mirror of https://github.com/m-labs/artiq.git
Tpz fixes (#1178)
* flake8 * fix TPZ constructor after move to asyncio * Tcube fix docummentation in set_channel_enable_state
This commit is contained in:
parent
6d7790844d
commit
c0d89db677
|
@ -207,7 +207,8 @@ class _Tcube:
|
||||||
# derived classes must implement this
|
# derived classes must implement this
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
async def send_request(self, msgreq_id, wait_for_msgs, param1=0, param2=0, data=None):
|
async def send_request(self, msgreq_id, wait_for_msgs, param1=0, param2=0,
|
||||||
|
data=None):
|
||||||
await self.send(Message(msgreq_id, param1, param2, data=data))
|
await self.send(Message(msgreq_id, param1, param2, data=data))
|
||||||
msg = None
|
msg = None
|
||||||
while msg is None or msg.id not in wait_for_msgs:
|
while msg is None or msg.id not in wait_for_msgs:
|
||||||
|
@ -218,7 +219,7 @@ class _Tcube:
|
||||||
async def set_channel_enable_state(self, activated):
|
async def set_channel_enable_state(self, activated):
|
||||||
"""Enable or Disable channel 1.
|
"""Enable or Disable channel 1.
|
||||||
|
|
||||||
:param activated: 1 to enable channel, 2 to disable it.
|
:param activated: 1 to enable channel, 0 to disable it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if activated:
|
if activated:
|
||||||
|
@ -283,9 +284,13 @@ class _Tcube:
|
||||||
|
|
||||||
|
|
||||||
class Tpz(_Tcube):
|
class Tpz(_Tcube):
|
||||||
|
"""Either :py:meth:`set_tpz_io_settings()<Tpz.set_tpz_io_settings>`
|
||||||
|
or :py:meth:`get_tpz_io_settings()<Tpz.get_tpz_io_settings>` must
|
||||||
|
be completed to finish initialising the driver.
|
||||||
|
"""
|
||||||
def __init__(self, serial_dev):
|
def __init__(self, serial_dev):
|
||||||
_Tcube.__init__(self, serial_dev)
|
_Tcube.__init__(self, serial_dev)
|
||||||
self.voltage_limit = self.get_tpz_io_settings()[0]
|
self.voltage_limit = None
|
||||||
|
|
||||||
async def handle_message(self, msg):
|
async def handle_message(self, msg):
|
||||||
msg_id = msg.id
|
msg_id = msg.id
|
||||||
|
@ -348,9 +353,8 @@ class Tpz(_Tcube):
|
||||||
:param voltage: The output voltage applied to the piezo when operating
|
:param voltage: The output voltage applied to the piezo when operating
|
||||||
in open loop mode. The voltage value must be in range
|
in open loop mode. The voltage value must be in range
|
||||||
[0; voltage_limit]. Voltage_limit being set by the
|
[0; voltage_limit]. Voltage_limit being set by the
|
||||||
:py:meth:`set_tpz_io_settings()
|
:py:meth:`set_tpz_io_settings()<Tpz.set_tpz_io_settings>`
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_tpz_io_settings>` method
|
method between the three values 75 V, 100 V and 150 V.
|
||||||
between the three values 75 V, 100 V and 150 V.
|
|
||||||
"""
|
"""
|
||||||
if voltage < 0 or voltage > self.voltage_limit:
|
if voltage < 0 or voltage > self.voltage_limit:
|
||||||
raise ValueError("Voltage must be in range [0;{}]"
|
raise ValueError("Voltage must be in range [0;{}]"
|
||||||
|
@ -404,7 +408,7 @@ class Tpz(_Tcube):
|
||||||
|
|
||||||
0x00 Software Only: Unit responds only to software inputs and the
|
0x00 Software Only: Unit responds only to software inputs and the
|
||||||
HV amp output is that set using the :py:meth:`set_output_volts()
|
HV amp output is that set using the :py:meth:`set_output_volts()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_output_volts>` method.
|
<Tpz.set_output_volts>` method.
|
||||||
|
|
||||||
0x01 External Signal: Unit sums the differential signal on the rear
|
0x01 External Signal: Unit sums the differential signal on the rear
|
||||||
panel EXT IN(+) and EXT IN(-) connectors with the voltage set
|
panel EXT IN(+) and EXT IN(-) connectors with the voltage set
|
||||||
|
@ -426,9 +430,8 @@ class Tpz(_Tcube):
|
||||||
amplifier circuit.
|
amplifier circuit.
|
||||||
|
|
||||||
:return: Value which selects the various analog sources, cf.
|
:return: Value which selects the various analog sources, cf.
|
||||||
:py:meth:`set_input_volts_source()
|
:py:meth:`set_input_volts_source()<Tpz.set_input_volts_source>`
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_input_volts_source>` method
|
method docstring for meaning of bits.
|
||||||
docstring for meaning of bits.
|
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
get_msg = await self.send_request(MGMSG.PZ_REQ_INPUTVOLTSSRC,
|
get_msg = await self.send_request(MGMSG.PZ_REQ_INPUTVOLTSSRC,
|
||||||
|
@ -488,7 +491,7 @@ class Tpz(_Tcube):
|
||||||
applicable channel is specified by the Chan Ident parameter If only a
|
applicable channel is specified by the Chan Ident parameter If only a
|
||||||
sub set of the array is being used (as specified by the cyclelength
|
sub set of the array is being used (as specified by the cyclelength
|
||||||
parameter of the :py:meth:`set_output_lut_parameters()
|
parameter of the :py:meth:`set_output_lut_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_output_lut_parameters>`
|
<Tpz.set_output_lut_parameters>`
|
||||||
function), then only the first cyclelength values need to be set. In
|
function), then only the first cyclelength values need to be set. In
|
||||||
this manner, any arbitrary voltage waveform can be programmed into the
|
this manner, any arbitrary voltage waveform can be programmed into the
|
||||||
LUT. Note. The LUT values are output by the system at a maximum
|
LUT. Note. The LUT values are output by the system at a maximum
|
||||||
|
@ -499,8 +502,8 @@ class Tpz(_Tcube):
|
||||||
to 512 for TPZ).
|
to 512 for TPZ).
|
||||||
:param output: The voltage value to be set. Values are in the range
|
:param output: The voltage value to be set. Values are in the range
|
||||||
[0; voltage_limit]. Voltage_limit being set with the
|
[0; voltage_limit]. Voltage_limit being set with the
|
||||||
:py:meth:`set_tpz_io_settings
|
:py:meth:`set_tpz_io_settings<Tpz.set_tpz_io_settings>`
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_tpz_io_settings>` method.
|
method.
|
||||||
"""
|
"""
|
||||||
volt = round(output*32767/self.voltage_limit)
|
volt = round(output*32767/self.voltage_limit)
|
||||||
payload = st.pack("<HHH", 1, lut_index, volt)
|
payload = st.pack("<HHH", 1, lut_index, volt)
|
||||||
|
@ -519,7 +522,8 @@ class Tpz(_Tcube):
|
||||||
return index, output*self.voltage_limit/32767
|
return index, output*self.voltage_limit/32767
|
||||||
|
|
||||||
async def set_output_lut_parameters(self, mode, cycle_length, num_cycles,
|
async def set_output_lut_parameters(self, mode, cycle_length, num_cycles,
|
||||||
delay_time, precycle_rest, postcycle_rest):
|
delay_time, precycle_rest,
|
||||||
|
postcycle_rest):
|
||||||
"""Set Waveform Generator Mode parameters.
|
"""Set Waveform Generator Mode parameters.
|
||||||
|
|
||||||
It is possible to use the controller in an arbitrary Waveform
|
It is possible to use the controller in an arbitrary Waveform
|
||||||
|
@ -680,8 +684,8 @@ class Tpz(_Tcube):
|
||||||
|
|
||||||
:return: Returns a tuple whose elements are the voltage limit and the
|
:return: Returns a tuple whose elements are the voltage limit and the
|
||||||
Hub analog input. Refer to :py:meth:`set_tpz_io_settings()
|
Hub analog input. Refer to :py:meth:`set_tpz_io_settings()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tpz.set_tpz_io_settings>` for the
|
<Tpz.set_tpz_io_settings>` for
|
||||||
meaning of those parameters.
|
the meaning of those parameters.
|
||||||
:rtype: a 2 elements tuple (int, int)
|
:rtype: a 2 elements tuple (int, int)
|
||||||
"""
|
"""
|
||||||
get_msg = await self.send_request(MGMSG.PZ_REQ_TPZ_IOSETTINGS,
|
get_msg = await self.send_request(MGMSG.PZ_REQ_TPZ_IOSETTINGS,
|
||||||
|
@ -760,8 +764,7 @@ class Tdc(_Tcube):
|
||||||
|
|
||||||
:return: An 8 int tuple containing the following values: zero_wnd,
|
:return: An 8 int tuple containing the following values: zero_wnd,
|
||||||
vel1, wnd1, vel2, wnd2, vel3, wnd3, vel4. See
|
vel1, wnd1, vel2, wnd2, vel3, wnd3, vel4. See
|
||||||
:py:meth:`set_pot_parameters()
|
:py:meth:`set_pot_parameters()<Tdc.set_pot_parameters>` for a
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_pot_parameters>` for a
|
|
||||||
description of each tuple element meaning.
|
description of each tuple element meaning.
|
||||||
:rtype: An 8 int tuple
|
:rtype: An 8 int tuple
|
||||||
"""
|
"""
|
||||||
|
@ -950,7 +953,8 @@ class Tdc(_Tcube):
|
||||||
This call is blocking until device is homed or move is stopped.
|
This call is blocking until device is homed or move is stopped.
|
||||||
"""
|
"""
|
||||||
await self.send_request(MGMSG.MOT_MOVE_HOME,
|
await self.send_request(MGMSG.MOT_MOVE_HOME,
|
||||||
[MGMSG.MOT_MOVE_HOMED, MGMSG.MOT_MOVE_STOPPED], 1)
|
[MGMSG.MOT_MOVE_HOMED, MGMSG.MOT_MOVE_STOPPED],
|
||||||
|
1)
|
||||||
|
|
||||||
async def set_limit_switch_parameters(self, cw_hw_limit, ccw_hw_limit):
|
async def set_limit_switch_parameters(self, cw_hw_limit, ccw_hw_limit):
|
||||||
"""Set the limit switch parameters.
|
"""Set the limit switch parameters.
|
||||||
|
@ -988,7 +992,7 @@ class Tdc(_Tcube):
|
||||||
:return: A 2 int tuple containing the following in order: cw_hw_limit,
|
:return: A 2 int tuple containing the following in order: cw_hw_limit,
|
||||||
ccw_hw_limit. Cf. description in
|
ccw_hw_limit. Cf. description in
|
||||||
:py:meth:`set_limit_switch_parameters()
|
:py:meth:`set_limit_switch_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_limit_switch_parameters>`
|
<Tdc.set_limit_switch_parameters>`
|
||||||
method.
|
method.
|
||||||
:rtype: A 2 int tuple.
|
:rtype: A 2 int tuple.
|
||||||
"""
|
"""
|
||||||
|
@ -1001,11 +1005,13 @@ class Tdc(_Tcube):
|
||||||
|
|
||||||
The relative distance parameter used for the move will be the parameter
|
The relative distance parameter used for the move will be the parameter
|
||||||
sent previously by a :py:meth:`set_move_relative_parameters()
|
sent previously by a :py:meth:`set_move_relative_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_move_relative_parameters>`
|
<Tdc.set_move_relative_parameters>`
|
||||||
command.
|
command.
|
||||||
"""
|
"""
|
||||||
await self.send_request(MGMSG.MOT_MOVE_RELATIVE,
|
await self.send_request(MGMSG.MOT_MOVE_RELATIVE,
|
||||||
[MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED], 1)
|
[MGMSG.MOT_MOVE_COMPLETED,
|
||||||
|
MGMSG.MOT_MOVE_STOPPED],
|
||||||
|
1)
|
||||||
|
|
||||||
async def move_relative(self, relative_distance):
|
async def move_relative(self, relative_distance):
|
||||||
"""Start a relative move
|
"""Start a relative move
|
||||||
|
@ -1015,7 +1021,8 @@ class Tdc(_Tcube):
|
||||||
"""
|
"""
|
||||||
payload = st.pack("<Hl", 1, relative_distance)
|
payload = st.pack("<Hl", 1, relative_distance)
|
||||||
await self.send_request(MGMSG.MOT_MOVE_RELATIVE,
|
await self.send_request(MGMSG.MOT_MOVE_RELATIVE,
|
||||||
[MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED],
|
[MGMSG.MOT_MOVE_COMPLETED,
|
||||||
|
MGMSG.MOT_MOVE_STOPPED],
|
||||||
data=payload)
|
data=payload)
|
||||||
|
|
||||||
async def move_absolute_memory(self):
|
async def move_absolute_memory(self):
|
||||||
|
@ -1023,11 +1030,12 @@ class Tdc(_Tcube):
|
||||||
|
|
||||||
The absolute move position parameter used for the move will be the
|
The absolute move position parameter used for the move will be the
|
||||||
parameter sent previously by a :py:meth:`set_move_absolute_parameters()
|
parameter sent previously by a :py:meth:`set_move_absolute_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_move_absolute_parameters>`
|
<Tdc.set_move_absolute_parameters>`
|
||||||
command.
|
command.
|
||||||
"""
|
"""
|
||||||
await self.send_request(MGMSG.MOT_MOVE_ABSOLUTE,
|
await self.send_request(MGMSG.MOT_MOVE_ABSOLUTE,
|
||||||
[MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED],
|
[MGMSG.MOT_MOVE_COMPLETED,
|
||||||
|
MGMSG.MOT_MOVE_STOPPED],
|
||||||
param1=1)
|
param1=1)
|
||||||
|
|
||||||
async def move_absolute(self, absolute_distance):
|
async def move_absolute(self, absolute_distance):
|
||||||
|
@ -1039,7 +1047,8 @@ class Tdc(_Tcube):
|
||||||
"""
|
"""
|
||||||
payload = st.pack("<Hl", 1, absolute_distance)
|
payload = st.pack("<Hl", 1, absolute_distance)
|
||||||
await self.send_request(MGMSG.MOT_MOVE_ABSOLUTE,
|
await self.send_request(MGMSG.MOT_MOVE_ABSOLUTE,
|
||||||
[MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED],
|
[MGMSG.MOT_MOVE_COMPLETED,
|
||||||
|
MGMSG.MOT_MOVE_STOPPED],
|
||||||
data=payload)
|
data=payload)
|
||||||
|
|
||||||
async def move_jog(self, direction):
|
async def move_jog(self, direction):
|
||||||
|
@ -1048,7 +1057,8 @@ class Tdc(_Tcube):
|
||||||
:param direction: The direction to jog. 1 is forward, 2 is backward.
|
:param direction: The direction to jog. 1 is forward, 2 is backward.
|
||||||
"""
|
"""
|
||||||
await self.send_request(MGMSG.MOT_MOVE_JOG,
|
await self.send_request(MGMSG.MOT_MOVE_JOG,
|
||||||
[MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED],
|
[MGMSG.MOT_MOVE_COMPLETED,
|
||||||
|
MGMSG.MOT_MOVE_STOPPED],
|
||||||
param1=1, param2=direction)
|
param1=1, param2=direction)
|
||||||
|
|
||||||
async def move_velocity(self, direction):
|
async def move_velocity(self, direction):
|
||||||
|
@ -1057,15 +1067,15 @@ class Tdc(_Tcube):
|
||||||
When this method is called, the motor will move continuously in the
|
When this method is called, the motor will move continuously in the
|
||||||
specified direction using the velocity parameter set by the
|
specified direction using the velocity parameter set by the
|
||||||
:py:meth:`set_move_relative_parameters()
|
:py:meth:`set_move_relative_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_move_relative_parameters>`
|
<Tdc.set_move_relative_parameters>`
|
||||||
command until a :py:meth:`move_stop()
|
command until a :py:meth:`move_stop()<Tdc.move_stop>` command (either
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.move_stop>` command (either
|
|
||||||
StopImmediate or StopProfiled) is called, or a limit switch is reached.
|
StopImmediate or StopProfiled) is called, or a limit switch is reached.
|
||||||
|
|
||||||
:param direction: The direction to jog: 1 to move forward, 2 to move
|
:param direction: The direction to jog: 1 to move forward, 2 to move
|
||||||
backward.
|
backward.
|
||||||
"""
|
"""
|
||||||
await self.send(Message(MGMSG.MOT_MOVE_VELOCITY, param1=1, param2=direction))
|
await self.send(Message(MGMSG.MOT_MOVE_VELOCITY, param1=1,
|
||||||
|
param2=direction))
|
||||||
|
|
||||||
async def move_stop(self, stop_mode):
|
async def move_stop(self, stop_mode):
|
||||||
"""Stop any type of motor move.
|
"""Stop any type of motor move.
|
||||||
|
@ -1108,8 +1118,8 @@ class Tdc(_Tcube):
|
||||||
:return: A 5 int tuple containing in this order:
|
:return: A 5 int tuple containing in this order:
|
||||||
proportional gain, integral gain, differential gain, integral limit
|
proportional gain, integral gain, differential gain, integral limit
|
||||||
and filter control. Cf. :py:meth:`set_dc_pid_parameters()
|
and filter control. Cf. :py:meth:`set_dc_pid_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_dc_pid_parameters>` for
|
<Tdc.set_dc_pid_parameters>`
|
||||||
precise description.
|
for precise description.
|
||||||
:rtype: A 5 int tuple.
|
:rtype: A 5 int tuple.
|
||||||
"""
|
"""
|
||||||
get_msg = await self.send_request(MGMSG.MOT_REQ_DCPIDPARAMS,
|
get_msg = await self.send_request(MGMSG.MOT_REQ_DCPIDPARAMS,
|
||||||
|
@ -1151,10 +1161,10 @@ class Tdc(_Tcube):
|
||||||
:param mode: If set to 1, the buttons are used to jog the motor. Once
|
:param mode: If set to 1, the buttons are used to jog the motor. Once
|
||||||
set to this mode, the move parameters for the buttons are taken
|
set to this mode, the move parameters for the buttons are taken
|
||||||
from the arguments of the :py:meth:`set_jog_parameters()
|
from the arguments of the :py:meth:`set_jog_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_jog_parameters>` method.
|
<Tdc.set_jog_parameters>`
|
||||||
If set to 2, each button can be programmed with a differente
|
method. If set to 2, each button can be programmed with a
|
||||||
position value such that the controller will move the motor to that
|
differente position value such that the controller will move the
|
||||||
position when the specific button is pressed.
|
motor to that position when the specific button is pressed.
|
||||||
:param position1: The position (in encoder counts) to which the motor
|
:param position1: The position (in encoder counts) to which the motor
|
||||||
will move when the top button is pressed.
|
will move when the top button is pressed.
|
||||||
:param position2: The position (in encoder counts) to which the motor
|
:param position2: The position (in encoder counts) to which the motor
|
||||||
|
@ -1169,8 +1179,8 @@ class Tdc(_Tcube):
|
||||||
|
|
||||||
:return: A 3 int tuple containing in this order: button mode,
|
:return: A 3 int tuple containing in this order: button mode,
|
||||||
position1 and position2. Cf. :py:meth:`set_button_parameters()
|
position1 and position2. Cf. :py:meth:`set_button_parameters()
|
||||||
<artiq.devices.thorlabs_tcube.driver.Tdc.set_button_parameters>` for
|
<Tdc.set_button_parameters>`
|
||||||
description.
|
for description.
|
||||||
:rtype: A 3 int tuple
|
:rtype: A 3 int tuple
|
||||||
"""
|
"""
|
||||||
get_msg = await self.send_request(MGMSG.MOT_REQ_BUTTONPARAMS,
|
get_msg = await self.send_request(MGMSG.MOT_REQ_BUTTONPARAMS,
|
||||||
|
|
|
@ -53,6 +53,8 @@ def main():
|
||||||
dev = Tdc(args.device)
|
dev = Tdc(args.device)
|
||||||
elif product == "tpz001":
|
elif product == "tpz001":
|
||||||
dev = Tpz(args.device)
|
dev = Tpz(args.device)
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(dev.get_tpz_io_settings())
|
||||||
else:
|
else:
|
||||||
print("Invalid product string (-P/--product), "
|
print("Invalid product string (-P/--product), "
|
||||||
"choose from tdc001 or tpz001")
|
"choose from tdc001 or tpz001")
|
||||||
|
|
Loading…
Reference in New Issue