navigate.model.devices.APIs.sutter.MP285.MP285
- class navigate.model.devices.APIs.sutter.MP285.MP285(com_port: str, baud_rate: int, timeout=0.25)
Bases:
object
Sutter MP285 3D Stage API
The USB interface expects a baud rate of 9600, 8 data bits, 1 stop bits, no parity, and no flow control.
The serial interface expects a baud rate of 9600, 8 data bits, 1 stop bits, no parity, and hardware or RTS/CTS flow control.
Little-endian byte order is used for all commands and responses.
Each command sequence consists of at least one byte, the first of which is the “command byte”. Those commands that have parameters or arguments require a sequence of bytes that follow the command byte. No delimiters are used between command sequence arguments, and command sequence terminators are used in most cases.
Most command sequences have a terminator: ASCII CR (Carriage Return; 13 decimal, 0D hexadecimal) to indicate that the task associated with the command has completed. When the controller completes the task associated with a command, it sends ASCII CR back to the host computer indicating that it is ready to receive a new command. If a command returns data, the last byte returned is the task-completed indicator.
- __init__(com_port: str, baud_rate: int, timeout=0.25) → None
Initialize the MP-285 stage.
- Parameters:
com_port (str) – COM port of the MP-285 stage.
baud_rate (int) – Baud rate of the MP-285 stage.
timeout (float) – Timeout for the serial connection.
Methods
__init__
(com_port, baud_rate[, timeout])Initialize the MP-285 stage.
close
()Close the serial connection to the stage
Connect to the serial port of the MP-285 stage.
convert_microns_to_microsteps
(microns)Converts microsteps to microns.
convert_microsteps_to_microns
(microsteps)Converts microsteps to microns
Disconnect from the serial port of the MP-285 stage.
Get the status of the MP-285 controller.
Get the current stage position.
Interrupt stage movement.
move_to_specified_position
(x_pos, y_pos, z_pos)Move to Specified Position (‘m’) Command
read_response
(idx)Read the response from the MP-285 stage.
Refresh the display on the MP-285 controller.
Reset the MP-285 controller.
send_command
(command[, response_num])Send a command to the MP-285 stage.
Set MP285 to Absolute Position Mode.
set_resolution_and_velocity
(speed, resolution)Sets the MP-285 stage speed and resolution.
Attributes
Serial connection to the MP-285 stage
Speed of the stage in microns/sec
Resolution of the stage.
Wait until the stage is done moving before returning
Time to wait between checking if the stage is done moving
Number of times to check if the stage is done moving
Event to prevent writing to the serial port
Lock to prevent writing to the serial port
Flat to indicate of the stage is moving.
Time of the last write to the serial port
Number of commands to buffer
Index of the top command in the buffer
Index of the last command in the buffer
Flag to indicate if the stage is interrupted
Number of unreceived bytes.
Buffer to store the number of bytes to read for each command
- close() → None
Close the serial connection to the stage
- connect_to_serial() → None
Connect to the serial port of the MP-285 stage.
- Raises:
serial.SerialException – If the serial connection fails.
- static convert_microns_to_microsteps(microns: float) → float
Converts microsteps to microns.
- Parameters:
microns (float) – Distance in microns.
- Returns:
microsteps – Distance in microsteps
- Return type:
float
- static convert_microsteps_to_microns(microsteps: float) → float
Converts microsteps to microns
- Parameters:
microsteps (float) – Distance in microsteps
- Returns:
microns – Distance in microns
- Return type:
float
- disconnect_from_serial() → None
Disconnect from the serial port of the MP-285 stage.
- get_controller_status() → bool
Get the status of the MP-285 controller.
This command gets status information from the controller and returns it in fixed-sized block of data. The command sequence consists of 2 bytes: Command byte and terminator. Return data consists of 33 bytes: 32 bytes of information and task-complete indicator.
- Returns:
True if command was successful, False if not.
- Return type:
command_complete = bool
- get_current_position() → Tuple[Optional[float], Optional[float], Optional[float]]
Get the current stage position.
Gets the stage position. The data returned consists of 13 bytes: 12 bytes containing X, Y, & Z position values in microsteps (4 bytes each), followed with the task-complete indicator (1 byte).
- Returns:
position – The x, y, and z positions in microns if available.
x_pos is the X position in microns. None if the position is not available.
y_pos is the Y position in microns. None if the position is not available.
z_pos is the Z position in microns. None if the position is not available.
- Return type:
Tuple[Optional[float], Optional[float], Optional[float]]
- interrupt_move() → Optional[bool]
Interrupt stage movement.
This command interrupts and stops a move in progress that originally initiated by the Move (‘m’) command. The command sequence consists of 1 byte: Command byte (no terminator).
Return data consists of 1 byte if movement is not in progress, or 2 bytes (‘=’ (move-in- progress indicator)and task-complete indicator.
- Returns:
stage_stopped – True if move was successful, False if not.
- Return type:
bool
- move_to_specified_position(x_pos: float, y_pos: float, z_pos: float) → bool
Move to Specified Position (‘m’) Command
This command instructs the controller to move all three axes to the position specified.
The command sequence consists of 14 bytes: Command byte followed by three sets of four bytes containing position information in microsteps for X, Y, and Z, and ending with the terminator. Return data consists of 1 byte (task-complete indicator), which occurs after the move is complete.
- Parameters:
x_pos (float) – X position in microns
y_pos (float) – Y position in microns
z_pos (float) – Z position in microns
- Returns:
move_complete – True if move was successful, False if not.
- Return type:
bool
- read_response(idx: int) → Optional[Union[bytes, str]]
Read the response from the MP-285 stage.
- Parameters:
idx (int) – Index of the command in the buffer.
- Returns:
response – Response from the MP-285 stage.
- Return type:
bytes, str, None
- refresh_display() → bool
Refresh the display on the MP-285 controller.
This command refreshes the VFD (Vacuum Fluorescent Display) of the controller. The command sequence consists of 2 bytes: Command byte and terminator. Return data consists of 1 byte: task-complete indicator.
- Returns:
command_complete – True if command was successful, False if not.
- Return type:
bool
- reset_controller() → bool
Reset the MP-285 controller.
This command resets the controller. The command sequence consists of 2 bytes: Command byte and terminator. Return data consists of 1 byte: task-complete indicator.
- Returns:
command_complete – True if command was successful, False if not.
- Return type:
bool
- send_command(command: bytes, response_num=1) → int
Send a command to the MP-285 stage.
- Parameters:
command (bytes) – Command to send to the MP-285 stage.
response_num (int) – Number of bytes to read for the response.
- Returns:
idx – Index of the command in the buffer.
- Return type:
int
- set_absolute_mode() → bool
Set MP285 to Absolute Position Mode.
This command sets the nature of the positional values specified with the Move (‘m’) command as absolute positions as measured from the point of origin (Position 0). The command sequence consists of 2 bytes: Command byte, followed by the terminator. Return data consists of 1 byte (task-complete indicator).
- Returns:
command_complete – True if command was successful, False if not.
- Return type:
bool
- set_resolution_and_velocity(speed: int, resolution: str) → bool
Sets the MP-285 stage speed and resolution.
This command instructs the controller to move all three axes to the position specified. The command sequence consists of 4 bytes: Command byte, followed by 2 bytes containing resolution and velocity information, and ending with the terminator. Return data consists of 1 byte (task-complete indicator).
- Parameters:
speed (int) – Low Resolution = 0-3000 microns/sec High Resolution = 0-1310 microns/sec
resolution (str) – Low - 0.2 microns/microstep = 10 microsteps/step High - 0.04 microns/microstep = 50 microsteps/step
- Returns:
command_complete – True if command was successful, False if not.
- Return type:
bool
- commands_buffer
Buffer to store the number of bytes to read for each command
- Type:
list
- commands_num
Number of commands to buffer
- Type:
int
- is_interrupted
Flag to indicate if the stage is interrupted
- Type:
bool
- is_moving
Flat to indicate of the stage is moving.
- Type:
bool
- last_command_idx
Index of the last command in the buffer
- Type:
int
- last_write_time
Time of the last write to the serial port
- Type:
time.time
- n_waits
Number of times to check if the stage is done moving
- Type:
int
- resolution
Resolution of the stage. High or Low.
- Type:
str
- safe_to_write
Event to prevent writing to the serial port
- Type:
threading.Event
- serial
Serial connection to the MP-285 stage
- Type:
serial.Serial
- speed
Speed of the stage in microns/sec
- Type:
int
- top_command_idx
Index of the top command in the buffer
- Type:
int
- unreceived_bytes
Number of unreceived bytes.
- Type:
int
- wait_time
Time to wait between checking if the stage is done moving
- Type:
float
- wait_until_done
Wait until the stage is done moving before returning
- Type:
bool
- write_done_flag
Lock to prevent writing to the serial port
- Type:
threading.Lock