Lakeshore 370

The Lakeshore 370 (LS370) units are an older version of the Lakshore 372, used for 100 mK and 1K thermometer readout. Basic functionality to interface and control an LS370 is provided by the socs.Lakeshore.Lakeshore370.py module.

usage: python3 agent.py [-h] [--port PORT] [--serial-number SERIAL_NUMBER]
                        [--mode MODE] [--fake-data FAKE_DATA]
                        [--dwell-time-delay DWELL_TIME_DELAY]
                        [--auto-acquire AUTO_ACQUIRE]

Agent Options

--port

Full path to USB node for the lakeshore, e.g. “/dev/ttyUSB0”

--serial-number
--mode
--fake-data

Set non-zero to fake data, without hardware.

Default: 0

--dwell-time-delay

Amount of time, in seconds, to delay data collection after switching channels. Note this time should not include the change pause time, which is automatically accounted for. Will automatically be reduced to dwell_time - 1 second if it is set longer than a channel’s dwell time. This ensures at least one second of data collection at the end of a scan.

Default: 0

--auto-acquire

Automatically start data acquisition on startup

Default: True

Configuration File Examples

OCS Site Config

To configure your Lakeshore 370 for use with OCS you need to add a Lakeshore370Agent block to your ocs configuration file. Here is an example configuration block:

{'agent-class': 'Lakeshore370Agent',
 'instance-id': 'LSA22YG',
 'arguments': [['--serial-number', 'LSA22YG'],
               ['--port', '/dev/ttyUSB1'],
               ['--dwell-time-delay', 0]]},

Each device requires configuration under ‘agent-instances’. See the OCS site configs documentation for more details.

Docker Compose

The Lakeshore 370 Agent should be configured to run in a Docker container. An example configuration is:

ocs-LSA22YG:
  image: simonsobs/socs:latest
  hostname: ocs-docker
  environment:
    - INSTANCE_ID=LSA22YG
  volumes:
    - ${OCS_CONFIG_DIR}:/config:ro
  devices:
    - "/dev/ttyUSB1:/dev/ttyUSB1"

Note

The serial numbers here will need to be updated for your device.

Note

The device path may differ on your machine, and if only using the ttyUSB value as shown here, is not guaranteed to be static.

Description

Direct Communication

Direct communication with the Lakeshore can be achieved without OCS, using the Lakeshore370.py module in socs/socs/Lakeshore/. From that directory, you can run a script like:

from Lakeshore370 import LS370

ls = LS370('/dev/ttyUSB1')

You can use the API detailed on this page to then interact with the Lakeshore. Each Channel is given a Channel object in ls.channels. You can query the resistance measured on the currently active channel with:

ls.get_active_channel().get_resistance_reading()

That should get you started with direct communication. The API is fairly full featured. For any feature requests for functionality that might be missing, please file a Github issue.

Agent API

class socs.agents.lakeshore370.agent.LS370_Agent(agent, name, port, fake_data=False, dwell_time_delay=0)[source]

Agent to connect to a single Lakeshore 370 device.

Parameters:
  • name (ApplicationSession) – ApplicationSession for the Agent.

  • port (str) – Serial port for the 370 device, e.g. ‘/dev/ttyUSB2’

  • fake_data (bool, optional) – generates random numbers without connecting to LS if True.

  • dwell_time_delay (int, optional) – Amount of time, in seconds, to delay data collection after switching channels. Note this time should not include the change pause time, which is automatically accounted for. Will automatically be reduced to dwell_time - 1 second if it is set longer than a channel’s dwell time. This ensures at least one second of data collection at the end of a scan.

init_lakeshore(auto_acquire=False, force=False)[source]

Task - Perform first time setup of the Lakeshore 370 communication.

Parameters:
  • auto_acquire (bool, optional) – Default is False. Starts data acquisition after initialization if True.

  • force (bool, optional) – Force re-initialize the lakeshore if True.

acq()[source]

Process - Run data acquisition.

set_heater_range(range, heater='sample', wait=0)[source]

Task - Adjust the heater range for servoing cryostat. Wait for a specified amount of time after the change.

Parameters:
  • heater (str) – Name of heater to set range for, ‘sample’ by default (and the only implemented option.)

  • range (str, float) – see arguments in socs.Lakeshore.Lakeshore370.Heater.set_heater_range()

  • wait (float, optional) – Amount of time to wait after setting the heater range. This allows the servo time to adjust to the new range.

set_excitation_mode(channel, mode)[source]

Task - Set the excitation mode of a specified channel.

Parameters:
  • channel (int) – Channel to set the excitation mode for. Valid values are 1-16.

  • mode (str) – Excitation mode. Possible modes are ‘current’ or ‘voltage’.

set_excitation(channel, value)[source]

Task - Set the excitation voltage/current value of a specified channel.

Parameters:
set_pid(P, I, D)[source]

Task - Set the PID parameters for servo control of fridge.

Parameters:
  • P (int) – Proportional term for PID loop

  • I (int) – Integral term for the PID loop

  • D (int) – Derivative term for the PID loop

Notes

Makes a call to socs.Lakeshore.Lakeshore370.Heater.set_pid().

set_active_channel(channel)[source]

Task - Set the active channel on the LS370.

Parameters:

channel (int) – Channel to switch readout to. Valid values are 1-16.

set_autoscan(autoscan)[source]

Task - Sets autoscan on the LS370.

Parameters:

autoscan (bool) – True to enable autoscan, False to disable.

servo_to_temperature(temperature, channel=None)[source]

Task - Servo to a given temperature using a closed loop PID on a fixed channel. This will automatically disable autoscan if enabled.

Parameters:
  • temperature (float) – Temperature to servo to in units of Kelvin.

  • channel (int, optional) – Channel to servo off of.

check_temperature_stability(measurements, threshold)[source]

Check servo temperature stability is within threshold.

Parameters:
  • measurements (int) – number of measurements to average for stability check

  • threshold (float) – amount within which the average needs to be to the setpoint for stability

set_output_mode(heater, mode)[source]

Task - Set output mode of the heater.

Parameters:
  • heater (str) – Name of heater to set range for, either ‘sample’ or ‘still’.

  • mode (str) – Specifies mode of heater. Can be “Off”, “Monitor Out”, “Open Loop”, “Zone”, “Still”, “Closed Loop”, or “Warm up”

set_heater_output(heater, output, display=None)[source]

Task - Set display type and output of the heater.

Parameters:
  • heater (str) – Name of heater to set range for, either ‘sample’ or ‘still’.

  • output (float) – Specifies heater output value. For possible values see socs.Lakeshore.Lakeshore370.Heater.set_heater_output()

  • display (str, optional) – Specifies heater display type. Can be “current” or “power”. If None, heater display is not reset before setting output.

get_channel_attribute(attribute, channel=1)[source]

Task - Gets an arbitrary channel attribute, stored in the session.data dict.

Parameters:
  • attribute (str, optional) – Attribute to get from the 370.

  • channel (int, optional) – Channel to get the attribute for.

Notes

Channel attributes stored in the session.data object are in the structure:

>>> response.session['data']
{"calibration_curve": 21,
 "dwell": 3,
 "excitation": 6.32e-6,
 "excitation_mode": "voltage",
 "excitation_power": 2.0e-15,
 "kelvin_reading": 100.0e-3,
 "pause": 3,
 "reading_status": ["T.UNDER"]
 "resistance_range": 2.0e-3,
 "resistance_reading": 10.0e3,
 "temperature_coefficient": "negative",
}

Only attribute called with this method will be populated for the given channel. This example shows all available attributes.

get_heater_attribute(attribute)[source]

Task - Gets an arbitrary heater attribute, stored in the session.data dict.

Parameters:

attribute (str) – Heater attribute to get.

Notes

Heater attributes stored in the session.data object are in the structure:

>>> response.session['data']
{"heater_range": 1e-3,
 "heater_setup": ["current", 1e-3, 120],
 "input_channel": 6,
 "manual_out": 0.0,
 "mode": "Closed Loop",
 "pid": (80, 10, 0),
 "setpoint": 100e-3,
 "still_output", 10.607,
 "units": "kelvin",
}

Only the attribute called with this method will be populated, this example just shows all available attributes.

Supporting APIs

For the API all methods should start with one of the following:

  • set - set a parameter of arbitary input (i.e. set_excitation)

  • get - get the status of a parameter (i.e. get_excitation)

  • enable - enable a boolean parameter (i.e. enable_autoscan)

  • disable - disbale a boolean parameter (i.e. disable_channel)

class socs.Lakeshore.Lakeshore370.LS370(port, baudrate=9600, timeout=10, num_channels=16)[source]

Lakeshore 370 class.

channels - list of channels, index corresponds to channel number with

index 0 corresponding to channel 1

msg(message)[source]

Send message to the Lakeshore 370 over RS-232.

If we’re asking for something from the Lakeshore (indicated by a ? in the message string), then we will attempt to ask twice before giving up due to potential communication timeouts.

Parameters:

message (str) – Message string as described in the Lakeshore 370 manual.

Returns:

Response string from the Lakeshore, if any. Else, an empty string.

Return type:

str

get_id()[source]

Get the ID number of the Lakeshore unit.

get_temp(unit='kelvin', chan=-1)[source]

Get temperature from the Lakeshore.

Parameters:
  • unit (str) – Unit to return reading for (‘ohms’ or ‘kelvin’)

  • chan (int) – Channel to query, -1 for currently active channel

Returns:

The reading from the lakeshore, either in ohms or kelvin.

Return type:

float

get_autoscan()[source]

Determine state of autoscan.

Returns:

state of autoscanner

Return type:

bool

enable_autoscan()[source]

Enable the autoscan feature of the Lakeshore 370.

Will query active channel to pass already selected channel to SCAN command.

disable_autoscan()[source]

Disable the autoscan feature of the Lakeshore 370.

Will query active channel to pass already selected channel to SCAN command.

chan_num2channel(channel_number)[source]

Return a Channel Object from LS370.channels by associated Channel number

Parameters:

channel_number – Number associated with Channel to be returned

Returns:

Channel Object corresponding to channel_number

Return type:

Channel Object:

get_active_channel()[source]

Query the Lakeshore for which channel it’s currently scanning.

Returns:

channel object describing the scanned channel

Return type:

Channel Object

set_active_channel(channel)[source]

Set the active scanner channel.

Query using SCAN? to determine autoscan parameter and set active channel.

Parameters:

channel (int) – Channel number to switch scanner to. 1-8 or 1-16 depending on scanner type

class socs.Lakeshore.Lakeshore370.Channel(ls, channel_num)[source]

Lakeshore 370 Channel Object

Parameters:
  • ls (LS370 Object) – Lakeshore unit for communication

  • channel_num (int) – The channel number (1-8 or 1-16 depending on scanner type)

get_excitation_mode()[source]

Get the excitation mode form RDGRNG?

Returns:

excitation mode, ‘current’ or ‘voltage’

Return type:

str

set_excitation_mode(excitation_mode)[source]

Set the excitation mode to either voltage excitation or current exitation.

Parameters:

excitation_mode (str) – mode we want, must be ‘current’ or ‘voltage’

Returns:

reply from RDGRNG call

Return type:

str

get_excitation()[source]

Get excitation value from RDGRNG?

Returns:

excitation value in volts or amps, depending on mode

Return type:

float

set_excitation(excitation_value)[source]

Set voltage/current exitation to specified value via RDGRNG command.

Parameters:

excitation_value (float) – value in volts/amps of excitation

Returns:

response from RDGRNG command

Return type:

str

enable_autorange()[source]

Enable auto range for channel via RDGRNG command.

disable_autorange()[source]

Disable auto range for channel via RDGRNG command.

set_resistance_range(resistance_range)[source]

Set the resistance range.

Parameters:

resistance_range (float) – range in ohms we want to measure. Doesn’t need to be exactly one of the options on the lakeshore, will select closest valid range, though note these are in increments of 2, 6.32, 20, 63.2, etc.

Returns:

response from RDGRNG command

Return type:

str

get_resistance_range()[source]

Get the resistance range.

Returns:

resistance range in Ohms

Return type:

float

enable_excitation()[source]

Enable excitation by not shunting the current source via RDGRNG command.

Returns:

state of excitation

Return type:

str

disable_excitation()[source]

Disable excitation by shunting the current source via RDGRNG command.

Returns:

state of excitation

Return type:

str

get_excitation_power()[source]

Get the most recent power calculation for the channel via RDGPWR? command.

Returns:

power in Watts

Return type:

float

enable_channel()[source]

Enable channel using INSET command.

Returns:

response from self._set_input_channel_parameter()

Return type:

str

disable_channel()[source]

Disable channel using INSET command.

Returns:

response from self._set_input_channel_parameter()

Return type:

str

set_dwell(dwell)[source]

Set the autoscanning dwell time.

Parameters:

dwell (int) – Dwell time in seconds

Returns:

response from self._set_input_channel_parameter()

Return type:

str

get_dwell()[source]

Get the autoscanning dwell time.

Returns:

the dwell time in seconds

Return type:

int

set_pause(pause)[source]

Set pause time.

Parameters:

pause (int) – Pause time in seconds

Returns:

response from self._set_input_channel_parameter()

Return type:

str

get_pause()[source]

Get the pause time from INSET.

Returns:

the pause time in seconds

Return type:

int

set_calibration_curve(curve_number)[source]

Set calibration curve using INSET.

Note: If curve doesn’t exist, curve number gets set to 0.

Parameters:

curve_number (int) – Curve number for temperature conversion

get_calibration_curve()[source]

Get calibration curve number using INSET?

Returns:

curve number in use for the channel

Return type:

int

set_temperature_coefficient(coefficient)[source]

Set tempertaure coefficient with INSET.

Parameters:

coefficient (str) – set coefficient to be used for temperature control if no curve is selected, either ‘negative’ or ‘positive’

Returns:

response from _set_input_channel_parameter()

Return type:

str

get_temperature_coefficient()[source]

Get temperature coefficient from INSET?

Returns:

temperature coefficient

get_kelvin_reading()[source]

Get temperature reading from channel.

Returns:

temperature from channel in Kelvin

Return type:

float

get_resistance_reading()[source]

Get resistence reading from channel.

Returns:

resistance from channel in Ohms

Return type:

float

get_reading_status()[source]

Get status of input reading.

Returns:

list of errors on reading (or None if no errors)

Return type:

list of str

class socs.Lakeshore.Lakeshore370.Curve(ls, curve_num)[source]

Calibration Curve class for the LS370.

get_header()[source]

Get curve header description.

Returns:

response from CRVHDR? in list

Return type:

list of str

get_name()[source]

Get the curve name with the CRVHDR? command.

Returns:

The curve name

Return type:

str

set_name(name)[source]

Set the curve name with the CRVHDR command.

Parameters:

name (str) – The curve name, limit of 15 characters, longer names get truncated

Returns:

the response from the CRVHDR command

Return type:

str

get_serial_number()[source]

Get the curve serial number with the CRVHDR? command.”

Returns:

The curve serial number

Return type:

str

set_serial_number(serial_number)[source]

Set the curve serial number with the CRVHDR command.

Parameters:

serial_number – The curve serial number, limit of 10 characters, longer serials get truncated

Returns:

the response from the CRVHDR command

Return type:

str

get_format()[source]

Get the curve data format with the CRVHDR? command.”

Returns:

The curve data format

Return type:

str

set_format(_format)[source]

Set the curve format with the CRVHDR command.

Parameters:

_format – The curve format, valid formats are: “Ohm/K (linear)” “log Ohm/K (linear)” “Ohm/K (cubic spline)”

Returns:

the response from the CRVHDR command

Return type:

str

get_limit()[source]

Get the curve temperature limit with the CRVHDR? command.

Returns:

The curve temperature limit

Return type:

str

set_limit(limit)[source]

Set the curve temperature limit with the CRVHDR command.

Parameters:

limit (float) – The curve temperature limit

Returns:

the response from the CRVHDR command

Return type:

str

get_coefficient()[source]

Get the curve temperature coefficient with the CRVHDR? command.

Returns:

The curve temperature coefficient

Return type:

str

set_coefficient(coefficient)[source]

Set the curve temperature coefficient with the CRVHDR command.

Parameters:

coefficient – The curve temperature coefficient, either ‘positive’ or ‘negative’

Returns:

the response from the CRVHDR command

Return type:

str

get_data_point(index)[source]

Get a single data point from a curve, given the index, using the CRVPT? command.

The format for the return value, a 2-tuple of floats, is chosen to work with how the get_curve() method later stores the entire curve in a numpy structured array.

Parameters:

index (int) – index of breakpoint to query

Returns:

(units, temperature) values for the given breakpoint

Return type:

3-tuple of floats

get_curve(_file=None)[source]

Get a calibration curve from the LS370.

If _file is not None, save to file location.

Parameters:

_file (str) – the file to load the calibration curve from

set_curve(_file)[source]

Set a calibration curve, loading it from the file.

Parameters:

_file (str) – the file to load the calibration curve from

Returns:

return the new curve header, refreshing the attributes

Return type:

list of str

delete_curve()[source]

Delete the curve using the CRVDEL command.

Returns:

the response from the CRVDEL command

Return type:

str

class socs.Lakeshore.Lakeshore370.Heater(ls)[source]

Heater class for LS370 control

Parameters:

ls (Lakeshore370.LS370) – the lakeshore object we’re controlling

get_heater_setup()[source]

Gets Heater setup params with the CSET? command.

Return resp:

List of values that have been returned from the Lakeshore.

get_mode()[source]

Set output mode with CMODE? commnd.

Returns:

The output mode

Return type:

str

set_mode(mode)[source]

Set output mode with CMODE commnd.

Parameters:

mode (str) – control mode for heater, see page 6-24 pf Lakeshore 370 manual

Returns:

the response from the OUTMODE command

get_input_channel()[source]

Get the control channel with the CSET? command.

Returns:

The control channel

Return type:

str

set_input_channel(_input)[source]

Set the control channel with the CSET command.

Parameters:

_input (str or int) – specifies which input or channel to control from

set_powerup(powerup)[source]
Parameters:

powerup (bool) – specifies whether the output remains on or shuts off after power cycle. True for on after powerup

set_polarity()[source]
Parameters:

polarity (str) – specifies output polarity: ‘unipolar’ or ‘bipolar’

set_filter(_filter)[source]
Parameters:

_filter (bool) – specifies controlling on unfiltered or filtered readings, True = filtered, False = unfiltered

get_units()[source]

Get the setpoint units with the CSET? command.

Returns:

units, either ‘kelvin’ or ‘ohms’

Return type:

str

set_units(units)[source]

Set the setpoint units with the CSET command.

Parameters:

units (str) – units, either ‘kelvin’ or ‘ohms’

set_delay(delay)[source]
Parameters:

delay (int) – delay in seconds for setpoint change during autoscanning, 1-255 seconds

set_heater_display(display)[source]
Parameters:

display (string) – Display mode for heater. Can either be ‘current’ or ‘power’.

set_heater_output(output, display_type=None)[source]

Set heater output with MOUT command.

Parameters:
  • output (float) – heater output value. If display is ‘power’, value should be in Watts. If ‘current’, value should be in percent.

  • display_type (string) – Display type if you want to set this before setting heater. Can be ‘power’ or ‘current’.

Returns:

heater output

Return type:

float

set_heater_range(_range)[source]

Set heater range with HTRRNG command.

Parameters:

_range (float or str (for "On" "Off")) – heater range

Returns:

heater range in amps

Return type:

float

get_heater_range()[source]

Get heater range with HTRRNG? command.

Returns:

heater range in amps

Return type:

float

set_pid(p, i, d)[source]

Set PID parameters for closed loop control.

Params p:

proportional term in PID loop

Params i:

integral term in PID loop

Params d:

derivative term in PID loop

Returns:

response from PID command

Return type:

str

get_pid()[source]

Get PID parameters with PID? command.

Returns:

p, i, d

Return type:

float, float, float