Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 new qmi driver for thorlabs mpc320 #73

Merged
merged 41 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b33ac86
apt_protocol with wip driver
rbudhrani Feb 12, 2024
1b69756
typo
rbudhrani Feb 22, 2024
8602142
removed unsupported methods
rbudhrani Mar 15, 2024
56b16b9
Merge branch 'main' into 62-new-qmi-driver-for-thorlabs-mpc320
rbudhrani Mar 15, 2024
2010c09
commit badges
Mar 15, 2024
ef125c7
pipeline fix to check failure
rbudhrani Mar 15, 2024
b143f81
Merge branch '62-new-qmi-driver-for-thorlabs-mpc320' of github.com:Qu…
rbudhrani Mar 15, 2024
7260d07
Merge branch 'main' into 62-new-qmi-driver-for-thorlabs-mpc320
rbudhrani Mar 19, 2024
d9bcdb7
added move absolute command
rbudhrani Mar 20, 2024
dd026c2
commit badges
Mar 20, 2024
34687cc
fixed polarisation commands
rbudhrani Mar 22, 2024
04f9cb3
commit badges
Mar 22, 2024
56d4f71
added channel validation
rbudhrani Mar 22, 2024
cd9d552
refactor
rbudhrani Mar 22, 2024
3f80d4a
added channel mapping
rbudhrani Mar 22, 2024
91110cf
fixed enable and disable channel commands
rbudhrani Mar 27, 2024
62612f7
refactored identify command
rbudhrani Mar 27, 2024
d155c47
commit badges
Mar 27, 2024
43b65e5
added method to jog
rbudhrani Mar 28, 2024
2008f26
bugfix channel mapping
rbudhrani Apr 5, 2024
7e4de7c
accept anything except 0x01 as DISABLE state
rbudhrani Apr 12, 2024
fb20f78
commit badges
Apr 12, 2024
067c471
move completed and homed commands have retries
rbudhrani Apr 30, 2024
c251952
homed and move completed fixes
rbudhrani Jul 10, 2024
78cc1f3
Merge branch 'main' into 62-new-qmi-driver-for-thorlabs-mpc320
rbudhrani Jul 12, 2024
43acbc7
first unittest and formatting
rbudhrani Jul 12, 2024
569d465
added more tests
rbudhrani Jul 12, 2024
3f60e11
more tests
rbudhrani Jul 15, 2024
d20895a
all tests
rbudhrani Jul 15, 2024
92c3015
test to check wrong msg id branch
rbudhrani Jul 15, 2024
d55e5b7
try catch for move and homing checks
rbudhrani Jul 16, 2024
b0e1bfb
added missing docstring
rbudhrani Jul 16, 2024
2545c16
typo
rbudhrani Jul 16, 2024
2d2f806
typo
rbudhrani Jul 16, 2024
724aa96
reformat docstring
rbudhrani Jul 16, 2024
7ee1b1f
typo
rbudhrani Jul 16, 2024
bed4f35
changed default params to 0x00
rbudhrani Jul 16, 2024
8621a73
fixed docstring typo
rbudhrani Jul 16, 2024
b2867ff
added mpc320 to init
rbudhrani Jul 16, 2024
18a3dee
review comments
rbudhrani Jul 16, 2024
55de244
refactoring
rbudhrani Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- QMI driver for TeraXion TFN in `qmi.instruments.teraxion` with CLI client.
- QMI driver for Thorlabs MPC320 in `qmi.instruments.thorlabs`.

### Changed
- In `setup.py` limited NumPy and SciPy versions to be <2. Also added missing line for Tenma 72 PSU CLI.
Expand Down
5 changes: 5 additions & 0 deletions qmi/instruments/thorlabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
- MFF10X filter flip mounts
- PM100D power meter
- TSP01, TSP01B environmental sensors.
- MPC320 Polarisation Controller.
"""
rbudhrani marked this conversation as resolved.
Show resolved Hide resolved

from qmi.instruments.thorlabs.pm100d import SensorInfo
from qmi.instruments.thorlabs.tc200 import Tc200Status
from qmi.instruments.thorlabs.apt_protocol import AptChannelState

# Alternative, QMI naming convention approved names
from qmi.instruments.thorlabs.k10cr1 import Thorlabs_K10CR1 as Thorlabs_K10Cr1
from qmi.instruments.thorlabs.mff10x import Thorlabs_MFF10X as Thorlabs_Mff10X
Expand All @@ -19,3 +23,4 @@
from qmi.instruments.thorlabs.tc200 import Thorlabs_TC200 as Thorlabs_Tc200
from qmi.instruments.thorlabs.tsp01 import Thorlabs_TSP01 as Thorlabs_Tsp01
from qmi.instruments.thorlabs.tsp01b import Thorlabs_TSP01B as Thorlabs_Tsp01b
from qmi.instruments.thorlabs.mpc320 import Thorlabs_Mpc320
191 changes: 191 additions & 0 deletions qmi/instruments/thorlabs/apt_packets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
"""Module containing the packets for the APT protocol."""

from typing import List, Tuple
from qmi.instruments.thorlabs.apt_protocol import (
AptMessage,
AptMessageId,
apt_long,
apt_dword,
apt_char,
apt_word,
apt_byte,
apt_short,
)


class HW_GET_INFO(AptMessage):
"""
Data packet structure for the HW_GET_INFO response. This packet is sent as a response to HW_GET_INFO.

Fields:
serial_number: Serial number of device.
model_number: Model number of device.
type: Hardware type of device.
firmware_version: Firmware version of device.
hw_version: Hardware version of device.
mod_state: Modification state of device.
num_channels: Number of channels in device.
"""

MESSAGE_ID = AptMessageId.HW_GET_INFO.value
_fields_: List[Tuple[str, type]] = [
("serial_number", apt_long),
("model_number", apt_char * 8),
("type", apt_word),
("firmware_version", apt_dword),
(
"internal",
apt_dword * 15,
), # this is for internal use, so we don't know what type it returns
("hw_version", apt_word),
("mod_state", apt_word),
("num_channels", apt_word),
]


class MOD_GET_CHANENABLESTATE(AptMessage):
"""
Header structure for the MOD_GET_CHANENABLESTATE response. This header is sent as a response to
MOD_REQ_CHANENABLESTATE.

Fields:
message_id: ID of message.
chan_ident: Channel number.
enable_state: Indicate whether chanel is enabled or disabled.
dest: Destination of message.
source: Source of message.
"""

MESSAGE_ID = AptMessageId.MOD_GET_CHANENABLESTATE.value
HEADER_ONLY = True
_fields_: List[Tuple[str, type]] = [
("message_id", apt_word),
("chan_ident", apt_byte),
("enable_state", apt_byte),
("dest", apt_byte),
("source", apt_byte),
]


class MOT_MOVE_HOMED(AptMessage):
"""
Header structure for the MOT_MOVE_HOMED response. This header is sent as a response to MOT_MOVE_HOME
once homing is complete.

Fields:
message_id: ID of message.
chan_ident: Channel number.
param2: To be left as 0x00.
dest: Destination of message.
source: Source of message.
"""

MESSAGE_ID = AptMessageId.MOT_MOVE_HOMED.value
HEADER_ONLY = True
_fields_: List[Tuple[str, type]] = [
("message_id", apt_word),
("chan_ident", apt_byte),
("param2", apt_byte),
("dest", apt_byte),
("source", apt_byte),
]


class MOT_MOVE_ABSOLUTE(AptMessage):
"""
Data packet structure for a MOT_SMOVE_ABSOLUTE command.

Fields:
chan_ident: The channel being addressed.
absolute_distance: The distance to move in encoder units.
"""

MESSAGE_ID = AptMessageId.MOT_MOVE_ABSOLUTE.value
_fields_: List[Tuple[str, type]] = [
("chan_ident", apt_word),
("absolute_distance", apt_long),
]


class MOT_MOVE_COMPLETED(AptMessage):
"""
Header structure for the MOT_MOVE_COMPLETED response. This header is sent as a response to a relative or absolute
move command once the move has been completed.

Fields:
message_id: ID of message.
chan_ident: Channel number.
param2: To be left as 0x00.
dest: Destination of message.
source: Source of message.
"""

MESSAGE_ID = AptMessageId.MOT_MOVE_COMPLETED.value
HEADER_ONLY = True
_fields_: List[Tuple[str, type]] = [
("message_id", apt_word),
("chan_ident", apt_byte),
("param2", apt_byte),
("dest", apt_byte),
("source", apt_byte),
]


class MOT_GET_USTATUSUPDATE(AptMessage):
"""
Data packet structure for a MOT_GET_USTATUSUPDATE command.

Fields:
chan_ident: The channel being addressed.
position: The position in encoder counts.
velocity: Velocity in controller units. Note that this is reported as a 16 bit
unsigned integer in the manual but it is actually signed according to the example.
motor_current: Motor current in mA.
status_bits: Status bits that provide various errors and indications.
"""

MESSAGE_ID = AptMessageId.MOT_GET_USTATUSUPDATE.value
_fields_: List[Tuple[str, type]] = [
("chan_ident", apt_word),
("position", apt_long),
("velocity", apt_word),
("motor_current", apt_short),
("status_bits", apt_dword),
]


class MOT_SET_EEPROMPARAMS(AptMessage):
"""
Data packet structure for a MOT_SET_EEPROMPARAMS command.

Fields:
chan_ident: The channel being addressed.
msg_id: ID of message whose settings should be save.
"""

MESSAGE_ID = AptMessageId.MOT_SET_EEPROMPARAMS.value
_fields_: List[Tuple[str, type]] = [("chan_ident", apt_word), ("msg_id", apt_word)]


class POL_GET_SET_PARAMS(AptMessage):
""" "
Data packet structure for POL_SET_PARAMS command. It is also the data packet structure for the POL_GET_PARAMS.

Fields:
not_used: This field is not used, but needs to be in the field structure to not break it.
velocity: Velocity in range 10% to 100% of 400 degrees/s.
home_position: Home position in encoder counts.
jog_step1: Size fo jog step to be performed on paddle 1.
jog_step2: Size fo jog step to be performed on paddle 2.
jog_step3: Size fo jog step to be performed on paddle 3.
"""

MESSAGE_ID = AptMessageId.POL_GET_PARAMS.value
_fields_: List[Tuple[str, type]] = [
("not_used", apt_word),
("velocity", apt_word),
("home_position", apt_word),
("jog_step1", apt_word),
("jog_step2", apt_word),
("jog_step3", apt_word),
]
Loading
Loading