# ThorLabs¶

## PM100USB USB Power Meter¶

class instruments.thorlabs.PM100USB(filelike)[source]

Instrument class for the ThorLabs PM100USB power meter. Note that as this is an SCPI-compliant instrument, the properties and methods of SCPIInstrument may be used as well.

class MeasurementConfiguration[source]

Enum containing valid measurement modes for the PM100USB

current = 'CURR'
energy = 'ENER'
energy_density = 'EDEN'
frequency = 'FREQ'
power = 'POW'
power_density = 'PDEN'
resistance = 'RES'
temperature = 'TEMP'
voltage = 'VOLT'
class Sensor(parent)[source]

Class representing a sensor on the ThorLabs PM100USB

Warning

This class should NOT be manually created by the user. It is designed to be initialized by the PM100USB class.

calibration_message

Gets the calibration message of the sensor channel

Type: str
flags

Gets any sensor flags set on the sensor channel

name

Gets the name associated with the sensor channel

Type: str
serial_number

Gets the serial number of the sensor channel

Type: str
type

Gets the sensor type of the sensor channel

Type: str
class SensorFlags[source]

Enum containing valid sensor flags for the PM100USB

has_temperature_sensor = 256
is_energy_sensor = 2
is_power_sensor = 1
response_settable = 16
tau_settable = 64
wavelength_settable = 32
read(size=-1, encoding='utf-8')[source]

Reads a measurement from this instrument, according to its current configuration mode.

Parameters: size (int) – Number of bytes to read from the instrument. Default of -1 reads until a termination character is found. As specified by measurement_configuration. Quantity
averaging_count

Integer specifying how many samples to collect and average over for each measurement, with each sample taking approximately 3 ms.

cache_units

If enabled, then units are not checked every time a measurement is made, reducing by half the number of round-trips to the device.

Warning

Setting this to True may cause incorrect values to be returned, if any commands are sent to the device either by its local panel, or by software other than InstrumentKit.

Type: bool
measurement_configuration

Returns the current measurement configuration.

Return type: PM100USB.MeasurementConfiguration
sensor

Returns information about the currently connected sensor.

## ThorLabsAPT ThorLabs APT Controller¶

class instruments.thorlabs.ThorLabsAPT(filelike)[source]

Generic ThorLabs APT hardware device controller. Communicates using the ThorLabs APT communications protocol, whose documentation is found in the thorlabs source folder.

class APTChannel(apt, idx_chan)[source]

Represents a channel within the hardware device. One device can have many channels, each labeled by an index.

enabled

Gets/sets the enabled status for the specified APT channel

Type: bool TypeError – If controller is not supported
identify()[source]

Causes a light on the APT instrument to blink, so that it can be identified.

channel

Gets the list of channel objects attached to the APT controller.

A specific channel object can then be accessed like one would access a list.

Type: tuple of APTChannel
destination

Gets the destination for the APT controller

Type: int
model_number

Gets the model number for the APT controller

Type: str
n_channels

Gets/sets the number of channels attached to the APT controller

Type: int
name

Gets the name of the APT controller. This is a human readable string containing the model, serial number, hardware version, and firmware version.

Type: str
serial_number

Gets the serial number for the APT controller

Type: str
class instruments.thorlabs.APTPiezoInertiaActuator(filelike)[source]

Represent a Thorlabs APT piezo inertia actuator.

Currently only the KIM piezo inertia actuator is implemented. Some routines will work with the TIM actuator as well. Routines that are specific for the KIM101 controller will raise a TypeError if not implemented for this controller. Unfortunately, handling all these controller specific functions is fairly messy, but necessary.

Example for a KIM101 controller:
>>> import instruments as ik
>>> import instruments.units as u
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # set first channel to enabled
>>> ch = kim.channel[0]
>>> ch.enabled_single = True
>>> # define and set drive parameters
>>> max_volts = u.Quantity(110, u.V)
>>> step_rate = u.Quantity(1000, 1/u.s)
>>> acceleration = u.Quantity(10000, 1/u.s**2)
>>> ch.drive_op_parameters = [max_volts, step_rate, acceleration]
>>> # aboslute move to 1000 steps
>>> ch.move_abs(1000)

class PiezoChannel(apt, idx_chan)[source]

Class representing a single piezo channel within a piezo stage on the Thorlabs APT controller.

move_abs(pos)[source]

Moves the axis to a position specified as the number of steps away from the zero position.

To set the moving parameters, use the setter for drive_op_parameters.

Parameters: pos (int) – Position to move to, in steps.
Example:
>>> import instruments as ik
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # move to 314 steps
>>> ch.move_abs(314)

move_jog(direction='fwd')[source]

Jogs the axis in forward or backward direction by the number of steps that are stored in the controller.

To set the moving parameters, use the setter for jog_parameters.

Parameters: direction (str) – Direction of jog. ‘fwd’ for forward, ‘rev’ for backward. ‘fwd’ if invalid argument given
Example:
>>> import instruments as ik
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # set jog parameters
>>> params = ch.jog_parameters
>>> params[0] = 2  # move by number of steps
>>> params[1] = 100  # step size forward
>>> params[2] = 200  # step size reverse
>>> ch.jog_parameters = params  # set parameters
>>> # jog forward (default)
>>> ch.move_jog()
>>> # jog reverse
>>> ch.move_jog('rev')

move_jog_stop()[source]

Stops the current motor movement.

Stop a jog command. The regular motor move stop command does not work for jogging. This command somehow does…

Note

This information is quite empirical. It would only be really needed if jogging parameters are set to continuous. The safer method is to set the step range.

drive_op_parameters

Get / Set various drive parameters for move motion.

Defines the speed and acceleration of moves initiated in the following ways: - by clicking in the position display - via the top panel controls when ‘Go To Position’ mode is selected (in the Set_TIM_JogParameters (09) or Set_KCubeMMIParams (15) sub‐messages). - via software using the MoveVelocity, MoveAbsoluteStepsEx or MoveRelativeStepsEx methods.

Setter: The setter must be be given as a list of 3 entries. The three entries are: - Maximum Voltage: The maximum piezo drive voltage, in the range 85V to 125V. Unitful, if no unit given, V are assumed. - Step Rate: The piezo motor moves by ramping up the drive voltage to the value set in the MaxVoltage parameter and then dropping quickly to zero, then repeating. One cycle is termed a step. This parameter specifies the velocity to move when a command is initiated. The step rate is specified in steps/sec, in the range 1 to 2,000. Unitful, if no unit given, 1 / sec assumed. - Step Acceleration: This parameter specifies the acceleration up to the step rate, in the range 1 to 100,000 cycles/sec/sec. Unitful, if no unit given, 1/sec**2 assumed. List with the drive parameters, unitful. TypeError – The setter was not a list or tuple. ValueError – The setter was not given a tuple with three values. ValueError – One of the parameters was out of range.
Example:
>>> import instruments as ik
>>> import instruments.units as u
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # change the step rate to 2000 /s
>>> drive_params = ch.drive_op_parameters
>>> drive_params[1] = 2000
>>> ch.drive_op_parameters = drive_params

enabled_single

Get / Set single axis enabled.

Note

Enabling multi channels for KIM101 is defined in

the controller class.

Returns: Axis status enabled. bool TypeError – Invalid controller for this command.
Example for a KIM101 controller:
>>> import instruments as ik
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # enable channel 0
>>> ch.enabled_single = True

jog_parameters

Get / Set the jog parameters.

Define the speed and acceleration of moves initiated in the following ways: - By clicking the jog buttons on the GUI panel - By moving the joystick on the unit when ‘Jog Mode’ is selected. - via software using the MoveJog method.

It differs from the normal motor jog message in that there are two jog step sizes, one for forward and one for reverse. The reason for this is that due to the inherent nature of the PIA actuators going further in one direction as compared with another this will allow the user to potentially make adjustments to get fore and aft movement the same or similar.

Setter: The setter must be be given as a list of 5 entries. The three entries are: - Jog Mode (1 for continuus, i.e., until stop command is issued, or 2 jog by the number of steps defined) - Jog Step Size Forward: Range 1 - 2000 - Jog Step Size Backward: Range 1 - 2000 The piezo motor moves by ramping up the drive voltage to the value set in the MaxVoltage parameter and then dropping quickly to zero, then repeating. One cycle is termed a step. This parameter specifies the velocity to move when a command is initiated. The step rate is specified in steps/sec, in the range 1 to 2,000. Unitful, if no unit given, 1 / sec assumed. - Jog Step Acceleration: This parameter specifies the acceleration up to the step rate, in the range 1 to 100,000 cycles/sec/sec. Unitful, if no unit given, 1/sec**2 assumed. List with the jog parameters. TypeError – The setter was not a list or tuple. ValueError – The setter was not given a tuple with three values. ValueError – One of the parameters was out of range. TypeError – Invalid controller for this command.
Example for a KIM101 controller:
>>> import instruments as ik
>>> import instruments.units as u
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # set jog parameters
>>> mode = 2  # only move by set step size
>>> step = 100  # step size
>>> rate = u.Quantity(1000, 1/u.s)  # step rate
>>> # if no quantity given, SI units assumed
>>> accl = 10000
>>> ch.jog_parameters = [mode, step, step, rate, accl]
>>> ch.jog_parameters
[2, 100, 100, array(1000) * 1/s, array(10000) * 1/s**2]

position_count

Get/Set the position count of a given channel.

Setter pos: Position (steps) of axis. Position (steps) of axis. int
Example:
>>> import instruments as ik
>>> # call the controller
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # grab channel 0
>>> ch = kim.channel[0]
>>> # set position count to zero
>>> ch.position_count = 0
>>> ch.position_count
0

enabled_multi

Enable / Query mulitple channel mode.

For KIM101 controller, where multiple axes can be selected simultaneously (i. e., for a mirror mount).

Setter mode: Channel pair to be activated. 0: All channels deactivated 1: First channel pair activated (channel 0 & 1) 2: Second channel pair activated (channel 2 & 3) The selected mode: 0 - multi-channel selection disabled 1 - Channel 0 & 1 enabled 2 - Channel 2 & 3 enabled int ValueError – No valid channel pair selected TypeError – Invalid controller for this command.
Example:
>>> import instruments as ik
>>> kim = ik.thorlabs.APTPiezoInertiaActuator.open_serial("/dev/ttyUSB0", baud=115200)
>>> # activate the first two channels
>>> kim.enabled_multi = 1
>>> kim.enabled_multi
1

class instruments.thorlabs.APTPiezoStage(filelike)[source]

Class representing a Thorlabs APT piezo stage

class PiezoChannel(apt, idx_chan)[source]

Class representing a single piezo channel within a piezo stage on the Thorlabs APT controller.

change_position_control_mode(closed, smooth=True)[source]

Changes the position control mode of the piezo channel

Parameters: closed (bool) – True for closed, False for open smooth (bool) – True for smooth, False for otherwise. Default is True.
output_position

Gets/sets the output position for the piezo channel.

Type: str
position_control_closed

Gets the status if the position control is closed or not.

True means that the position control is closed, False otherwise

Type: bool
class instruments.thorlabs.APTStrainGaugeReader(filelike)[source]

Class representing a Thorlabs APT strain gauge reader.

Warning

This is not currently implemented

class StrainGaugeChannel(apt, idx_chan)[source]

Class representing a single strain gauge channel attached to a APTStrainGaugeReader on the Thorlabs APT controller.

Warning

This is not currently implemented

class instruments.thorlabs.APTMotorController(filelike)[source]

Class representing a Thorlabs APT motor controller.

Note

A motor model must be selected in order to use unitful distances.

Example:
>>> import instruments as ik
>>> import instruments.units as u

>>> # load the controller, a KDC101 cube
>>> kdc = ik.thorlabs.APTMotorController.open_serial("/dev/ttyUSB0", baud=115200)
>>> # assign a channel to ch
>>> ch = kdc.channel[0]
>>> # select the stage that is connected to the controller
>>> ch.motor_model = 'PRM1-Z8'  # a rotation stage

>>> # home the stage
>>> ch.go_home()
>>> # move to 52 degrees absolute position
>>> ch.move(u.Quantity(52, u.deg))
>>> # move 10 degrees back from current position
>>> ch.move(u.Quantity(-10, u.deg), absolute=False)

class MotorChannel(apt, idx_chan)[source]

Class representing a single motor attached to a Thorlabs APT motor controller (APTMotorController).

go_home()[source]

move(pos, absolute=True)[source]

Instructs the specified motor channel to move to a specific location. The provided position can be either an absolute or relative position.

Parameters: pos (Quantity) – The position to move to. Provided value will be converted to encoder counts. absolute (bool) – Specify if the position is a relative or absolute position. True means absolute, while False is for a relative move. As specified, or assumed to of units encoder counts
Example:
>>> import instruments as ik
>>> import instruments.units as u

>>> # load the controller, a KDC101 cube
>>> kdc = ik.thorlabs.APTMotorController.open_serial("/dev/ttyUSB0", baud=115200)
>>> # assign a channel to ch
>>> ch = kdc.channel[0]
>>> # select the stage that is connected to the controller
>>> ch.motor_model = 'PRM1-Z8'  # a rotation stage

>>> # move to 32 degrees absolute position
>>> ch.move(u.Quantity(32, u.deg))

>>> # move 10 degrees forward from current position
>>> ch.move(u.Quantity(10, u.deg), absolute=False)

set_scale(motor_model)[source]

Sets the scale factors for this motor channel, based on the model of the attached motor and the specifications of the driver of which this is a channel.

Parameters: motor_model (str) – Name of the model of the attached motor, as indicated in the APT protocol documentation (page 14, v9).
motion_timeout

Gets/sets the motor channel motion timeout.

Units: Seconds Quantity
motor_model

Gets or sets the model name of the attached motor. Note that the scale factors for this motor channel are based on the model of the attached motor and the specifications of the driver of which this is a channel, such that setting a new motor model will update the scale factors accordingly.

Type: str or None
position

Gets the current position of the specified motor channel

Type: Quantity
position_encoder

Gets the position of the encoder of the specified motor channel

Type: Quantity Encoder counts
scale_factors = (<Quantity(1, 'dimensionless')>, <Quantity(1, 'dimensionless')>, <Quantity(1, 'dimensionless')>)

Sets the scale between the encoder counts and physical units for the position, velocity and acceleration parameters of this channel. By default, set to dimensionless, indicating that the proper scale is not known.

In keeping with the APT protocol documentation, the scale factor is multiplied by the physical quantity to get the encoder count, such that scale factors should have units similar to microsteps/mm, in the example of a linear motor.

Encoder counts are represented by the quantities package unit “ct”, which is considered dimensionally equivalent to dimensionless. Finally, note that the “/s” and “/s**2” are not included in scale factors, so as to produce quantities of dimension “ct/s” and “ct/s**2” from dimensionful input.

For more details, see the APT protocol documentation.

status_bits

Gets the status bits for the specified motor channel.

Type: dict

## SC10 Optical Beam Shutter Controller¶

class instruments.thorlabs.SC10(filelike)[source]

The SC10 is a shutter controller, to be used with the Thorlabs SH05 and SH1. The user manual can be found here: http://www.thorlabs.com/thorcat/8600/SC10-Manual.pdf

class Mode[source]

Enum containing valid output modes of the SC10

auto = 2
external = 5
manual = 1
repeat = 4
single = 3
default()[source]

Restores instrument to factory settings.

Returns 1 if successful, zero otherwise.

Return type: int
restore()[source]

Returns 1 if successful, zero otherwise.

Return type: int
save()[source]

Stores the parameters in static memory

Returns 1 if successful, zero otherwise.

Return type: int
save_mode()[source]

Stores output trigger mode and baud rate settings in memory.

Returns 1 if successful, zero otherwise.

Return type: int
baud_rate

Gets/sets the instrument baud rate.

Valid baud rates are 9600 and 115200.

Type: int
closed

Gets the shutter closed status.

True represents the shutter is closed, and False for the shutter is open.

Return type: bool
enable

Gets/sets the shutter enable status, False for disabled, True if enabled

If output enable is on (True), there is a voltage on the output.

Return type: bool
interlock

Gets the interlock tripped status.

Returns True if the interlock is tripped, and False otherwise.

Return type: bool
mode

Gets/sets the output mode of the SC10

Return type: SC10.Mode
name

Gets the name and version number of the device.

Returns: Name and verison number of the device str
open_time

Gets/sets the amount of time that the shutter is open, in ms

Units: As specified (if a Quantity) or assumed to be of units milliseconds. Quantity
out_trigger

Gets/sets the out trigger source.

0 trigger out follows shutter output, 1 trigger out follows controller output

Type: int
repeat

Gets/sets the repeat count for repeat mode. Valid range is [1,99] inclusive.

Type: int
shut_time

Gets/sets the amount of time that the shutter is closed, in ms

Units: As specified (if a Quantity) or assumed to be of units milliseconds. Quantity
trigger

Gets/sets the trigger source.

0 for internal trigger, 1 for external trigger

Type: int

## LCC25 Liquid Crystal Controller¶

class instruments.thorlabs.LCC25(filelike)[source]

The LCC25 is a controller for the thorlabs liquid crystal modules. it can set two voltages and then oscillate between them at a specific repetition rate.

The user manual can be found here: http://www.thorlabs.com/thorcat/18800/LCC25-Manual.pdf

class Mode[source]

Enum containing valid output modes of the LCC25

normal = 0
voltage1 = 1
voltage2 = 2
default()[source]

Restores instrument to factory settings.

Returns 1 if successful, 0 otherwise

Return type: int
get_settings(slot)[source]

Gets the current settings to memory.

Returns 1 if successful, zero otherwise.

Parameters: slot (int) – Memory slot to use, valid range [1,4] int
save()[source]

Stores the parameters in static memory

Returns 1 if successful, zero otherwise.

Return type: int
set_settings(slot)[source]

Saves the current settings to memory.

Returns 1 if successful, zero otherwise.

Parameters: slot (int) – Memory slot to use, valid range [1,4] int
test_mode()[source]

Puts the LCC in test mode - meaning it will increment the output voltage from the minimum value to the maximum value, in increments, waiting for the dwell time

Returns 1 if successful, zero otherwise.

Return type: int
dwell

Gets/sets the dwell time for voltages for the test mode.

Units: As specified (if a Quantity) or assumed to be of units milliseconds. Quantity
enable

Gets/sets the output enable status.

If output enable is on (True), there is a voltage on the output.

Return type: bool
extern

Gets/sets the use of the external TTL modulation.

Value is True for external TTL modulation and False for internal modulation.

Return type: bool
frequency

Gets/sets the frequency at which the LCC oscillates between the two voltages.

Units: As specified (if a Quantity) or assumed to be of units Hertz. Quantity
increment

Gets/sets the voltage increment for voltages for the test mode.

Units: As specified (if a Quantity) or assumed to be of units Volts. Quantity
max_voltage

Gets/sets the maximum voltage value for the test mode. If the maximum voltage is less than the minimum voltage, nothing happens.

Units: As specified (if a Quantity) or assumed to be of units Volts. Quantity
min_voltage

Gets/sets the minimum voltage value for the test mode.

Units: As specified (if a Quantity) or assumed to be of units Volts. Quantity
mode

Gets/sets the output mode of the LCC25

Return type: LCC25.Mode
name

Gets the name and version number of the device

Return type: str
remote

Gets/sets front panel lockout status for remote instrument operation.

Value is False for normal operation and True to lock out the front panel buttons.

Return type: bool
voltage1

Gets/sets the voltage value for output 1.

Units: As specified (if a Quantity) or assumed to be of units Volts. Quantity
voltage2

Gets/sets the voltage value for output 2.

Units: As specified (if a Quantity) or assumed to be of units Volts. Quantity

## TC200 Temperature Controller¶

class instruments.thorlabs.TC200(filelike)[source]

The TC200 is is a controller for the voltage across a heating element. It can also read in the temperature off of a thermistor and implements a PID control to keep the temperature at a set value.

The user manual can be found here: http://www.thorlabs.com/thorcat/12500/TC200-Manual.pdf

class Mode[source]

Enum containing valid output modes of the TC200.

cycle = 1
normal = 0
class Sensor[source]

Enum containing valid temperature sensor types for the TC200.

ntc10k = 'ntc10k'
ptc100 = 'ptc100'
ptc1000 = 'ptc1000'
th10k = 'th10k'
name()[source]

Gets the name and version number of the device

Returns: the name string of the device str
beta

Gets/sets the beta value of the thermistor curve.

Value within [2000, 6000]

Returns: the gain (in nnn) int
d

Gets/sets the d-gain. Valid numbers are [0, 250]

Returns: the d-gain (in nnn) int
degrees

Gets/sets the units of the temperature measurement.

Returns: The temperature units (degC/F/K) the TC200 is measuring in Unit
enable

Gets/sets the heater enable status.

If output enable is on (True), there is a voltage on the output.

Type: bool
i

Gets/sets the i-gain. Valid numbers are [1,250]

Returns: the i-gain (in nnn) int
max_power

Gets/sets the maximum power

Returns: The maximum power Watts (linear units) Quantity
max_temperature

Gets/sets the maximum temperature

Returns: the maximum temperature (in deg C) As specified or assumed to be degree Celsius. Returns with units degC. Quantity
mode

Gets/sets the output mode of the TC200

Type: TC200.Mode
p

Gets/sets the p-gain. Valid numbers are [1,250].

Returns: the p-gain (in nnn) int
pid

Gets/sets all three PID values at the same time. See TC200.p, TC200.i, and TC200.d for individual restrictions.

If None is specified then the corresponding PID value is not changed.

Returns: List of integers of PID values. In order [P, I, D]. list or tuple list
sensor

Gets/sets the current thermistor type. Used for converting resistances to temperatures.

Returns: The thermistor type TC200.Sensor
status

Gets the the status code of the TC200

Return type: int
temperature

Gets the actual temperature of the sensor

Units: As specified (if a Quantity) or assumed to be of units degrees C. Quantity or int the temperature (in degrees C) Quantity
temperature_set

Gets/sets the actual temperature of the sensor

Units: As specified (if a Quantity) or assumed to be of units degrees C. Quantity or int the temperature (in degrees C) Quantity