thorlabs_apt_device.devices.bsc module¶
- class thorlabs_apt_device.devices.bsc.BSC(serial_port=None, vid=None, pid=None, manufacturer=None, product=None, serial_number=None, location=None, home=True, x=1, invert_direction_logic=False, swap_limit_switches=True)[source]¶
Bases:
APTDevice_BayUnit
A class for the BSC10x and BSC20x series of Thorlabs APT controllers.
It is based off
APTDevice_BayUnit
with the addition of the control loop parameters used for encoded stages.Note that it seems (at least some of) the BSC series will send automatic status updates, but they do not support the corresponding acknowledgement message, and so will stop responding after ~5 seconds due to the lack of acknowledgement from the host. As a workaround, the status of the device will be polled.
Additionally, it seems that the initial movement and homing velocities can be effectively zero, making it seem like the device is not working, though it is actually just moving extremely slowly. It’s a good idea to ensure sensible values are set for
set_velocity_params()
,set_jog_params()
andset_home_params()
during initialisation. What values qualify as “sensible” will depend on the particular stepper and stage being controlled. For example, the DRV250 actuator has 409600 microsteps/mm, 21987328 microsteps/mm/s, and 4506 microsteps/mm/s/s. Thus, usingacceleration=4506
andmax_velocity=21987328
inset_velocity_params()
would result in a movement speed of 1 mm/s and an acceleration of 1 mm/s/s. Consult the APT Communications Protocol PDF document on the Thorlabs website for parameters for a specific stage.- Parameters:
serial_port – Serial port device the device is connected to.
vid – Numerical USB vendor ID to match.
pid – Numerical USB product ID to match.
manufacturer – Regular expression to match to a device manufacturer string.
product – Regular expression to match to a device product string.
serial_number – Regular expression matching the serial number of device to search for.
location – Regular expression to match to a device bus location.
x – Number of channels the device controls (the x in BSC20x).
home – Perform a homing operation on initialisation.
invert_direction_logic – Invert the meaning of “forward” and “reverse” directions.
swap_limit_switches – Swap “forward” and “reverse” limit switch values.
- set_loop_params(loop_mode=None, prop=None, integral=None, diff=None, pid_clip=None, pid_tol=None, encoder_const=None, bay=0, channel=0)[source]¶
Configure the closed-loop positioning parameters used by encoded stages.
The closed-loop control algorithm is a PID style. Note that the keyword parameter to modify the “int” value is named “integral” so as not to confuse it with the python int keyword.
- Parameters:
loop_mode – Set to 1 if open-loop, 2 for closed-loop mode.
prop – Coefficient of the proportional gain term.
integral – Coefficient of the integral gain term.
diff – Coefficient of the differential gain term.
pid_clip – Maximum value of the PID algorithm output.
pid_tol – Minimum allowed (non-zero) value of the PID algorithm output.
- Encoder_const:
Coefficient to map encoder counts to motor steps.
- set_power_params(rest_factor=None, move_factor=None, bay=0, channel=0)[source]¶
Configure the motor power parameters used during movement and rest.
Values are expressed as a percentage between
0
and100
. Typically move power should be set to100
, and the rest power reduced to prevent excessive heating of the motor.- Parameters:
rest_factor – Percentage power used when at rest.
move_factor – Percentage power used when moving.
- loopparams¶
Alias to first bay/channel of
loopparams_
.
- loopparams_¶
Parameters for the closed-loop position control for encoded stages.
Fields are
"loop_mode"
,"prop"
,"int"
,"diff"
,"pid_clip"
,"pid_tol"
, and"encoder_const"
.
- powerparams¶
Alias to first bay/channel of
powerparams
.
- powerparams_¶
Parameters for the motor power parameters.
Fields are
"rest_factor"
and"move_factor"
.
- class thorlabs_apt_device.devices.bsc.BSC201(serial_port=None, vid=None, pid=None, manufacturer=None, product=None, serial_number='40', location=None, home=True, invert_direction_logic=False, swap_limit_switches=True)[source]¶
Bases:
BSC
A class for ThorLabs APT device model BSC201.
It is based off
BSC
, but looking for a serial number starting with"40"
and settingx = 1
.- Parameters:
serial_port – Serial port device the device is connected to.
vid – Numerical USB vendor ID to match.
pid – Numerical USB product ID to match.
manufacturer – Regular expression to match to a device manufacturer string.
product – Regular expression to match to a device product string.
serial_number – Regular expression to match to a device serial number.
home – Perform a homing operation on initialisation.
invert_direction_logic – Invert the meaning of “forward” and “reverse” directions.
swap_limit_switches – Swap “forward” and “reverse” limit switch values.
- class thorlabs_apt_device.devices.bsc.BSC201_DRV250(serial_port=None, vid=None, pid=None, manufacturer=None, product=None, serial_number='40', location=None, home=True, invert_direction_logic=False, swap_limit_switches=True, closed_loop=False)[source]¶
Bases:
BSC201
A class for ThorLabs APT device model BSC201 with DRV250 stepper-motor-driven actuator, sold as a package as the LNR502 and LNR502E.
It is based off
BSC201
, but with sensible default movement parameters configured for the actuator.For the DRV250, there are 409600 microsteps/mm, 21987328 microsteps/mm/s, and 4506 microsteps/mm/s/s.
For the models with the optical encoder (LNR502E, LNR502E/M), use the parameter
closed_loop=True
to enable closed-loop positioning. This will configure the controller parameters to use feedback from the encoder during positioning. For non-encoded stages, or to use open-loop control, this should be set toclosed_loop=False
.- Parameters:
closed_loop – Boolean to indicate the use of an encoded stage (the “E” in LNR502E) in closed-loop mode, default is False.
serial_port – Serial port device the device is connected to.
vid – Numerical USB vendor ID to match.
pid – Numerical USB product ID to match.
manufacturer – Regular expression to match to a device manufacturer string.
product – Regular expression to match to a device product string.
serial_number – Regular expression to match to a device serial number.
home – Perform a homing operation on initialisation.
invert_direction_logic – Invert the meaning of “forward” and “reverse” directions.
swap_limit_switches – Swap “forward” and “reverse” limit switch values.