-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from julienbarrier/thorlab_drivers
Add Thorlab drivers
- Loading branch information
Showing
13 changed files
with
1,413 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QCoDes-Driver for Thorlab KDC101 K-Cube Brushed DC Servo Motor Controller | ||
https://www.thorlabs.com/thorproduct.cfm?partnumber=KDC101 | ||
Authors: | ||
Julien Barrier, <[email protected]> | ||
""" | ||
import logging | ||
from typing import Optional | ||
|
||
from .private.CC import _Thorlabs_CC | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class Thorlabs_KDC101(_Thorlabs_CC): | ||
"""Instrument driver for the Thorlabs KDC101 servo motor controller | ||
Args: | ||
name: Instrument name. | ||
serial_number: Serial number of the device. | ||
dll_path: Path to the kinesis dll for the instrument to use. | ||
dll_dir: Directory in which the kinesis dll are stored. | ||
simulation: Enables the simulation manager. | ||
polling: Polling rate in ms. | ||
home: Sets the device to home state. | ||
""" | ||
def __init__(self, | ||
name: str, | ||
serial_number: str, | ||
dll_path: Optional[str] = None, | ||
dll_dir: Optional[str] = None, | ||
simulation: bool = False, | ||
polling: int = 200, | ||
home: bool = False, | ||
**kwargs): | ||
if dll_path: | ||
self._dll_path = dll_path | ||
else: | ||
self._dll_path = 'Thorlabs.MotionControl.KCube.DCServo.dll' | ||
self._dll_dir: Optional[str] = dll_dir if dll_dir else None | ||
super().__init__(name, serial_number, self._dll_path, self._dll_dir, | ||
simulation, polling, home, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,39 @@ | ||
from qcodes import Instrument | ||
import qcodes.utils.validators as vals | ||
|
||
from .Kinesis import Thorlabs_Kinesis | ||
|
||
|
||
class Thorlabs_KLS1550(Instrument): | ||
def __init__( | ||
self, | ||
name: str, | ||
serial_number: str, | ||
polling_speed_ms: int, | ||
kinesis: Thorlabs_Kinesis, | ||
**kwargs, | ||
): | ||
super().__init__(name, **kwargs) | ||
# Save Kinesis server reference | ||
self.kinesis = kinesis | ||
|
||
# Initialization | ||
self.serial_number = serial_number | ||
self.polling_speed_ms = polling_speed_ms | ||
self.kinesis.open_laser(self.serial_number) | ||
self.kinesis.start_polling(self.serial_number, self.polling_speed_ms) | ||
self.info = self.kinesis.laser_info(self.serial_number) | ||
self.model = self.info[0].value.decode("utf-8") | ||
self.version = self.info[4].value | ||
|
||
# Parameters | ||
self.add_parameter( | ||
"output_enabled", | ||
get_cmd=self._get_output_enabled, | ||
set_cmd=self._set_output_enabled, | ||
vals=vals.Bool(), | ||
unit="", | ||
label="Laser output on/off", | ||
docstring="Turn laser output on/off. Note that laser key switch must be on to turn laser output on.", | ||
) | ||
|
||
self.add_parameter( | ||
"power", | ||
get_cmd=self._get_power, | ||
set_cmd=self._set_power, | ||
vals=vals.Numbers(0, 0.007), # [ATTENTION] max power for simulator is 10mW | ||
unit="W", | ||
label="Power output", | ||
) | ||
|
||
self.connect_message() | ||
|
||
def get_idn(self): | ||
return { | ||
"vendor": "Thorlabs", | ||
"model": self.model, | ||
"firmware": self.version, | ||
"serial": self.serial_number, | ||
} | ||
|
||
def _get_output_enabled(self): | ||
# First status bit represents 'output enabled' | ||
return bool(self.kinesis.laser_status_bits(self.serial_number) & 1) | ||
|
||
def _set_output_enabled(self, value: bool): | ||
if value: | ||
self.kinesis.laser_enable_output(self.serial_number) | ||
# -*- coding: utf-8 -*- | ||
"""QCoDeS-Driver for Thorlab KLS1550 Laser source | ||
Authors: | ||
iago-rst https://github.com/iago-rst, 2023 | ||
Julien Barrier <[email protected]>, 2023 | ||
""" | ||
import logging | ||
from typing import Optional | ||
from .private.LS import _Thorlabs_LS | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
class Thorlabs_KLS1550(_Thorlabs_LS): | ||
"""Instrument driver for the Thorlabs KLS1550 | ||
Args: | ||
name: Instrument name. | ||
serial_number: Serial number of the device. | ||
dll_path: Path to the kinesis dll for the instrument to use. | ||
dll_dir: Directory in which the kinesis dll are stored. | ||
simulation: Enables the simulation manager. | ||
polling: Polling rate in ms. | ||
""" | ||
def __init__(self, | ||
name: str, | ||
serial_number: str, | ||
dll_path: Optional[str] = None, | ||
dll_dir: Optional[str] = None, | ||
simulation: bool = False, | ||
polling: int = 200, | ||
**kwargs): | ||
if dll_path: | ||
self._dll_path = dll_path | ||
else: | ||
self.kinesis.laser_disable_output(self.serial_number) | ||
|
||
def _get_power(self): | ||
return self.kinesis.get_laser_power(self.serial_number) | ||
|
||
def _set_power(self, power_W: float): | ||
self.kinesis.set_laser_power(self.serial_number, power_W) | ||
|
||
def disconnect(self): | ||
self.kinesis.stop_polling(self.serial_number) | ||
self.kinesis.close_laser(self.serial_number) | ||
|
||
def close(self): | ||
self.disconnect() | ||
super().close() | ||
self._dll_path = 'Thorlabs.MotionControl.KCube.LaserSource.dll' | ||
self._dll_dir: Optional[str] = dll_dir if dll_dir else None | ||
super().__init__(name, serial_number, self._dll_path, self._dll_dir, | ||
simulation, polling, **kwargs) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.