Kepco BOP GL Power Supply

The Kepco BOP GL power supplies are programmable power supplies that operate in current or voltage mode. The current implementation supports the Kepco BOP 50-20GL model.

Using EPICS Kepco BOP GL power supply module

Usage of Python class for EPICS Kepco BOP GL power supplies.

class py4syn.epics.KepcoBOPClass.KepcoBOP(pvName, mnemonic)[source]

Class to control Kepco BOP GL power supplies via EPICS.

Examples

>>> from py4syn.epics.KepcoBOPClass import KepcoBOP
>>>
>>> def configurePower(pv="", name="", voltage=5.0, currentLimit=1.0):
...    bop = KepcoBOP(pv, name)
...    bop.reset()
...    bop.setCurrentLimits(currentLimit, currentLimit)
...    bop.setVoltage(voltage)
...    return bop
...
>>> def smoothVoltageTransition(bop, initial=0.0, final=12.0, duration=2.0):
...    bop.setRampWaveform(duration, final-initial, (initial+final)/2)
...    bop.waveformStart()
...    bop.waveformWait()
...
>>> def noiseCurrent(bop):
...    bop.reset()
...    bop.setMode(KepcoBOP.MODE_CURRENT)
...    bop.setVoltageLimits(20, 20)
...    points = [random.uniform(-5, 5) for i in range(100)]
...    bop.clearWaveform()
...    bop.addWaveformPoints(points, [0.025])
...    bop.waveformStart()
...

Constructor See py4syn.epics.StandardDevice

Parameters:
pvName : string

Power supply base naming of the PV (Process Variable)

mnemonic : string

Power supply mnemonic

addLevelWaveform(length, offset)[source]

Adds a fixed level wave to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. The other way is sending the complete array of points for the waveform. This method is limited to a specific waveform type, but it’s faster to program than uploading individual points. When the final desired waveform can be composed of simple waveform segments, this is the best way to program the device.

Adding points does not execute the program. The method waveformStart() must be called.

See also: waveformStart(), setLevelWaveform(), addWaveformPoints(), addSineWaveform(), addRampWaveform(), addTriangleWaveform(), addSquareWaveform()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
length : float

The duration of the level waveform. The allowed range is 500µs to 5s. The number of points used is 60.

offset : float

The level offset. The offset cannot exceed the configured device limits.

addRampWaveform(length, height, offset)[source]

Adds a ramp wave to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. The other way is sending the complete array of points for the waveform. This method is limited to a specific waveform type and it also consumes a lot of points, but it’s faster to program than uploading individual points. When the final desired waveform can be composed of simple waveform segments, this is the best way to program the device.

Adding points does not execute the program. The method waveformStart() must be called.

See also: waveformStart(), setRampWaveform(), addWaveformPoints(), addSineWaveform(), addTriangleWaveform(), addSquareWaveform(), addLevelWaveform()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
length : float

The ramp length. The allowed range is [1/532, 100] (1.88ms to 100s). The number of points used vary from 20, for smaller ramps, to 3840, for larger ramps.

height : float

The ramp height. The height can be positive or negative. It cannot exceed the range defined by the configured operating device limits.

offset : float

The offset of the ramp middle height. The offset cannot exceed the configured device limits.

addSineWaveform(frequency, amplitude, offset, start=0, stop=360)[source]

Adds a sine wave to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. The other way is sending the complete array of points for the waveform. This method is limited to a specific waveform type and it also consumes a lot of points, but it’s faster to program than uploading individual points. When the final desired waveform can be composed of simple waveform segments, this is the best way to program the device.

Adding points does not execute the program. The method waveformStart() must be called.

See also: waveformStart(), setSineWaveform(), addWaveformPoints(), addTriangleWaveform(), addRampWaveform(), addSquareWaveform(), addLevelWaveform()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
frequency : float

The sine wave frequency. The allowed range is 0.01Hz to 443Hz. The number of points used vary from 3840, for lower frequency waves to 24, for higher frequency waves.

amplitude : float

The sine wave peak to peak amplitude. The peak to peak amplitude cannot exceed the range defined by the configured operating device limits.

offset : float

The offset of the sine wave zero amplitude. The offset cannot exceed the configured device limits.

start : float

The starting angle for the sine wave, in degrees. Allowed range is [0.0, 359.99]

stop : float

The stop angle for the sine wave, in degrees. Allowed range is [0.01, 360.0]

addSquareWaveform(frequency, amplitude, offset)[source]

Adds a square wave (constant 50% duty cycle, starts with positive excursion) to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. The other way is sending the complete array of points for the waveform. This method is limited to a specific waveform type and it also consumes a lot of points, but it’s faster to program than uploading individual points. When the final desired waveform can be composed of simple waveform segments, this is the best way to program the device.

Adding points does not execute the program. The method waveformStart() must be called.

See also: waveformStart(), setSquareWaveform(), addWaveformPoints(), addSineWaveform(), addTriangleWaveform(), addRampWaveform(), addLevelWaveform()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
frequency : float

The square wave frequency. The allowed range is 0.02Hz to 1000Hz. The number of points used vary from 3840, for lower frequency waves to 10, for higher frequency waves.

amplitude : float

The square wave peak to peak amplitude. The peak to peak amplitude cannot exceed the range defined by the configured operating device limits.

offset : float

The offset of the square wave zero amplitude. The offset cannot exceed the configured device limits.

addTriangleWaveform(frequency, amplitude, offset, start=0, stop=360)[source]

Adds a triangle wave to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. The other way is sending the complete array of points for the waveform. This method is limited to a specific waveform type and it also consumes a lot of points, but it’s faster to program than uploading individual points. When the final desired waveform can be composed of simple waveform segments, this is the best way to program the device.

Adding points does not execute the program. The method waveformStart() must be called.

See also: waveformStart(), setTriangleWaveform(), addWaveformPoints(), addSineWaveform(), addRampWaveform(), addSquareWaveform(), addLevelWaveform()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
frequency : float

The triangle wave frequency. The allowed range is 0.01Hz to 443Hz. The number of points used vary from 3840, for lower frequency waves to 24, for higher frequency waves.

amplitude : float

The triangle wave peak to peak amplitude. The peak to peak amplitude cannot exceed the range defined by the configured operating device limits.

offset : float

The offset of the triangle wave zero amplitude. The offset cannot exceed the configured device limits.

start : float

The starting angle for the triangle wave, in degrees. Allowed range is [0.0, 359.99]

stop : float

The stop angle for the triangle wave, in degrees. Allowed range is [0.01, 360.0]

addWaveform(tp, param1, param2, param3=None)[source]

Helper method that implements adding waveform segments.

addWaveformPoints(points, times)[source]

Adds a set of points to the waveform program. This is one of the ways that the device can be programmed to generate a complex waveform. It’s the most flexible way, allowing arbitrary waveforms, but it’s also the slowest one (a 10 second waveform may take at least 4 seconds just to upload the program). This method adds more points to the current waveform program. It does not overwrite the existing program.

Adding points does not execute the program. The method waveformStart() must be called.

See also: setWaveformPoints(), addSineWaveform(), addTriangleWaveform(), addRampWaveform(), addSquareWaveform(), addLevelWaveform(), waveformStart()

Note

When changing operating mode, the waveform program must be cleared if necessary, because the device will prohibit mixing points from different modes.

Parameters:
points : array of floats

The array of points to be added to the program. The total number of allowed points may vary, depending on the times array. When the times array has exactly one element, the maximum number of points is 5900. When the times array has at most 126 distinct values, the maximum number of points is 3933. When the times array has more than 126 distinct values, the maximum number of points is 2950.

times : array of floats

The dwell times for each point. Either there must be one time entry for each point, or the array of times must contain exactly one element, which sets the time for all points. The allowed time range is [93e-6, 34e-3] (93µs to 34ms).

cachedMode()[source]

Helper method to return cached operating mode

checkError()[source]

Helper method to raise an exception if the device reports an error.

clearWaveform()[source]

Clears the programmed waveform data. This is required when building a new waveform program. Waveform data can only be cleared while the program is not running.

defaults()[source]

Helper method to reset internal data.

getCurrent()[source]

Measures the current value. The measured value that is read back is known to have an error (less than 1%) and a delay (up to 320ms).

Returns:
`float`
getCurrentLimits()[source]

Gets the negative and positive current limits allowed for operation. The specific limit type that is read depends on the operating mode. When in current mode, the limit set is a main channel limit: it defines the limits of the current that can be programmed by the user. When in voltage mode, the limit is a protection limit: it defines the current limits that the load may impose because of the requested voltage. When changing the operating modes, the set limits no longer apply: they are different for the new mode.

See also: setMode()

Returns:
negative : float

The absolute value of the negative limit

positive : float

The absolute value of the positive limit

getError()[source]

Helper method to pop the last error from the device error queue.

getHighLimitValue()[source]

Gets either the voltage or current high limit value, depending on operation mode.

Returns:
`float`
getLimits(device, mode)[source]

Helper method that implements getVoltageLimits() and :meth: getCurrentLimits

getLowLimitValue()[source]

Gets either the voltage or current low limit value, depending on operation mode.

Returns:
`float`
getOperationFlag()[source]

Returns the real time value of the device operation condition register. The register contains a set of bits representing the following flags: “list running” (16384), “list complete” (4096), “sample complete” (2048), “constant current mode” (1024), “transient complete” (512)”, “constant voltage mode” (256), “transient armed” (64), “waiting for trigger” (32). Refer to the Kepco BOP GL manual for specific details. The relevant flag used by the library is the “list running” flag, which indicates that theres a waveform program running.

See also: isWaveformRunning(), waveformWait()

Returns:
`int`
getProgramLength()[source]

Helper method that returns the number of points in current waveform program.

getValue()[source]

Returns either the readback voltage or the current, depending on operating mode.

Returns:
`float`
getVoltage()[source]

Measures the voltage value. The measured value that is read back is known to have an error (less than 1%) and a delay (up to 320ms).

Returns:
`float`
getVoltageLimits()[source]

Gets the negative and positive voltage limits allowed for operation. The specific limit type that is read depends on the operating mode. When in voltage mode, the limit set is a main channel limit: it defines the limits of the voltages that can be programmed by the user. When in current mode, the limit is a protection limit: it defines the voltage limits that the load may impose because of the requested current. When changing the operating modes, the set limits no longer apply: they are different for the new mode.

See also: setMode()

Returns:
negative : float

The absolute value of the negative limit

positive : float

The absolute value of the positive limit

getWaveformRepeat()[source]

Gets the last requested waveform repeat count.

See also: setWaveformRepeat()

Returns:
`int`
isWaveformRunning()[source]

Returns whether there’s a running waveform program.

See also: getOperationFlag(), waveformWait()

Returns:
`bool`
procAndGet(device, pv)[source]

Helper method to synchronously execute a query in the device.

reset()[source]

Resets the device to a known state. Possible reset states may vary with the device configuration, but generally will be a zero value output (either voltage or current) with low protection limits. The device error queue will be cleared.

setCurrent(current, wait=True)[source]

Sets the current value. This method can only be used when in current mode. The current values must be within the power supply acceptable range and also within the configured limit values.

See also: setMode(), setCurrentLimits()

Parameters:
current : float

The desired current value

setCurrentLimits(negative=None, positive=None)[source]

Sets the negative and positive current limits allowed for operation. The specific limit type that is set depends on the operating mode. When in current mode, the limit set is a main channel limit: it defines the limits of the current that can be programmed by the user. When in voltage mode, the limit is a protection limit: it defines the current limits that the load may impose because of the requested voltage. When changing the operating modes, the set limits no longer apply: they must be set again for the new mode.

See also: setMode()

Parameters:
negative : float

The absolute value of the negative limit

positive : float

The absolute value of the positive limit

setLevelWaveform(length, offset)[source]

A shortcut to clearing the waveform program, adding a level waveform and setting the repeat count to 1.

See also: clearWaveform(), addLevelWaveform(), setWaveformRepeat()

Parameters:
length : float

Parameter passed to addLevelWaveform()

offset : float

Parameter passed to addLevelWaveform()

setLimits(device, mode, negative=None, positive=None, maximum=1e+100)[source]

Helper method that implements setVoltageLimits() and setCurrentLimits()

setMode(mode)[source]

Changes the operating mode. Supported modes are voltage mode and current mode. In the voltage mode, the device tries to set a specific voltage, while staying within the current protection limits. In current mode, the device tries to set a specific current, while staying within the voltage protection limits. See also: setCurrentLimits(), setVoltageLimits()

Parameters:
mode : {KepcoBOP.MODE_CURRENT, KepcoBOP.MODE_VOLTAGE}

The desired mode

setRampWaveform(length, height, offset)[source]

A shortcut to clearing the waveform program, adding ramp waveform and setting the repeat count to 1.

See also: clearWaveform(), addRampWaveform(), setWaveformRepeat()

Parameters:
length : float

Parameter passed to addRampWaveform()

height : float

Parameter passed to addRampWaveform()

offset : float

Parameter passed to addRampWaveform()

setSineWaveform(frequency, amplitude, offset, start=0, stop=360)[source]

A shortcut to clearing the waveform program, adding sine waveform and setting the repeat count to 1.

See also: clearWaveform(), addSineWaveform(), setWaveformRepeat()

Parameters:
frequency : float

Parameter passed to addSineWaveform()

amplitude : float

Parameter passed to addSineWaveform()

offset : float

Parameter passed to addSineWaveform()

start : float

Parameter passed to addSineWaveform()

stop : float

Parameter passed to addSineWaveform()

setSquareWaveform(frequency, amplitude, offset)[source]

A shortcut to clearing the waveform program, adding square waveform and setting the repeat count to 1.

See also: clearWaveform(), addSquareWaveform(), setWaveformRepeat()

Parameters:
frequency : float

Parameter passed to addSquareWaveform()

amplitude : float

Parameter passed to addSquareWaveform()

offset : float

Parameter passed to addSquareWaveform()

setTriangleWaveform(frequency, amplitude, offset, start=0, stop=360)[source]

A shortcut to clearing the waveform program, adding triangle waveform and setting the repeat count to 1.

See clearWaveform(), addTriangleWaveform(), setWaveformRepeat()

Parameters:
frequency : float

Parameter passed to addTriangleWaveform()

amplitude : float

Parameter passed to addTriangleWaveform()

offset : float

Parameter passed to addTriangleWaveform()

start : float

Parameter passed to addTriangleWaveform()

stop : float

Parameter passed to addTriangleWaveform()

setValue(v, wait=True)[source]

Sets either the current voltage or current, depending on operating mode.

Parameters:
v : float

Either voltage, or current to set, depending on operating mode.

setVoltage(voltage, wait=True)[source]

Sets the voltage value. This method can only be used when in voltage mode. The voltage values must be within the power supply acceptable range and also within the configured limit values.

See also: setMode(), setVoltageLimits()

Parameters:
voltage : float

The desired voltage value

setVoltageLimits(negative=None, positive=None)[source]

Sets the negative and positive voltage limits allowed for operation. The specific limit type that is set depends on the operating mode. When in voltage mode, the limit set is a main channel limit: it defines the limits of the voltages that can be programmed by the user. When in current mode, the limit is a protection limit: it defines the voltage limits that the load may impose because of the requested current. When changing the operating modes, the set limits no longer apply: they must be set again for the new mode.

See also: setMode()

Parameters:
negative : float

The absolute value of the negative limit

positive : float

The absolute value of the positive limit

setWaveformAngle(start=0, stop=360)[source]

Helper method that configures start and stop angles for sine and triangle waveforms.

setWaveformPoints(points, times)[source]

A shortcut to clearing the waveform program, adding waveform points and setting the repeat count to 1.

See also: clearWaveform(), addWaveformPoints(), setWaveformRepeat()

Parameters:
points : array of floats

Parameter passed to addWaveformPoints()

times : array of floats

Parameter passed to addWaveformPoints()

setWaveformRepeat(repeat)[source]

Set the number of times the waveform program will run. By default, the program runs an indeterminate number of times, until it’s explicitly stopped. This method is used to specify the number of times the waveform program will repeat.

A waveform may also have separate one-shot part and repeatable part. Use the method setWaveformRepeatMark() to separate them.

See also: setWaveformRepeatMark(), waveformStop(), waveformAbort()

Parameters:
repeat : int

Number of times the programmed waveform will run. A value of zero means run until explicitly stopped.

setWaveformRepeatMark(position=None)[source]

Separates the one-short part from the repeating part in the waveform program. By default, the whole waveform repeats, according to the repeat count. This method marks the separation point that allows the definition of an initial one-shot part of the wave. The part before the marked point will be the one-shot part and after the marked point will be the repeating part.

See also: setWaveformRepeat()

Parameters:
position : int

Desired position of the setWaveformRepeatMark, representing the point in the waveform that starts the repeating part. If unset, the current first free position in the waveform is set as the mark.

wait()[source]

Does the same as waveformWait().

waveformAbort()[source]

Immediatelly stops a running waveform. The final output value will be the value before running the waveform program.

See also: waveformStop(), waveformWait()

waveformStart()[source]

Executes a waveform program. The program must be already defined by using the waveform add methods. This methods triggers the execution and returns immediatelly. It does not wait for the complete waveform execution to finish.

By default, the waveform will repeat until it is explicitly stopped, but this can be configured by the setWaveformRepeat() method. To stop the waveform execution, the methods waveformStop() and waveformAbort() can be used. For a program with finite repeat count, it’s possible to wait until the waveform finishes with waveformWait().

See also: addWaveformPoints(), addSineWaveform(), addTriangleWaveform(), addRampWaveform(), addSquareWaveform(), addLevelWaveform(), waveformStop(), waveformAbort(), waveformWait(), isWaveformRunning()

waveformStop()[source]

Requests to stop a running waveform. The waveform will execute until the end and then will stop, without repeating the program again. The final output value will be the final point in the program.

See also: waveformAbort(), waveformWait()

Note

Because it’s not possible to reliably stop a program with finite repeat count without potentially triggering an “already finished” error, this command is only enabled for stopping waveform programs with inifinite repeat count. For finite repeat counts, use waveformAbort(), or waveformWait() instead.

waveformWait()[source]

Waits until the whole waveform program finishes, including all repetitions. It’s only possible to wait for waveform programs with finite repeat counts.

Note

When using the Kepco power supply with a serial port, it’s not possible to receive a notification from the device when the waveform finishes, so this method works by repeatedly polling the device requesting the operation flag. Because of this, the recommended way to use this method is first sleeping for as much time as possible to avoid the loop and only on the last second call this method. Example of a helper function that accomplishes this:

Examples

>>> def runAndWait(bop, totalTime):
...     bop.waveformStart()
...     sleep(max(totalTime-1, 0))
...     bop.waveformWait()
...