Thorlabs thorlabs_motor Instrument

Connects to the tdc001_cube controller, which is just a wrapper for the core underneath that we installed. You can find the core here https://github.com/qpit/thorlabs_apt/tree/master/thorlabs_apt, or need to copy it into C:/Users/NAME/AppData/Local/Continuum/anaconda3/envs/hyperion/Lib/site-packages/thorlabs_apt.

I implemented and documented those functions that I am actually going to use. If you want to use others, they might exist in the core.

class hyperion.instrument.position.thorlabs_motor_instr.Thorlabsmotor(settings)

Thorlabsmotor instrument

check_move(value)
First checks whether there is no limit reached.
Then checks whether the units actually agree with the kind of device, so degrees for a waveplate or a length for a stage motor.
Returns whether you can move, otherwise prints warnings.
Returns the units of the value, since the controller thinks in degrees and mm.
Parameters:value (pint quantity) – distance or new position that you would want to move
Returns:you_can_move, value
Return type:Bool, float
finalize()

This would have been to close connection to the device, but that method does not exist in the core controller.

get_axis_info()
Important returns axis information of stage.
If units = 1, the units are in mm and the device is a stage motor.
If units = 2, the units are in degrees and the device is a motorized waveplate.
Store this in self.kind_of_device, so the rest of this class knows.
Returns:(minimum position, maximum position, stage units, pitch)
Return type:tuple
initialize()
  • Initializes the cube:
  • checks whether the serial number is recognized by the cube
  • runs list_device to check whether this serial number actually exists in all connected T-cubes
  • asks the harware info just in case
  • blinks the light to identify the T-cube
  • runs set_axis_info, which will set the minimum position to -12 and
  • run get_axis_info, which will figure out whether you are connected to a waveplate or stage motor always run this one!!
is_in_motion()

Returns whether thorlabs motor is in motion, and prints a warning if so.

Returns:in motion
Return type:bool
list_devices()
Lists all available devices.
It actually maybe should live outside of this class, since it talks to all Thorlabs motors attached, not a single one.
However, I could not make that work, so now I kept it here.
It also runs through the list now and checks whether the serial of the T-cube that you want to talk to, exists in the list.
make_step(stepsize, blocking)
Moves the T-cube by one step of a stepsize.
Actually just uses move_relative, but I thought maybe this method might be useful for a gui.
If blocking is True, it will move until its done.
If blocking is False, it might not reach its destination if you dont give it time.
Parameters:
  • stepsize (pint quantity) – stepsize in mm or degree
  • blocking (bool) – wait until moving is finished; default False
motion_error()

Returns whether there is a motion error (= excessing position error), and prints a warning if so.

Returns:motion error
Return type:bool
motor_current_limit_reached()

Return whether current limit of thorlabs_motor has been reached, and prints a warning if so.

Returns:current limit reached
Return type:bool
move_absolute(new_position, blocking)
Moves the T-cube to a new position, but first checks the units by calling check_move.
The method check_move will give back the correct units.
If blocking is True, it will move until its done.
If blocking is False, it might not reach its destination if you dont give it time.
Parameters:
  • new_position (pint quantity) – the new position
  • blocking (bool) –
move_home(blocking)
Moves to home position.
You can use the blocking method of the core, but than higher layers will not be able to stop the move or know the position.
So I implemented my own blocking that uses the is_in_motion method.
If blocking is True, it will move until its done.
If blocking is False, it might not reach its destination if you dont give it time.
Parameters:blocking (bool) – wait until homed
move_relative(distance, blocking)
Moves the T-cube with a distance relative to the current one, but first checks the units by calling check_move.
The method check_move will give back the correct units.
If blocking is True, it will move until its done.
If blocking is False, it might not reach its destination if you dont give it time.
Parameters:
  • value (pint quantity) – relative distance in mm or degree
  • blocking (bool) – wait until moving is finished; default False
move_velocity(direction, blocking)
Moves the T-cube with a certain velocity until it gets stoped.
The method check_move will give back the correct units.
If blocking is True, it will move until its done.
If blocking is False, it might not reach its destination if you dont give it time.
Parameters:
  • blocking (bool) – wait until moving is finished; default False
  • direction (1 for forward 2 for backward) – direction of movement
moving_loop()
This method is used by the move_home, move_relative and move_absolute methods.
It stays in the while loop until the position is reached or self.stop is set to True,
meanwhile updating the current_position as known in this instrument level.
This means it can be used in higher levels to display the position on the gui and thread the stop function.
If the sleeps are making your program too slow, they could be changed.
Pay attention not to make the first sleep too short, otherwise it already starts asking before the guy even knows whether he moves.
position()
Asks the position to the controller and returns that.
Units depend on the kind of device; either mm or degrees.
Remembers the current_position as declared in the init.
Returns:position in mm or degrees
Return type:pint quantity
set_axis_info()
Executes get_axis_info to set the kind of device, and changes the minimum position to -12.0.
This is important because the stage axis puts itself at 0 if you shut down the cubes,
so it happens that afterwards you want to go to a negative position.
To prevent errors, this method changes the minimum position from 0 to -12.0.
stop_moving()
Stop motor but turn down velocity slowly (profiled).