-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure the Lakeshore instrument drivers , add Lakeshore 224. (#870)
Use the new channels feature. Add a driver for the model 224 which uses the temperature input channel class.
- Loading branch information
1 parent
eb9ee9c
commit 55752c0
Showing
6 changed files
with
218 additions
and
77 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,7 @@ | ||
################################## | ||
Lake Shore 224 Temperature Monitor | ||
################################## | ||
|
||
.. autoclass:: pymeasure.instruments.lakeshore.LakeShore224 | ||
:members: | ||
:show-inheritance: |
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,62 @@ | ||
# | ||
# This file is part of the PyMeasure package. | ||
# | ||
# Copyright (c) 2013-2023 PyMeasure Developers | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
|
||
import logging | ||
from pymeasure.instruments import Instrument | ||
from pymeasure.instruments.lakeshore.lakeshore_base import LakeShoreTemperatureChannel | ||
|
||
log = logging.getLogger(__name__) | ||
log.addHandler(logging.NullHandler()) | ||
|
||
|
||
class LakeShore224(Instrument): | ||
""" Represents the Lakeshore 224 Temperature monitor and provides a high-level interface | ||
for interacting with the instrument. Note that the 224 provides 12 temperature input channels | ||
(A, B, C1-5, D1-5). This driver makes use of the :ref:`LakeShoreChannels` | ||
.. code-block:: python | ||
monitor = LakeShore224('GPIB::1') | ||
print(monitor.input_A.kelvin) # Print the temperature in kelvin on sensor A | ||
monitor.input_A.wait_for_temperature() # Wait for the temperature on sensor A to stabilize. | ||
""" | ||
|
||
i_ch = Instrument.ChannelCreator(LakeShoreTemperatureChannel, | ||
['0', 'A', 'B', | ||
'C1', 'C2', 'C3', 'C4', 'C5', | ||
'D1', 'D2', 'D3', 'D4', 'D5'], | ||
prefix='input_') | ||
|
||
def __init__(self, adapter, **kwargs): | ||
name = 'Lakeshore Model 224 Temperature Controller' if 'name' not in kwargs.keys() \ | ||
else kwargs.pop('name') | ||
read_termination = '\r\n' if 'read_termination' not in kwargs.keys() \ | ||
else kwargs.pop('read_termination') | ||
super().__init__( | ||
adapter, | ||
name, | ||
read_termination=read_termination, | ||
**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
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,114 @@ | ||
# | ||
# This file is part of the PyMeasure package. | ||
# | ||
# Copyright (c) 2013-2023 PyMeasure Developers | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
|
||
import logging | ||
import numpy as np | ||
from time import sleep, time | ||
|
||
from pymeasure.instruments import Instrument, Channel | ||
from pymeasure.instruments.validators import strict_discrete_set | ||
|
||
log = logging.getLogger(__name__) | ||
log.addHandler(logging.NullHandler()) | ||
|
||
|
||
class LakeShoreTemperatureChannel(Channel): | ||
""" Temperature input channel on a lakeshore temperature monitor. Reads the temperature in | ||
kelvin, celcius, or sensor units. Also provides a method to block the program until a given | ||
stable temperature is reached. | ||
""" | ||
|
||
kelvin = Instrument.measurement( | ||
'KRDG? {ch}', | ||
"""Read the temperature in kelvin from a channel.""" | ||
) | ||
celcius = Instrument.measurement( | ||
'CRDG? {ch}', | ||
"""Read the temperature in celcius from a channel.""" | ||
) | ||
sensor = Instrument.measurement( | ||
'SRDG? {ch}', | ||
"""Read the temperature in sensor units from a channel.""" | ||
) | ||
|
||
def wait_for_temperature(self, target, unit='kelvin', accuracy=0.1, | ||
interval=1, timeout=360, | ||
should_stop=lambda: False): | ||
""" Blocks the program, waiting for the temperature to reach the target | ||
within the accuracy (%), checking this each interval time in seconds. | ||
:param target: Target temperature in kelvin, celcius, or sensor units. | ||
:param unit: 'kelvin', 'celcius', or 'sensor' specifying the unit | ||
for queried temperature values. | ||
:param accuracy: An acceptable percentage deviation between the | ||
target and temperature. | ||
:param interval: Interval time in seconds between queries. | ||
:param timeout: A timeout in seconds after which an exception is raised | ||
:param should_stop: A function that returns True if waiting should stop, by | ||
default this always returns False | ||
""" | ||
abs_tolerance = target * (accuracy / 100) | ||
target_reached = False | ||
t = time() | ||
while not target_reached: | ||
reading = np.array([getattr(self, unit)]) | ||
target_reached = np.allclose(reading, target, atol=abs_tolerance) | ||
sleep(interval) | ||
if (time() - t) > timeout: | ||
raise Exception(( | ||
"Timeout occurred after waiting %g seconds for " | ||
"the LakeShore 331 temperature to reach %g %s." | ||
) % (timeout, target, unit)) | ||
if should_stop(): | ||
return | ||
|
||
|
||
class LakeShoreHeaterChannel(Channel): | ||
""" Heater output channel on a lakeshore temperature controller. Provides properties to query | ||
the output power in percent of the max, set the manual output power, heater range, and PID | ||
temperature setpoint. | ||
""" | ||
|
||
output = Instrument.measurement( | ||
'HTR? {ch}', | ||
"""Query the heater output in percent of the max.""" | ||
) | ||
mout = Instrument.control( | ||
'MOUT? {ch}', | ||
'MOUT {ch},%f', | ||
"""Manual heater output in percent.""" | ||
) | ||
range = Instrument.control( | ||
'RANGE? {ch}', | ||
'RANGE {ch},%i', | ||
"""String property controlling heater range, which can take the | ||
values: off, low, medium, and high.""", | ||
validator=strict_discrete_set, | ||
values={'off': 0, 'low': 1, 'medium': 2, 'high': 3}, | ||
map_values=True) | ||
setpoint = Instrument.control( | ||
'SETP? {ch}', 'SETP {ch},%f', | ||
"""A floating point property that control the setpoint temperature | ||
in the preferred units of the control loop sensor.""" | ||
) |