1.2.3. Motion control: wanglib.instruments.stages

Interfaces to motion controllers.

Newport motion cotroller command syntax has significant overlap between models, so I’ve written several classes to keep things as modular as possible.

To control a stage attached to a Newport ESP300 controller, which is on address 9 of a GPIB network run by a prologix controller ‘plx’, you might do this:

>>> from wanglib.instruments.stages import ESP300_stage
>>> esp = plx.instrument(9)
>>> example_stage = ESP300_stage(1, esp)

Here the ‘esp’ object is the prologix GPIB connection, but pyVISA instruments should also work.

To control another axis of the stage, just make another ESP300_stage instance using the same instrument object.

>>> other_stage = ESP300_stage(2, esp)

This creates another stage on axis 2.

This class also defines handy classes specific to actual stages that are on the table, and you probably want those. For example:

>>> from wanglib.instruments.stages import long_stage
>>> from wanglib.instruments.stages import short_stage

Will get two delay stages, with extra properties representing the delay in picoseconds, etc.

class wanglib.instruments.stages.ESP300_stage(axisnum, bus=None)

A single stage controlled by the ESP300.

The ESP300 is typically on GPIB address 9.

To use over RS232, use the following parameters:
baudrate:19200
rtscts:True
term_chars:‘\r\n’

These settings are used by default if you simply pass the name of the serial port as a string:

>>> my_stage = ESP300_stage(1, '/dev/ttyUSB')

This will make an object corresponding to axis 1 of the stage.

For full control over the RS232 communication, provide a Serial instance instead of an address. For example:

>>> from wanglib.util import Serial
>>> esp = Serial('/dev/ttyUSB', baudrate=19200, timeout=10, 
...             rtscts=1, log='esp300.log', term_chars="\r\n")
>>> my_stage = ESP300_stage(1, esp)

This will work the same as above, but also log command traffic to the file esp300.log.

busy

ask whether motion is in progress

cmd(string)

Prepend the axis number to a command.

define_home(loc=None)

Define the origin of this stage to be its current position.

To define the current position to be some number other than zero, provide that number in the loc kwarg.

encoder_resolution

Get the distance represented by one encoder pulse.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_max_velocity()

Get the maximum motor velocity.

get_pos()

Query the absolute position of the stage

get_velocity()

Get the current motor velocity.

move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on

Turn motor on/off.

pos

Query the absolute position of the stage

set_max_velocity(val)

Set the max motor velocity.

set_pos(val)

Set the absolute position of the stage

set_unit(key)

Set the unit label for a given axis, by index.

Unit labels (‘mm’, ‘um’, etc) have corresponding integer indices. Look these up in the _unit_labels dictionary.

set_velocity(val)

Set the motor velocity.

step_size

Get the distance represented by one motor step.

unit

Get the unit label for a given axis.

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.MM3000_stage(axisnum, bus=None)

A single stage controlled by the Newport MM3000 motion controller.

Firmware version: 2.2

The MM3000 is typically on GPIB address 8.

busy
cmd(string)

Prepend the axis number to a command.

define_home()

Define the origin of this stage to be its current position.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_pos()

Query the absolute position of the stage

motor_status(bit=None)

Request the MM3000 motor status byte.

Optionally, pick out a specific bit.
bit 0: True if axis is moving bit 1: True if motor is off bit 2: True if direction of move is positive bit 3: True if positive travel limit is active bit 4: True if negative travel limit is active bit 5: True if positive side of home bit 6: always True bit 7: always False
move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on
pos

Query the absolute position of the stage

set_pos(val)

Set the absolute position of the stage

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.delay_stage(axisnum, bus=None)

Mixin class for stages used primarily to delay pulses.

Defines one extra feature: the ‘t’ attribute, which is basically the position of the stage in picosecond units.

When mixing in, you need to define two extra attributes:
stage_length:length of the stage, in its natural length units.
c:speed of light, in natural length units per picosecond.

Important: make sure to call ‘find_zero’ on the stage before using t to control motion. Otherwise you might run out of range.

cmd(string)

Prepend the axis number to a command.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_pos()

Query the absolute position of the stage

get_t()

Convert stage position in mm to delay in ps

move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

pos

Query the absolute position of the stage

set_pos(val)

Set the absolute position of the stage

set_t(new_val)
t

Convert stage position in mm to delay in ps

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.long_stage(axisnum, bus=None)
busy

ask whether motion is in progress

c = 0.3
cmd(string)

Prepend the axis number to a command.

define_home(loc=None)

Define the origin of this stage to be its current position.

To define the current position to be some number other than zero, provide that number in the loc kwarg.

encoder_resolution

Get the distance represented by one encoder pulse.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_max_velocity()

Get the maximum motor velocity.

get_pos()

Query the absolute position of the stage

get_t()

Convert stage position in mm to delay in ps

get_velocity()

Get the current motor velocity.

move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on

Turn motor on/off.

pos

Query the absolute position of the stage

set_max_velocity(val)

Set the max motor velocity.

set_pos(val)

Set the absolute position of the stage

set_t(new_val)
set_unit(key)

Set the unit label for a given axis, by index.

Unit labels (‘mm’, ‘um’, etc) have corresponding integer indices. Look these up in the _unit_labels dictionary.

set_velocity(val)

Set the motor velocity.

stage_length = 600
step_size

Get the distance represented by one motor step.

t

Convert stage position in mm to delay in ps

unit

Get the unit label for a given axis.

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.short_stage(axisnum, bus=None)
busy
c = 3000.0
cmd(string)

Prepend the axis number to a command.

define_home()

Define the origin of this stage to be its current position.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_pos()

Query the absolute position of the stage

get_t()

Convert stage position in mm to delay in ps

mm = 10000.0
motor_status(bit=None)

Request the MM3000 motor status byte.

Optionally, pick out a specific bit.
bit 0: True if axis is moving bit 1: True if motor is off bit 2: True if direction of move is positive bit 3: True if positive travel limit is active bit 4: True if negative travel limit is active bit 5: True if positive side of home bit 6: always True bit 7: always False
move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on
pos

Query the absolute position of the stage

set_pos(val)

Set the absolute position of the stage

set_t(new_val)
stage_length = 1000000.0
t

Convert stage position in mm to delay in ps

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.shorty_stage(axisnum, bus=None)

Newport UTM100pp.1 stage, when plugged into ESP300

busy

ask whether motion is in progress

cmd(string)

Prepend the axis number to a command.

define_home(loc=None)

Define the origin of this stage to be its current position.

To define the current position to be some number other than zero, provide that number in the loc kwarg.

encoder_resolution

Get the distance represented by one encoder pulse.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_max_velocity()

Get the maximum motor velocity.

get_pos()

Query the absolute position of the stage

get_t()

Convert stage position in mm to delay in ps

get_velocity()

Get the current motor velocity.

initialize()
move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on

Turn motor on/off.

pos

Query the absolute position of the stage

set_max_velocity(val)

Set the max motor velocity.

set_pos(val)

Set the absolute position of the stage

set_t(new_val)
set_unit(key)

Set the unit label for a given axis, by index.

Unit labels (‘mm’, ‘um’, etc) have corresponding integer indices. Look these up in the _unit_labels dictionary.

set_velocity(val)

Set the motor velocity.

step_size

Get the distance represented by one motor step.

t

Convert stage position in mm to delay in ps

unit

Get the unit label for a given axis.

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)

class wanglib.instruments.stages.thorlabs_Z612B(axisnum, bus=None)

Thorlabs Z612B motorized actuator.

busy

ask whether motion is in progress

cmd(string)

Prepend the axis number to a command.

define_home(loc=None)

Define the origin of this stage to be its current position.

To define the current position to be some number other than zero, provide that number in the loc kwarg.

encoder_resolution

Get the distance represented by one encoder pulse.

find_zero()

Place the zero 1mm from the hardware limit. This follows Yan’s old labview routine.

get_max_velocity()

Get the maximum motor velocity.

get_pos()

Query the absolute position of the stage

get_velocity()

Get the current motor velocity.

initialize()
move(delta)

Move the stage (relative move)

move_to_limit(direction=-1)

Move to the hardware limit of the stage.

By default, finds the negative limit. To find the positive limit, provide a positive number as the argument.

NOTE: sometimes, the ESP300 will time out and give up looking for the hardware limit if it takes too long to get there. So, try to get reasonably close to the limit before using this function.

on

Turn motor on/off.

pos

Query the absolute position of the stage

set_max_velocity(val)

Set the max motor velocity.

set_pos(val)

Set the absolute position of the stage

set_unit(key)

Set the unit label for a given axis, by index.

Unit labels (‘mm’, ‘um’, etc) have corresponding integer indices. Look these up in the _unit_labels dictionary.

set_velocity(val)

Set the motor velocity.

step_size

Get the distance represented by one motor step.

unit

Get the unit label for a given axis.

wait(lag=0.5)

Stop the python program until motors stop moving.

optionally, specify a check interval in seconds (default: 0.5)