diff --git a/artiq/devices/thorlabs_tcube/driver.py b/artiq/devices/thorlabs_tcube/driver.py index 0e8674193..061741a23 100644 --- a/artiq/devices/thorlabs_tcube/driver.py +++ b/artiq/devices/thorlabs_tcube/driver.py @@ -1,8 +1,9 @@ from enum import Enum import logging import struct as st +import asyncio -import serial +import asyncserial logger = logging.getLogger(__name__) @@ -166,22 +167,6 @@ class Message: return st.pack("` method + ` method between the three values 75 V, 100 V and 150 V. """ if voltage < 0 or voltage > self.voltage_limit: @@ -360,19 +357,19 @@ class Tpz(_Tcube): .format(self.voltage_limit)) volt = int(voltage*32767/self.voltage_limit) payload = st.pack("` method. + ` method. 0x01 External Signal: Unit sums the differential signal on the rear panel EXT IN(+) and EXT IN(-) connectors with the voltage set @@ -422,23 +419,23 @@ class Tpz(_Tcube): either or both of the other source options. """ payload = st.pack("` method + ` method docstring for meaning of bits. :rtype: int """ - get_msg = self.send_request(MGMSG.PZ_REQ_INPUTVOLTSSRC, + get_msg = await self.send_request(MGMSG.PZ_REQ_INPUTVOLTSSRC, [MGMSG.PZ_GET_INPUTVOLTSSRC], 1) return st.unpack("` + ` function), then only the first cyclelength values need to be set. In this manner, any arbitrary voltage waveform can be programmed into the LUT. Note. The LUT values are output by the system at a maximum @@ -503,26 +500,26 @@ class Tpz(_Tcube): :param output: The voltage value to be set. Values are in the range [0; voltage_limit]. Voltage_limit being set with the :py:meth:`set_tpz_io_settings - ` method. + ` method. """ volt = round(output*32767/self.voltage_limit) payload = st.pack("` for the + ` for the meaning of those parameters. :rtype: a 2 elements tuple (int, int) """ - get_msg = self.send_request(MGMSG.PZ_REQ_TPZ_IOSETTINGS, - [MGMSG.PZ_GET_TPZ_IOSETTINGS], 1) + get_msg = await self.send_request(MGMSG.PZ_REQ_TPZ_IOSETTINGS, + [MGMSG.PZ_GET_TPZ_IOSETTINGS], 1) voltage_limit, hub_analog_input = st.unpack("` for a + ` for a description of each tuple element meaning. :rtype: An 8 int tuple """ - get_msg = self.send_request(MGMSG.MOT_REQ_POTPARAMS, - [MGMSG.MOT_GET_POTPARAMS], 1) + get_msg = await self.send_request(MGMSG.MOT_REQ_POTPARAMS, + [MGMSG.MOT_GET_POTPARAMS], 1) return st.unpack("` + ` method. :rtype: A 2 int tuple. """ - get_msg = self.send_request(MGMSG.MOT_REQ_LIMSWITCHPARAMS, - [MGMSG.MOT_GET_LIMSWITCHPARAMS], 1) + get_msg = await self.send_request(MGMSG.MOT_REQ_LIMSWITCHPARAMS, + [MGMSG.MOT_GET_LIMSWITCHPARAMS], 1) return st.unpack("` + ` command. """ - self.send_request(MGMSG.MOT_MOVE_RELATIVE, - [MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED], 1) + await self.send_request(MGMSG.MOT_MOVE_RELATIVE, + [MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED], 1) - def move_relative(self, relative_distance): + async def move_relative(self, relative_distance): """Start a relative move :param relative_distance: The distance to move in position encoder counts. """ payload = st.pack("` + ` command. """ - self.send_request(MGMSG.MOT_MOVE_ABSOLUTE, - [MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED], - param1=1) + await self.send_request(MGMSG.MOT_MOVE_ABSOLUTE, + [MGMSG.MOT_MOVE_COMPLETED, MGMSG.MOT_MOVE_STOPPED], + param1=1) - def move_absolute(self, absolute_distance): + async def move_absolute(self, absolute_distance): """Start an absolute move. :param absolute_distance: The distance to move. This is a signed @@ -1040,36 +1038,36 @@ class Tdc(_Tcube): counts. """ payload = st.pack("` + ` command until a :py:meth:`move_stop() - ` command (either + ` command (either StopImmediate or StopProfiled) is called, or a limit switch is reached. :param direction: The direction to jog: 1 to move forward, 2 to move backward. """ - self.send(Message(MGMSG.MOT_MOVE_VELOCITY, param1=1, param2=direction)) + await self.send(Message(MGMSG.MOT_MOVE_VELOCITY, param1=1, param2=direction)) - def move_stop(self, stop_mode): + async def move_stop(self, stop_mode): """Stop any type of motor move. Stops any of those motor move: relative, absolute, homing or move at @@ -1079,13 +1077,13 @@ class Tdc(_Tcube): or profiled stop. Set this byte to 1 to stop immediately, or to 2 to stop in a controlled (profiled) manner. """ - if self.is_moving(): - self.send_request(MGMSG.MOT_MOVE_STOP, - [MGMSG.MOT_MOVE_STOPPED, - MGMSG.MOT_MOVE_COMPLETED], - 1, stop_mode) + if await self.is_moving(): + await self.send_request(MGMSG.MOT_MOVE_STOP, + [MGMSG.MOT_MOVE_STOPPED, + MGMSG.MOT_MOVE_COMPLETED], + 1, stop_mode) - def set_dc_pid_parameters(self, proportional, integral, differential, + async def set_dc_pid_parameters(self, proportional, integral, differential, integral_limit, filter_control=0x0F): """Set the position control loop parameters. @@ -1102,23 +1100,23 @@ class Tdc(_Tcube): """ payload = st.pack("` for + ` for precise description. :rtype: A 5 int tuple. """ - get_msg = self.send_request(MGMSG.MOT_REQ_DCPIDPARAMS, - [MGMSG.MOT_GET_DCPIDPARAMS], 1) + get_msg = await self.send_request(MGMSG.MOT_REQ_DCPIDPARAMS, + [MGMSG.MOT_GET_DCPIDPARAMS], 1) return st.unpack("` method. + ` method. If set to 2, each button can be programmed with a differente position value such that the controller will move the motor to that position when the specific button is pressed. @@ -1164,31 +1162,31 @@ class Tdc(_Tcube): """ payload = st.pack("` for + ` for description. :rtype: A 3 int tuple """ - get_msg = self.send_request(MGMSG.MOT_REQ_BUTTONPARAMS, - [MGMSG.MOT_GET_BUTTONPARAMS], 1) + get_msg = await self.send_request(MGMSG.MOT_REQ_BUTTONPARAMS, + [MGMSG.MOT_GET_BUTTONPARAMS], 1) return st.unpack("