nqontrol.servo package¶
Module contents¶
Servo class.
-
class
nqontrol.servo.
Servo
(channel, adw, applySettings=None, offset=0.0, gain=1.0, filters=None, name=None, keep_state=False)[source]¶ Bases:
object
Servo object that communicates with a control channel of the ADwin.
readFromFile overwrites all other parameters.
- Parameters
channel (
int
) – Channel used vor the Servo. Possible is 1..8 Channel number is used for input, output and process numberadw (
ADwin
) – For all servos of aServoDevice
to use the sameADwin
object, it is necessary to pass an ADwin object.applySettings (
str
or dict) – Apply settings directly from file or dict.offset (
offset
) – Overall offset.gain (
float
) –filters (5 * 5
list
) – Filter coefficient matrix. Default is a 0.0 matrix.name (
str
) – Choose an optional name for this servo.keep_state (
bool
) – Keep the current state of the running device. It will not reset or alter any configuration on ADwin.
-
REALTIME_DICTS
= ['realtime', '_fifo']¶
-
DEFAULT_COLUMNS
= ['input', 'aux', 'output']¶
-
realtime
= <DictProxy object, typeid 'dict'>¶
-
DEFAULT_FIFO_STEPSIZE
= 10¶
-
MAX_CHANNELS
= 8¶
-
property
channel
¶
-
property
filterStates
¶ List of all filter states.
-
filterState
(id_, enabled)¶ Enable or disable the SOS filter with number id_.
-
property
auxSw
¶ Switch for mixing the aux signal to the output.
- Getter
Return the state of aux mixing.
- Setter
Enable or disable the aux mixing.
- Type
-
property
offsetSw
¶ Enable or disable offset switch.
- Getter
Return the state of the switch.
- Setter
Enable or disable the offset.
- Type
-
property
outputSw
¶ Enable or disable output switch.
- Getter
Return the state of the switch.
- Setter
Enable or disable the output.
- Type
-
property
inputSw
¶ Enable or disable input switch.
- Getter
Return the state of the switch.
- Setter
Enable or disable the input.
- Type
-
property
offset
¶ Offset value in volt. (-10 to 10)
- Getter
Return the offset value.
- Setter
Set the offset.
- Type
-
property
inputSensitivity
¶ Input sensitivity mode (0 to 3).
The input voltage is amplified by \(2^\mathrm{mode}\).
mode
amplification
limits (V)
0
1
10
1
2
5
2
4
2.5
3
8
1.25
- Getter
Return the sensitivity mode.
- Setter
Set the mode.
- Type
-
property
auxSensitivity
¶ Aux sensitivity mode (0 to 3).
The input voltage is amplified by \(2^\mathrm{mode}\).
mode
amplification
limits (V)
0
1
10
1
2
5
2
4
2.5
3
8
1.25
- Getter
Return the sensitivity mode.
- Setter
Set the mode.
- Type
-
property
filters
¶ All second order sections (SOS) of all filters.
A neutral filter matrix looks like:
[ [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0] ]
Use
ServoDesign
fromopenqlab.analysis
to create your filters. That object you can simply pass to a servo usingapplyServoDesign
.- Getter
Return all filter values.
- Setter
Write all 5 filters to ADwin and trigger reloading.
- Type
(5, 5)
matrix with filter values (float
).
-
applyServoDesign
(servoDesign=None)¶ Apply filters from a
ServoDesign
object.- Parameters
servoDesign (
openqlab.analysis.ServoDesign
) – Object to apply filters from.
-
property
lockSearch
¶ Return the lock search state. Don’t confuse with locked.
0: off 1: search
- Getter
Trigger a read from ADwin. Return current value.
- Setter
Set new lock state. Will convert given value to bool and then back to int.
- Type
-
property
locked
¶ Return the locked state. Whether the servo is currently in locked state.
0: not locked 1: locked
- Getter
Trigger a read from ADwin. Return current value.
- Setter
Set new locked state. Will convert given value to bool and then back to int. Really only makes sense to turn this off manually, not on. Still, when manually switching on, will make sure to turn off lock search.
- Type
-
property
relock
¶ Set the lock to trigger a relock automatically when falling below or above threshold (according to greater setting). The relock parameter is either 0 or 1, can also be passed as a boolean.
- Getter
Return the current value.
- Setter
Set the condition.
- Type
-
property
lockGreater
¶ Set the lock direction to either greater (True) or lesser (False) than the threshold.
- Getter
Return the current value.
- Setter
Set the condition.
- Type
-
property
lockRampmode
¶ Enable rampmode bit for lock function. If in ramp mode, the autolock will keep searching even if a lock is found. This replaces the previous ramp.
- Getter
Return current rampmode bit.
- Setter
Set rampmode bit True or False.
- Type
-
property
lockThreshold
¶ Get or set the autolock threshold.
- Getter
Trigger a read from ADwin. Return the threshold.
- Setter
Set the threshold.
- Type
-
property
lockThresholdBreak
¶ Get or set the autolock threshold break. This is the tolerance value for falling out of lock.
- Getter
Trigger a read from ADwin. Return the threshold break.
- Setter
Set the threshold break value.
- Type
-
property
lockAmplitude
¶ Get or set the autolock ramp amplitude. A floating point number from 0 to 10 which will be multiplied to the normalized (-1 to 1 V) ramp.
ramp_position = amplitude * iterator + offset
- Getter
Trigger a read from ADwin. Return the amplitude.
- Setter
Set the amplitude.
- Type
-
property
lockOffset
¶ Get or set the autolock ramp offset. A floating point number from -10 to 10 V which will be added to the ramp.
ramp_position = amplitude * iterator + offset
- Getter
Trigger a read from ADwin. Return the offset.
- Setter
Set the offset.
- Type
-
property
lockFrequency
¶ Rough frequency of the ramp, might contain rounding errors. Calculates the frequency from the stepsize and search range of the lock. If possible, use the stepsize directly!
- Getter
Set the frequency.
- Setter
Get the frequency.
- Type
-
autolock
(search=True, relock=None, rampmode=None, amplitude=None, offset=None, frequency=None, analysis=True, **args)¶
-
enableRamp
(amplitude=None, offset=None, frequency=None, enableFifo=True)¶ Enable the lock ramp on this servo. Intended for command line use.
- Parameters
amplitude (
float
, optional) – Ramp amplitude from 0 to 10 V. (0 does not make too much sense, though.) Default 1.offset (
float
, optional) – Ramp offset from -10 to 10 V. Default 0.frequency (
float
, optional) – Ramp frequency from 1 to 100 Hz. (Can be changed in settings.)enableFifo (
bool
) – Defaults toTrue
. Possible not to enable the FIFO buffering for this servo.
-
disableRamp
()¶ Disable the ramp on this channel. Counterpart to enableRamp.
-
lockAnalysis
(testdata=None, raiseErrors: bool = False, tries: int = 10)¶ Analyze the threshold and direction to be used in the autolock feature. Takes in data or reads out automatically if None was provided. Determines the correct peak by analyzing median value of the AUX channel and comparing it to the signal’s maxima and minima. A peak is deemed valid if it is sufficiently different from the median value. Generally, one would expect good peaks to be much bigger than white noise, thus we deem the analysis valid using a 3 sigma criteria.
You can also use this in conjunction with the autolock command line method, e.g.
`python s = DEVICE.servo(1) s.lockAmplitude = 3 s.lockOffset = -4 s.lockFrequency = 3 s.lockAnalysis() s.autolock() `
- Parameters
testdata (
pandas.DataFrame
, optional) – For testing purposes one can provide a pandas DataFrame to be analyzed. Please make sure it contains a ‘aux’ column. If no data is provided, it will be read out from ADwin. (by default None)raiseErrors (bool, optional) – Can raise errors instead of logs for testing purposes. (by default False)
-
getSettingsDict
()¶ Get a dict with all servo settings.
- Returns
Return all important settings for the current servo state.
- Return type
-
saveJsonToFile
(filename)¶ Save this single servo as json to a file.
- Parameters
filename (
str
) – Filename to save the json file.
-
loadSettings
(applySettings, keep_state=False)¶ Load settings from file or dict.
Not reading the channel, it can only be set on creating a servo object.
-
property
fifoStepsize
¶ Use
nqontrol.Servo.enableFifo()
Trigger ADwin to write the three channels of this servo to the FIFO buffer to read it with the PC over LAN.
input
,aux
andoutput
will be sent.- Getter
Number of program cycles between each data point.
- Setter
Set the number or choose None to disable the FiFo output.
- Type
- Type
Setter DEPRECATED
-
property
realtimeEnabled
¶
-
property
fifoEnabled
¶
-
disableFifo
()¶ Disable the FiFo output if it is enabled on this channel.
-
takeData
() → pandas.core.frame.DataFrame¶ Take data from ADwin.
It will return a DataFrame containing the columns input, aux and output.
- Returns
returnVar
- Return type
DataFrame
-
stopRealtimePlot
()¶ Stop the realtime plot.
-
realtimePlot
(ydata=None, refreshTime=None, multiprocessing=True)¶ Enable parallel realtime plotting.
To stop the running job call stopRealtimePlot().
-
property
tempFeedback
¶ Return or set temperature feedback server associated with the servo.
- Getter
Return the
FeedbackController
.- Setter
Set a new
FeedbackController
.- Type
FeedbackController
.
-
tempFeedbackStart
(dT=None, mtd=None, voltage_limit=None, server='127.0.0.1', port=5917, update_interval=None)¶ Start the temperature feedback server. Setup a server if it hasn’t been previously set.
- Parameters
dT (
float
) – Description of parameter dT.mtd (
tuple
) – (1, 1)voltage_limit (
float
) – The maximum voltage to which one can go using the temperature control (the default is 5).server (type) – Description of parameter server (the default is settings.DEFAULT_TEMP_HOST).
port (type) – Description of parameter port (the default is settings.DEFAULT_TEMP_PORT).
update_interval (
float
) – Description of parameter update_interval (the default is 1).
-
tempFeedbackStop
()¶ Stop the tempFeedback server.