navigate.model.devices.APIs.asi.asi_MS2000_controller.MS2000Controller
- class navigate.model.devices.APIs.asi.asi_MS2000_controller.MS2000Controller(com_port: str, baud_rate: int, verbose: bool = False)
Bases:
object
MS2000 Controller class
- __init__(com_port: str, baud_rate: int, verbose: bool = False)
Initialize the MS2000 Controller class
- Parameters:
com_port (str) – COM port of the MS2000 Controller
baud_rate (int) – Baud rate of the MS2000 Controller
verbose (bool) – If True, will print out messages to the console
Methods
__init__
(com_port, baud_rate[, verbose])Initialize the MS2000 Controller class
connect_to_serial
([rx_size, tx_size, ...])Connect to the serial port.
Disconnect from the serial port if it's open.
get_axis_position
(axis)Return the position of the stage in ASI units (tenths of microns).
get_axis_position_um
(axis)Return the position of the stage in microns.
Get the default motor axis sequence from the ASI device
Get encoder counts pre mm of axis
get_position
(axes)Return current stage position in ASI units.
get_speed
(axis)Get speed
is_axis_busy
(axis)Returns True if the axis is busy.
Returns True if any axis is busy.
Check to see if the stage is moving.
is_open
()Returns True if the serial port exists and is open.
move
(pos_dict)Move the stage with an absolute move on multiple axes
move_axis
(axis, distance)Move the stage with an absolute move on one axis
moverel
([x, y, z])Move the stage with a relative move on multiple axes.
moverel_axis
(axis, distance)Move the stage with a relative move on one axis
Read a line from the serial response.
report_to_console
(message)Print message to the output device, usually the console.
Scans for available COM ports
scanr
(start_position_mm, end_position_mm[, ...])Set scanr operation mode.
scanv
(start_position_mm, end_position_mm, ...)Set scanv operation mode.
send_command
(cmd)Send a serial command to the device.
set_backlash
(axis, val)Enable/disable stage backlash correction.
set_error
(axis, ac)Set the stage drift error
set_feedback_alignment
(axis, aa)Set the stage feedback alignment.
set_finishing_accuracy
(axis, ac)Set the stage finishing accuracy.
set_max_speed
(axis, speed)Set the speed on a specific axis.
set_speed
(speed_dict)Set speed
Set speed as a percentage of the maximum speed
set_triggered_move
(axis)Set ASI to repeat the latest relative movement upon receiving a TTL pulse
start_scan
(axis[, is_single_axis_scan])Start scan
stop
()Stop all stage movement immediately
Stop scan.
wait_for_device
([timeout])Waits for the all motors to stop moving.
Attributes
Serial port object
COM port of the MS2000 Controller
Baud rate of the MS2000 Controller
If True, will print out messages to the console
Default axes sequence of the MS2000 Controller
Event to indicate if it is safe to write to the serial port
- connect_to_serial(rx_size: int = 12800, tx_size: int = 12800, read_timeout: int = 1, write_timeout: int = 1) → None
Connect to the serial port.
- Parameters:
rx_size (int) – Size of the rx buffer
tx_size (int) – Size of the tx buffer
read_timeout (int) – Read timeout in seconds
write_timeout (int) – Write timeout in seconds
- disconnect_from_serial() → None
Disconnect from the serial port if it’s open.
- get_axis_position(axis: str) → int
Return the position of the stage in ASI units (tenths of microns).
- Parameters:
axis (str) – Stage axis
- Returns:
Position of the stage in ASI units
- Return type:
int
- get_axis_position_um(axis: str) → float
Return the position of the stage in microns.
- Parameters:
axis (str) – Stage axis
- Returns:
Position of the stage in microns
- Return type:
float
- get_default_motor_axis_sequence() → None
Get the default motor axis sequence from the ASI device
- Returns:
Default motor axis sequence
- Return type:
list[str]
- get_encoder_counts_per_mm(axis: str)
Get encoder counts pre mm of axis
- Parameters:
axis (str) – Stage axis
- Returns:
Encoder counts per mm of axis
- Return type:
float
- get_position(axes) → dict
Return current stage position in ASI units.
If default axes sequence has gotten from the ASI device, then it will ask the device all the position in one command, else it will ask each axis position one by one.
WATCH OUT! This will return the positions in the order of the underlying hardware no matter what order the axes are passed in.
See https://asiimaging.com/docs/products/serial_commands#commandwhere_w
- Parameters:
axes (list[str]) – List of axes to query
- Returns:
{axis: position}
- Return type:
dictionary
- get_speed(axis: str)
Get speed
- Parameters:
axis (str) – Stage axis
- is_axis_busy(axis: str) → bool
Returns True if the axis is busy.
- Parameters:
axis (str) – Stage axis
- Returns:
True if the axis is busy
- Return type:
bool
- is_device_busy() → bool
Returns True if any axis is busy.
- Returns:
True if any axis is busy
- Return type:
bool
- is_moving()
Check to see if the stage is moving.
Sends the command / which is equivalent to STATUS
Gets response: N - there are no motors running from a serial command B - there is a motor running from a serial command
- Returns:
response – True if any axis is moving. False if not.
- Return type:
Bool
- is_open() → bool
Returns True if the serial port exists and is open.
- Returns:
True if the serial port exists and is open
- Return type:
bool
- move(pos_dict) → None
Move the stage with an absolute move on multiple axes
- Parameters:
pos_dict (dict) – Dictionary of the form {axis: position}
- move_axis(axis: str, distance: float) → None
Move the stage with an absolute move on one axis
- Parameters:
axis (str) – Stage axis
distance (float) – Absolute move distance
- moverel(x: int = 0, y: int = 0, z: int = 0) → None
Move the stage with a relative move on multiple axes.
- Parameters:
x (int) – Relative move on the x-axis
y (int) – Relative move on the y-axis
z (int) – Relative move on the z-axis
- moverel_axis(axis: str, distance: float) → None
Move the stage with a relative move on one axis
- Parameters:
axis (str) – Stage axis
distance (float) – Relative move distance
- read_response() → str
Read a line from the serial response.
- Returns:
Response from the serial port
- Return type:
str
- report_to_console(message: str) → None
Print message to the output device, usually the console.
- Parameters:
message (str) – Message to print to the output device
- static scan_ports() → list[str]
Scans for available COM ports
Returns a sorted list of COM ports.
- Returns:
Sorted list of COM ports
- Return type:
list[str]
- scanr(start_position_mm: float, end_position_mm: float, enc_divide: float = 0, axis: str = 'X')
Set scanr operation mode.
- Parameters:
start_position_mm (float) – Start position in mm
end_position_mm (float) – End position in mm
enc_divide (float) – Encoder divide
axis (str) – Stage axis
- scanv(start_position_mm: float, end_position_mm: float, number_of_lines: float, overshoot: float = 1.0, axis: str = 'X')
Set scanv operation mode.
- Parameters:
start_position_mm (float) – Start position in mm
end_position_mm (float) – End position in mm
number_of_lines (float) – Number of lines
overshoot (float) – Overshoot
axis (str) – Stage axis
- send_command(cmd: str) → None
Send a serial command to the device.
- Parameters:
cmd (str) – Serial command to send to the device
- set_backlash(axis, val)
Enable/disable stage backlash correction.
- Parameters:
axis (str) – Stage axis
val (float) – Distance of anti-backlash motion [mm]
- set_error(axis, ac)
Set the stage drift error
- Parameters:
axis (str) – Stage axis
ac (float) – Position error [mm]
- set_feedback_alignment(axis, aa)
Set the stage feedback alignment.
- Parameters:
axis (str) – Stage axis
- set_finishing_accuracy(axis, ac)
Set the stage finishing accuracy.
- Parameters:
axis (str) – Stage axis
ac (float) – Position error [mm]
- set_max_speed(axis: str, speed: float) → None
Set the speed on a specific axis. Speed is in mm/s.
- Parameters:
axis (str) – Stage axis
speed (float) – Speed in mm/s
- set_speed(speed_dict)
Set speed
- Parameters:
speed_dict (dict) – Dictionary of the form {axis: speed}
- set_speed_as_percent_max(pct)
Set speed as a percentage of the maximum speed
- Parameters:
pct (float) – Percentage of the maximum speed
- set_triggered_move(axis)
Set ASI to repeat the latest relative movement upon receiving a TTL pulse
- Parameters:
axis (str) – Stage axis
- start_scan(axis: str, is_single_axis_scan: bool = True)
Start scan
- Parameters:
axis (str) – Stage axis
is_single_axis_scan (bool) – If True, will only scan on one axis
- stop()
Stop all stage movement immediately
- stop_scan()
Stop scan.
- wait_for_device(timeout: float = 1.75) → None
Waits for the all motors to stop moving.
- timeoutfloat
Timeout in seconds. Default is 1.75 seconds.
- baud_rate
Baud rate of the MS2000 Controller
- Type:
int
- com_port
COM port of the MS2000 Controller
- Type:
str
- default_axes_sequence
Default axes sequence of the MS2000 Controller
- Type:
list[str]
- safe_to_write
Event to indicate if it is safe to write to the serial port
- Type:
threading.Event
- serial_port
Serial port object
- Type:
Serial
- verbose
If True, will print out messages to the console
- Type:
bool