qmi.instruments.thorlabs.apt_protocol
Module for the APT protocol used by Thorlabs. The documentation for the protocol can be found here https://www.thorlabs.com/Software/Motion%20Control/APT_Communications_Protocol.pdf
Classes
|
Possible values for the |
|
Possible values for the |
|
Jog direction |
|
Channel state |
|
Channel stop mode |
|
Implement the Thorlabs APT protocol primitives. |
|
Homing parameters for the controller. |
|
Status bits of motor controller. |
- class qmi.instruments.thorlabs.apt_protocol.AptChannelState(value)
Channel state
- class qmi.instruments.thorlabs.apt_protocol.AptChannelStopMode(value)
Channel stop mode
- class qmi.instruments.thorlabs.apt_protocol.AptChannelJogDirection(value)
Jog direction
- class qmi.instruments.thorlabs.apt_protocol.AptChannelHomeDirection(value)
Possible values for the
home_directionfield in the homing parameters.
- class qmi.instruments.thorlabs.apt_protocol.AptChannelHomeLimitSwitch(value)
Possible values for the
limit_switchfield in the homing parameters.
- class qmi.instruments.thorlabs.apt_protocol.HomeParams(home_direction: AptChannelHomeDirection, limit_switch: AptChannelHomeLimitSwitch, home_velocity: float, offset_distance: float)
Homing parameters for the controller.
- home_direction
Direction of moving to home (1 = forward, 2 = reverse).
- limit_switch
Limit switch to use for homing (1 = reverse, 4 = forward).
- home_velocity
Homing velocity in degrees/second or mm/second.
- Type:
float
- offset_distance
Distance of home position from home limit switch (in degrees or mm).
- Type:
float
- class qmi.instruments.thorlabs.apt_protocol.MotorStatus(forward_limit: bool, reverse_limit: bool, moving_forward: bool, moving_reverse: bool, jogging_forward: bool, jogging_reverse: bool, homing: bool, homed: bool, tracking: bool, settled: bool, motion_error: bool, current_limit: bool, channel_enabled: bool)
Status bits of motor controller.
Note: Some of the status bits do not seem to work with the K10CR1.
- moving_forward
True if the motor is moving in forward direction.
- Type:
bool
- moving_reverse
True if the motor is moving in reverse direction. It looks like move_forward and move_reverse are both active when the stage is moving, regardless of the actual direction of movement.
- Type:
bool
- jogging_forward
True if the motor is jogging in forward direction.
- Type:
bool
- jogging_reverse
True if the motor is jogging in reverse direction. It looks like jogging_reverse is also active when jogging in forward direction, while jogging_forward is never active.
- Type:
bool
- homing
True if the motor is homing.
- Type:
bool
- homed
True if homing has been completed.
- Type:
bool
- motion_error
True if an excessive position error is detected.
- Type:
bool
- current_limit
True if the motor current limit has been reached.
- Type:
bool
- channel_enabled
True if the motor drive channel is enabled.
- Type:
bool
- class qmi.instruments.thorlabs.apt_protocol.AptProtocol(transport: QMI_SerialTransport, apt_device_address: int = 80, host_address: int = 1, default_timeout: float | None = None)
Implement the Thorlabs APT protocol primitives.
- create(msg_type: _AptMessage, **kwargs: Any) _AptMessage
Call for creating and returning a message instance. Valid for request and get messages.
- Returns:
The created message instance.
- Return type:
apt_message
- send_message(msg: _AptMessage) None
Encode and send a binary message to the instrument. Before sending a new command, do a non-blocking read to consume a potential old message from the instrument. This prevents a buildup of unhandled notification messages from the instrument after several move_XXX() commands.
- Parameters:
msg – An _AptMessage instance.
- read_message(timeout: float | None) _AptMessage
Read and decode a binary message from the instrument.
- Parameters:
timeout – A timeout value for reading the messages.
- Returns:
The obtained message instance with data from the buffer.
- Return type:
message
- Raises:
QMI_InstrumentException – If an unknown or partial message is received.
- wait_message(message_type: type, timeout: float | None) _AptMessage
Wait for a specific message type from the instrument.
Any other (valid) messages received from the instrument will be discarded.
- Parameters:
message_type – Type of message to wait for.
timeout – Maximum time to wait for the message in seconds.
- Returns:
The received message.
- Raises:
QMI_TimeoutException – If the expected message is not received within the timeout.
- ask(request_msg: _AptMessage, reply_msg: _AptMessage | _AptMessageHeader) _AptMessage
A helper function for requests that expect a response.
- Parameters:
request_msg – The request message to be sent.
reply_msg – The reply message expected to be received.