ThorLabs¶
PM100USB
USB Power Meter¶
- class instruments.thorlabs.PM100USB(filelike, *args, **kwargs)[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(value)[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.- property flags¶
Gets any sensor flags set on the sensor channel
- Type:
- class SensorFlags(value)[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.- Units:
As specified by
measurement_configuration
.- Return type:
- property averaging_count¶
Integer specifying how many samples to collect and average over for each measurement, with each sample taking approximately 3 ms.
- property 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:
- property measurement_configuration¶
Returns the current measurement configuration.
- Return type:
- property sensor¶
Returns information about the currently connected sensor.
- Type:
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.
- property 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
ofAPTChannel
- property 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:
- 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.
- property 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.
- Returns:
List with the drive parameters, unitful.
- Raises:
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
- property enabled_single¶
Get / Set single axis enabled.
Note
Enabling multi channels for KIM101 is defined in
the controller class.
- Returns:
Axis status enabled.
- Return type:
- Raises:
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
- property 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.
- Returns:
List with the jog parameters.
- Raises:
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]
- property position_count¶
Get/Set the position count of a given channel.
- Setter pos:
Position (steps) of axis.
- Returns:
Position (steps) of axis.
- Return type:
- 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
- property 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)
- Returns:
The selected mode: 0 - multi-channel selection disabled 1 - Channel 0 & 1 enabled 2 - Channel 2 & 3 enabled
- Return type:
- Raises:
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 >>> # read back >>> kim.enabled_multi 1
- class instruments.thorlabs.APTPiezoStage(filelike)[source]¶
Class representing a Thorlabs APT piezo stage
- 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
).- 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:
- Units pos:
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).
- property backlash_correction¶
Get / set backlash correctionf or given stage.
If no units are given,
u.counts
are assumed. If you have the stage defined (see example below), unitful values can be used for setting the backlash correction, e.g.,u.mm
oru.deg
.- Returns:
Unitful quantity of backlash correction.
- 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] >>> ch.motor_model = 'PRM1-Z8' # select rotation stage
>>> ch.backlash_correction = 4 * u.deg # set it to 4 degrees >>> ch.backlash_correction # read it back <Quantity(4, 'degree')>
- property home_parameters¶
Get the home parameters for the motor channel.
Parameters are stage specific and not all parameters can be set for every stage. For example, the MLS203 stage only allows the homing velocity to be changed.
Note
When setting the quantity, pass
None
to values that you want to leave unchanged (see example below).Note
After changing the offset, the stage must be homed in order to show the new offset in its values.
- Returns:
Home Direction (1: forward/positive, 2 reverse/negative), Limit Switch (1: hardware reverse, 4: hardware forward), Home Velocity, Offset distance
- Return type:
- 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] >>> ch.motor_model = 'PRM1-Z8' # select rotation stage
>>> # set offset distance to 4 degrees, leave other values >>> ch.home_parameters = None, None, None, 4 * u.deg >>> ch.home_parameters # read it back (2, 1, <Quantity(9.99, 'degree / second')>, <Quantity(3.99, 'degree')>)
- property 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.
- property position_encoder¶
Gets the position of the encoder of the specified motor channel
- Type:
- Units:
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.
- property status_bits¶
Gets the status bits for the specified motor channel.
Note
This command, as currently implemented, is only available for certain devices and will result in an
OSError
otherwise. Devices that work according to the manual are: TSC001, KSC101, BSC10x, BSC20x, LTS150, LTS300, MLJ050, MLJ150, TIM101, KIM101.- Type:
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(value)[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:
- restore()[source]¶
Loads the settings from memory.
Returns 1 if successful, zero otherwise.
- Return type:
- save()[source]¶
Stores the parameters in static memory
Returns 1 if successful, zero otherwise.
- Return type:
- save_mode()[source]¶
Stores output trigger mode and baud rate settings in memory.
Returns 1 if successful, zero otherwise.
- Return type:
- property baud_rate¶
Gets/sets the instrument baud rate.
Valid baud rates are 9600 and 115200.
- Type:
- property closed¶
Gets the shutter closed status.
True
represents the shutter is closed, andFalse
for the shutter is open.- Return type:
- property 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: Status of the switch. :rtype:bool
- Raises:
TypeError – Unexpected type given when trying to enable.
- property interlock¶
Gets the interlock tripped status.
Returns
True
if the interlock is tripped, andFalse
otherwise.- Return type:
- property name¶
Gets the name and version number of the device.
- Returns:
Name and verison number of the device
- Return type:
- property open_time¶
Gets/sets the amount of time that the shutter is open, in ms
- property out_trigger¶
Gets/sets the out trigger source.
0 trigger out follows shutter output, 1 trigger out follows controller output
- Type:
- property repeat¶
Gets/sets the repeat count for repeat mode. Valid range is [1,99] inclusive.
- Type:
- property shut_time¶
Gets/sets the amount of time that the shutter is closed, in ms
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(value)[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:
- get_settings(slot)[source]¶
Gets the current settings to memory.
Returns 1 if successful, zero otherwise.
- save()[source]¶
Stores the parameters in static memory
Returns 1 if successful, zero otherwise.
- Return type:
- set_settings(slot)[source]¶
Saves the current settings to memory.
Returns 1 if successful, zero otherwise.
- 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:
- property dwell¶
Gets/sets the dwell time for voltages for the test mode.
- property enable¶
Gets/sets the output enable status.
If output enable is on (
True
), there is a voltage on the output.- Return type:
- property extern¶
Gets/sets the use of the external TTL modulation.
Value is
True
for external TTL modulation andFalse
for internal modulation.- Return type:
- property frequency¶
Gets/sets the frequency at which the LCC oscillates between the two voltages.
- property increment¶
Gets/sets the voltage increment for voltages for the test mode.
- property max_voltage¶
Gets/sets the maximum voltage value for the test mode. If the maximum voltage is less than the minimum voltage, nothing happens.
- property min_voltage¶
Gets/sets the minimum voltage value for the test mode.
- property mode¶
Gets/sets the output mode of the LCC25
- Return type:
- property remote¶
Gets/sets front panel lockout status for remote instrument operation.
Value is
False
for normal operation andTrue
to lock out the front panel buttons.- Return type:
- property voltage1¶
Gets/sets the voltage value for output 1.
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 Sensor(value)[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
- Return type:
- property beta¶
Gets/sets the beta value of the thermistor curve.
Value within [2000, 6000]
- Returns:
the gain (in nnn)
- Type:
- property degrees¶
Gets/sets the units of the temperature measurement.
- Returns:
The temperature units (degC/F/K) the TC200 is measuring in
- Type:
- property enable¶
Gets/sets the heater enable status.
If output enable is on (
True
), there is a voltage on the output.- Type:
- property i¶
Gets/sets the i-gain. Valid numbers are [1,250]
- Returns:
the i-gain (in nnn)
- Return type:
- property max_power¶
Gets/sets the maximum power
- Returns:
The maximum power
- Units:
Watts (linear units)
- Type:
- property max_temperature¶
Gets/sets the maximum temperature
- Returns:
the maximum temperature (in deg C)
- Units:
As specified or assumed to be degree Celsius. Returns with units degC.
- Return type:
- property mode¶
Gets/sets the output mode of the TC200
- Type:
- property p¶
Gets/sets the p-gain. Valid numbers are [1,250].
- Returns:
the p-gain (in nnn)
- Return type:
- property pid¶
Gets/sets all three PID values at the same time. See
TC200.p
,TC200.i
, andTC200.d
for individual restrictions.If
None
is specified then the corresponding PID value is not changed.
- property sensor¶
Gets/sets the current thermistor type. Used for converting resistances to temperatures.
- Returns:
The thermistor type
- Type:
- property temperature¶
Gets the actual temperature of the sensor