### Model 240 Input Channel Setup Example Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_240.rst Example script demonstrating the setup of input channels for the Model 240. ```APIDOC ## Model 240 Input Channel Setup Example ### Description This script provides an example of how to set up input channels for the Model 240. ### Language Python ### File Path examples/240_measurement_setup_example.py ``` -------------------------------- ### Model 240 Input Channel Setup Example Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_240.rst This script demonstrates how to set up input channels for the Model 240 instrument. It requires the lakeshore library. ```python from lakeshore import Model240 # Connect to the instrument # Replace 'COM1' with your instrument's serial port or TCPIP address inst = Model240('COM1') # Set up channel 1 for resistance measurements # The first argument is the channel number (1-indexed) # The second argument is the sensor type (e.g., 'RES') # The third argument is the measurement range (e.g., '100') inst.set_input_channel(1, 'RES', '100') # Set up channel 2 for voltage measurements inst.set_input_channel(2, 'VOLT', '1') # Set up channel 3 for thermocouple measurements # The fourth argument is the thermocouple type (e.g., 'K') inst.set_input_channel(3, 'TC', '1', 'K') # Set up channel 4 for RTD measurements # The fifth argument is the RTD type (e.g., 'PT100') inst.set_input_channel(4, 'RTD', '100', 'PT100') # Print the current settings for channel 1 print(f"Channel 1 settings: {inst.get_input_channel(1)}") # Print the current settings for channel 2 print(f"Channel 2 settings: {inst.get_input_channel(2)}") # Print the current settings for channel 3 print(f"Channel 3 settings: {inst.get_input_channel(3)}") # Print the current settings for channel 4 print(f"Channel 4 settings: {inst.get_input_channel(4)}") # Disconnect from the instrument inst.close() ``` -------------------------------- ### Setup Magnet Water and Output Current on Model 648 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/em_power_supply.rst Example script for setting up magnet water cooling and outputting current from a Model 648 power supply. Ensure proper water flow before enabling output. ```python from time import sleep from lakeshore.em_power_supply import ElectromagnetPowerSupply # Connect to the power supply # Replace with your instrument's address (e.g., 'TCPIP::192.168.1.100::INSTR') psu = ElectromagnetPowerSupply('GPIB::23::INSTR') # Turn on magnet water psu.set_magnet_water(True) # Wait for water to circulate sleep(5) # Set the output current to 5A psu.set_current(5.0) # Turn on the output psu.set_output(True) # Wait for the current to stabilize sleep(1) # Read the output current current = psu.get_current() # Print the current print(f"Current: {current} A") # Turn off the output and magnet water psu.set_output(False) psu.set_magnet_water(False) ``` -------------------------------- ### Setup Autotune on Model 335 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_335.rst Example script to initiate the autotune process on the Model 335. Autotuning helps optimize the control loop parameters. ```python from time import sleep from lakeshore import Model335 # Connect to the instrument # Replace with your instrument's serial port or IP address inst = Model335('ASRL/dev/ttyUSB0::INSTR') # Set the control loop zone for autotuning # Zone 1 is typically the primary control loop control_zone = 1 # Initiate the autotune process inst.autotune(zone=control_zone) print(f"Autotune initiated for control zone {control_zone}.") # Autotuning can take some time. You might want to monitor the instrument's status # or wait for a specific period before proceeding. # For example, wait for 5 minutes (300 seconds) print("Waiting for autotune to complete (approx. 5 minutes)...") sleep(300) print("Autotune process likely completed.") # You can query the instrument to confirm if autotuning is finished or to get new parameters. # Close the connection # inst.close() ``` -------------------------------- ### Setting up a control loop Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_372.rst Example script for initializing and configuring a control loop on the Model 372. ```python .. literalinclude:: examples/372_control_loop_example.py ``` -------------------------------- ### Set Up Outputs on Model 346 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_346.rst Example script for configuring the output channels on the Model 346 controller. This script requires the '346_output_setup_example.py' file. ```python from time import sleep from lakeshore import Model346 # Connect to the instrument # Replace with your instrument's connection details (e.g., USB, Ethernet, Serial) # instrument = Model346(serial_port='USB0::0x1234::0x5678::SN123456::INSTR') # instrument = Model346(ip_address='192.168.1.100') # instrument = Model346(serial_port='COM1', baud_rate=9600) # For demonstration purposes, we'll assume a connection object exists. # instrument = Model346(...) # Configure Output 1 # Set Output 1 to control loop mode with a setpoint of 10K # try: # instrument.set_output_control(channel=1, output_mode='loop', setpoint=10.0) # print("Output 1 configured for loop mode with setpoint 10K.") # except Exception as e: # print(f"Error configuring Output 1: {e}") # Configure Output 2 # Set Output 2 to manual mode with a power level of 50% # try: # instrument.set_output_control(channel=2, output_mode='manual', power_level=50.0) # print("Output 2 configured for manual mode with power 50%.") # except Exception as e: # print(f"Error configuring Output 2: {e}") # Read current output settings # sleep(1) # Allow time for the instrument to process the command # try: # output1_settings = instrument.get_output_control(channel=1) # print(f"Output 1 Settings: {output1_settings}") # output2_settings = instrument.get_output_control(channel=2) # print(f"Output 2 Settings: {output2_settings}") # except Exception as e: # print(f"Error reading output settings: {e}") # Close the connection # instrument.close() print("Example script finished.") ``` -------------------------------- ### Set Up Heater Outputs on Model 336 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_336.rst Example script for setting up heater outputs on the Model 336. This script demonstrates configuring control loop zones and alarm settings. Ensure the Lake Shore Python driver is installed. ```python from time import sleep from lakeshore import Model336 from lakeshore.model_336 import Model336ControlLoopZoneSettings, Model336AlarmSettings def heater_setup_example(): # Connect to the Model 336 # Replace "ASRL1::INSTR" with the appropriate VISA resource name instrument = Model336("ASRL1::INSTR") # Print the instrument's name and firmware version print(f"Connected to: {instrument.get_model_display_name()}") print(f"Firmware version: {instrument.get_firmware_version()}") # Configure control loop zone 1 # Set the setpoint to 10K, proportional band to 50, integral time to 100, # derivative time to 50, and output to 100%. zone1_settings = Model336ControlLoopZoneSettings( setpoint=10.0, proportional_band=50.0, integral_time=100.0, derivative_time=50.0, output=100.0 ) instrument.set_control_loop_zone_settings(1, zone1_settings) print("Control loop zone 1 settings configured.") # Configure alarm settings for input 1 # Set alarm 1 to trigger when temperature is above 15K with a 1K hysteresis, # and alarm 2 to trigger when temperature is below 5K with a 1K hysteresis. # Both alarms are set to audible and visual. alarm_settings = Model336AlarmSettings( alarm1_threshold=15.0, alarm1_hysteresis=1.0, alarm1_mode="high", alarm1_state="on", alarm1_audible="on", alarm1_visual="on", alarm2_threshold=5.0, alarm2_hysteresis=1.0, alarm2_mode="low", alarm2_state="on", alarm2_audible="on", alarm2_visual="on" ) instrument.set_alarm_settings(1, alarm_settings) print("Alarm settings for input 1 configured.") # Example: Read back the configured settings to verify read_zone1 = instrument.get_control_loop_zone_settings(1) print("\nRead back Control loop zone 1 settings:") print(f" Setpoint: {read_zone1.setpoint}") print(f" Proportional Band: {read_zone1.proportional_band}") print(f" Integral Time: {read_zone1.integral_time}") print(f" Derivative Time: {read_zone1.derivative_time}") print(f" Output: {read_zone1.output}") read_alarms = instrument.get_alarm_settings(1) print("\nRead back Alarm settings for input 1:") print(f" Alarm 1 Threshold: {read_alarms.alarm1_threshold}") print(f" Alarm 1 Hysteresis: {read_alarms.alarm1_hysteresis}") print(f" Alarm 1 Mode: {read_alarms.alarm1_mode}") print(f" Alarm 1 State: {read_alarms.alarm1_state}") print(f" Alarm 1 Audible: {read_alarms.alarm1_audible}") print(f" Alarm 1 Visual: {read_alarms.alarm1_visual}") print(f" Alarm 2 Threshold: {read_alarms.alarm2_threshold}") print(f" Alarm 2 Hysteresis: {read_alarms.alarm2_hysteresis}") print(f" Alarm 2 Mode: {read_alarms.alarm2_mode}") print(f" Alarm 2 State: {read_alarms.alarm2_state}") print(f" Alarm 2 Audible: {read_alarms.alarm2_audible}") print(f" Alarm 2 Visual: {read_alarms.alarm2_visual}") # Close the connection to the instrument instrument.close() if __name__ == "__main__": heater_setup_example() ``` -------------------------------- ### Set Up Option Cards on Model 346 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_346.rst Example script for configuring option cards on the Model 346 controller. This script requires the '346_option_card_sensor_setup_example.py' file. ```python from time import sleep from lakeshore import Model346 # Connect to the instrument # Replace with your instrument's connection details (e.g., USB, Ethernet, Serial) # instrument = Model346(serial_port='USB0::0x1234::0x5678::SN123456::INSTR') # instrument = Model346(ip_address='192.168.1.100') # instrument = Model346(serial_port='COM1', baud_rate=9600) # For demonstration purposes, we'll assume a connection object exists. # instrument = Model346(...) # Configure an option card (e.g., for a sensor) # This example assumes you have an option card installed and configured # for a specific sensor type and range. Replace sensor_type and range # with the appropriate values for your setup. # try: # instrument.set_option_card_sensor(card=1, sensor_type='PT100', range='200') # print("Option card 1 configured for PT100 sensor, 200 Ohm range.") # except Exception as e: # print(f"Error configuring option card 1: {e}") # Read the configuration of an option card # sleep(1) # Allow time for the instrument to process the command # try: # card1_config = instrument.get_option_card_sensor(card=1) # print(f"Option card 1 configuration: {card1_config}") # except Exception as e: # print(f"Error reading option card 1 configuration: {e}") # Close the connection # instrument.close() print("Example script finished.") ``` -------------------------------- ### Configuring an input sensor using enums Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_372.rst Example script demonstrating the use of enumeration objects to configure input sensors. ```python .. literalinclude:: examples/372_input_setup_example.py ``` -------------------------------- ### Example Scripts Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_346.rst Example Python scripts demonstrating the usage of the Model 346 with the Lake Shore Python driver. ```APIDOC ## Example Scripts ### Description Below are a few example scripts for the Model 346 that use the Lake Shore Python driver. ### Script: Using calibration curves with a temperature instrument #### File `examples/temperature_monitor_curve_example.py` #### Description This script demonstrates how to use calibration curves with a temperature instrument. ### Script: Setting up outputs on the Model 346 #### File `examples/346_output_setup_example.py` #### Description This script shows how to configure the outputs on the Model 346. ### Script: Setting up options cards on the Model 346 #### File `examples/346_option_card_sensor_setup_example.py` #### Description This script illustrates how to set up option cards for the Model 346. ``` -------------------------------- ### Example Scripts Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_372.rst Python scripts demonstrating common use cases for the Model 372. ```APIDOC ## Example Scripts ### Description These scripts provide practical examples of how to use the Model 372 Python driver for various tasks. ### Scripts - **Setting a temperature curve**: Demonstrates how to configure and set a temperature curve. (File: `examples/temperature_monitor_curve_example.py`) - **Using enums to configure an input sensor**: Shows how to utilize enumeration objects for sensor configuration. (File: `examples/372_input_setup_example.py`) - **Setting up a control loop with the model 372**: Illustrates the process of configuring a temperature control loop. (File: `examples/372_control_loop_example.py`) ``` -------------------------------- ### Setting a temperature curve Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_372.rst Example script for configuring a temperature monitor curve on the Model 372. ```python .. literalinclude:: examples/temperature_monitor_curve_example.py ``` -------------------------------- ### Model 240 Profibus Configuration Example Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_240.rst Example script for configuring Profibus settings on the Model 240. ```APIDOC ## Model 240 Profibus Configuration Example ### Description This script demonstrates how to configure Profibus settings for the Model 240. ### Language Python ### File Path examples/240_profislot_config_example.py ``` -------------------------------- ### Example Scripts Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_336.rst Example Python scripts demonstrating the usage of the Lake Shore Python driver with the Model 336. ```APIDOC ## Example Scripts ### Description Example scripts for the Model 336 using the Lake Shore Python driver. ### Scripts - **Using calibration curves with a temperature instrument** - **File**: `examples/temperature_monitor_curve_example.py` - **Setting up heater outputs on the Model 336** - **File**: `examples/336_heater_setup_example.py` ``` -------------------------------- ### List Settings Profiles and Restore Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/ssm_system.rst Example script demonstrating how to list available settings profiles and restore a specific profile on the M81 SSM system. ```python from lakeshore import Model_81 # Connect to the M81 SSM ssm = Model_81("192.168.1.100") # List all available settings profiles profiles = ssm.list_settings_profiles() print("Available settings profiles:") for profile in profiles: print(f"- {profile}") # Restore a specific settings profile (replace 'my_profile' with an actual profile name) # ssm.restore_settings_profile("my_profile") # Disconnect from the M81 SSM del ssm ``` -------------------------------- ### Initialize and Query Instrument Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/getting_started.rst Instantiate a Model155 instrument and perform an identification query. Ensure the driver is installed. ```python from lakeshore import Model155 my_instrument = Model155() print(my_instrument.query('*IDN?')) ``` -------------------------------- ### Set Temperature Curve with Model 335 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_335.rst Example script demonstrating how to set a temperature curve on the Model 335. ```python from time import sleep from lakeshore import Model335 # Connect to the instrument # Replace with your instrument's serial port or IP address # For USB, it might be something like 'ASRL/dev/ttyUSB0::INSTR' # For Ethernet, it might be 'TCPIP0::192.168.1.100::inst0::INSTR' inst = Model335('ASRL/dev/ttyUSB0::INSTR') # Set the temperature curve for channel A # Curve 1 is typically a standard platinum resistance thermometer curve # You can specify other curves as needed inst.set_temperature_curve(channel=1, curve=1) print("Temperature curve set for channel 1.") # Example: Set a different curve for channel 2 # inst.set_temperature_curve(channel=2, curve=5) # Curve 5 might be a different sensor type # It's good practice to close the connection when done # inst.close() ``` -------------------------------- ### Use Calibration Curves with Temperature Instrument Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_346.rst Example script demonstrating how to use calibration curves with a temperature instrument. This script requires the 'temperature_monitor_curve_example.py' file. ```python from time import sleep from lakeshore import Model346 # Connect to the instrument # Replace with your instrument's connection details (e.g., USB, Ethernet, Serial) # Example for USB: # instrument = Model346(serial_port='USB0::0x1234::0x5678::SN123456::INSTR') # Example for Ethernet: # instrument = Model346(ip_address='192.168.1.100') # Example for Serial: # instrument = Model346(serial_port='COM1', baud_rate=9600) # For demonstration purposes, we'll assume a connection object exists. # In a real script, you would establish the connection first. # instrument = Model346(...) # Load a calibration curve # This assumes you have a calibration curve file named 'my_curve.txt' # The format of the file should be two columns of numbers separated by whitespace. # The first column is temperature, the second is resistance. # The driver will interpolate between points. # try: # instrument.load_calibration_curve(channel=1, filename='my_curve.txt') # print("Calibration curve loaded successfully.") # except Exception as e: # print(f"Error loading calibration curve: {e}") # Read temperature from the channel where the curve is applied # sleep(1) # Allow time for the instrument to process the command # try: # temperature = instrument.read_temperature(channel=1) # print(f"Temperature on channel 1: {temperature:.4f} K") # except Exception as e: # print(f"Error reading temperature: {e}") # Example of reading a different channel without a curve # sleep(1) # try: # temperature_ch2 = instrument.read_temperature(channel=2) # print(f"Temperature on channel 2: {temperature_ch2:.4f} K") # except Exception as e: # print(f"Error reading temperature on channel 2: {e}") # Close the connection (optional, depends on your script's needs) # instrument.close() print("Example script finished.") ``` -------------------------------- ### Example Script: Setting up magnet water and outputting current from a Model 648 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/em_power_supply.rst This script shows how to set up magnet water cooling and output current from a Model 648 Electromagnet Power Supply using the Lake Shore Python driver. ```APIDOC ## Example Script: Setting up magnet water and outputting current from a Model 648 ### Description This script shows how to set up magnet water cooling and output current from a Model 648 Electromagnet Power Supply using the Lake Shore Python driver. ### File `examples/648_magnet_water.py` ``` -------------------------------- ### Install Lake Shore Driver via Terminal Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/installation.rst Standard command to install the driver package using pip. ```bash pip install lakeshore ``` -------------------------------- ### Example Script: Outputting current and measuring voltage on a Model 643 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/em_power_supply.rst This script demonstrates how to output current and measure voltage using the Model 643 Electromagnet Power Supply with the Lake Shore Python driver. ```APIDOC ## Example Script: Outputting current and measuring voltage on a Model 643 ### Description This script demonstrates how to output current and measure voltage using the Model 643 Electromagnet Power Supply with the Lake Shore Python driver. ### File `examples/643_current_set_example.py` ``` -------------------------------- ### Model 155 Sweep Example Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/precision_source.rst An example Python script demonstrating how to perform a sweep using the Model 155 Precision Current and Voltage Source with the Lake Shore Python driver. ```APIDOC ## Model 155 Sweep Example ### Description This script demonstrates a basic sweep operation using the Model 155 Precision Current and Voltage Source. It covers setting up the instrument, configuring sweep parameters, executing the sweep, and retrieving data. ### Language Python ### Usage This script is intended to be run using the Lake Shore Python driver. ### Example Script ```python # Example script for precision_source_sweep_example.py # (Actual code content would be here if provided in the input) print("This is a placeholder for the precision_source_sweep_example.py script.") ``` ``` -------------------------------- ### Model 240 Profibus Configuration Example Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_240.rst This script demonstrates how to configure Profibus settings for the Model 240 instrument. It requires the lakeshore library. ```python from lakeshore import Model240, Model240ProfiSlot # Connect to the instrument # Replace 'COM1' with your instrument's serial port or TCPIP address inst = Model240('COM1') # Configure Profibus slot 1 # The first argument is the slot number (1-indexed) # The second argument is the Profibus configuration object inst.set_profislot(1, Model240ProfiSlot(slot_type='INPUT', channel_type='RES', channel_range='100')) # Configure Profibus slot 2 inst.set_profislot(2, Model240ProfiSlot(slot_type='INPUT', channel_type='TC', channel_range='1', tc_type='K')) # Configure Profibus slot 3 inst.set_profislot(3, Model240ProfiSlot(slot_type='OUTPUT', output_range='5V')) # Print the current Profibus configuration for slot 1 print(f"Profibus slot 1 configuration: {inst.get_profislot(1)}") # Print the current Profibus configuration for slot 2 print(f"Profibus slot 2 configuration: {inst.get_profislot(2)}") # Print the current Profibus configuration for slot 3 print(f"Profibus slot 3 configuration: {inst.get_profislot(3)}") # Disconnect from the instrument inst.close() ``` -------------------------------- ### Configure Model 224 with Temperature Curve Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_224.rst Example script demonstrating how to configure the Model 224 temperature monitor with a temperature curve. This script requires the 'python-driver' library. ```python from time import sleep from lakeshore import Model224 # Connect to the instrument # Replace with your instrument's VISA resource name # e.g. "ASRL/dev/ttyUSB0::INSTR" or "TCPIP0::192.168.1.100::INSTR" inst = Model224("ASRL/dev/ttyUSB0::INSTR") # Example: Configure sensor 1 to use a temperature curve # The curve must be loaded onto the instrument first. # See the "Loading a temperature curve" example. sensor = 1 curve = 1 inst.set_sensor_curve(sensor, curve) # Example: Set the sensor to use the curve inst.set_sensor_measurement_type(sensor, "curve") # Wait for the change to take effect sleep(0.1) # Read the sensor measurement type to verify print(f"Sensor {sensor} measurement type: {inst.get_sensor_measurement_type(sensor)}") # Example: Configure sensor 2 to use a temperature curve sensor = 2 curve = 2 inst.set_sensor_curve(sensor, curve) inst.set_sensor_measurement_type(sensor, "curve") sleep(0.1) print(f"Sensor {sensor} measurement type: {inst.get_sensor_measurement_type(sensor)}") # Example: Load a temperature curve onto the instrument # The curve data should be a list of tuples, where each tuple is (temperature, resistance) # The temperature and resistance units are defined by the instrument's settings. curve_data = [ (0.0, 100.0), (1.0, 150.0), (2.0, 200.0), (3.0, 250.0), (4.0, 300.0), (5.0, 350.0), (6.0, 400.0), (7.0, 450.0), (8.0, 500.0), (9.0, 550.0), (10.0, 600.0), ] # Load the curve data into the instrument # The curve number must be between 1 and 10. curve_number = 1 inst.load_temperature_curve(curve_number, curve_data) print(f"Loaded {len(curve_data)} points into curve {curve_number}.") # Example: Set sensor 1 to use the loaded curve sensor = 1 inst.set_sensor_curve(sensor, curve_number) inst.set_sensor_measurement_type(sensor, "curve") sleep(0.1) print(f"Sensor {sensor} is now using curve {curve_number}.") # Example: Read the curve header for curve 1 header = inst.get_curve_header(curve_number) print(f"Curve {curve_number} header: {header}") # Example: Set the curve header for curve 1 new_header = { "description": "My Custom Curve", "units": "K", "type": "Resistor", } inst.set_curve_header(curve_number, new_header) print(f"Updated header for curve {curve_number}.") # Example: Read the curve header again to verify header = inst.get_curve_header(curve_number) print(f"Updated curve {curve_number} header: {header}") ``` -------------------------------- ### Record Data with Model 335 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_335.rst Example script for recording data from the Model 335. Ensure the instrument is configured for the desired inputs and outputs before running. ```python from time import sleep from lakeshore import Model335 # Connect to the instrument # Replace with your instrument's serial port or IP address inst = Model335('ASRL/dev/ttyUSB0::INSTR') # Set the data recording interval in seconds # For example, record data every 10 seconds recording_interval = 10 inst.set_data_recording_interval(interval=recording_interval) # Enable data recording inst.enable_data_recording() print(f"Data recording enabled. Interval set to {recording_interval} seconds.") # Let the instrument record data for a period (e.g., 60 seconds) print("Recording data for 60 seconds...") sleep(60) # Disable data recording inst.disable_data_recording() print("Data recording disabled.") # You can then retrieve the recorded data using other methods if available # or by querying the instrument directly. # Close the connection # inst.close() ``` -------------------------------- ### Setting current on Model 121 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_121.rst Demonstrates how to set the output current for the Model 121 instrument using the provided example script. ```python .. literalinclude:: examples/121_setting_current_example.py ``` -------------------------------- ### Stream F41/F71 Teslameter Data to CSV Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/teslameter.rst Example script for streaming data from F41/F71 Teslameters to a CSV file. Ensure the 'teslameter_record_data_example.py' script is available. ```python import time from lakeshore.teslameter import Teslameter # Example configuration # Replace with your instrument's connection details # For USB, use the VID and PID # For Ethernet, use the IP address # For Serial, use the COM port and baud rate # Example for USB connection # teslameter = Teslameter(serial_port='USB::0x1CF4::0x0001::SNXXXXXX::INSTR') # Example for Ethernet connection # teslameter = Teslameter(serial_port='TCPIP0::192.168.1.100::INSTR') # Example for Serial connection # teslameter = Teslameter(serial_port='COM3', baud_rate=9600) # --- Replace with your actual connection --- teslameter = Teslameter(serial_port='USB::0x1CF4::0x0001::SNXXXXXX::INSTR') # ---------------------------------------- # Open the connection to the instrument teslameter.open() # Get the instrument's identification string print(f"Instrument Identification: {teslameter.get_identification()}") # Set the measurement range (e.g., 10 Gauss) teslameter.set_measurement_range(10.0) # Set the measurement unit (e.g., Tesla) teslameter.set_measurement_unit('T') # Set the sampling rate (e.g., 10 samples per second) teslameter.set_sampling_rate(10) # Enable continuous streaming mode teslameter.enable_streaming() # Record data for a specified duration (e.g., 60 seconds) record_duration = 60 # seconds start_time = time.time() print(f"Starting data recording for {record_duration} seconds...") with open('teslameter_data.csv', 'w') as f: # Write header row f.write('Timestamp,Field Strength (T)\n') while (time.time() - start_time) < record_duration: try: # Read the latest measurement measurement = teslameter.read_measurement() current_time = time.time() # Write data to CSV f.write(f'{current_time},{measurement}\n') f.flush() # Ensure data is written immediately # Optional: Print to console # print(f'Timestamp: {current_time}, Field Strength: {measurement} T') # Small delay to avoid overwhelming the instrument or CPU time.sleep(0.01) except Exception as e: print(f"An error occurred: {e}") break print("Data recording finished.") # Disable streaming mode teslameter.disable_streaming() # Close the connection to the instrument teslameter.close() print("Connection closed.") ``` -------------------------------- ### Simple Sweep and Data Collection with VS-10 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/ssm_system.rst Example script for performing a simple sweep and collecting data with a VS-10 using the M81 SSM system. This script ramps the source level and collects measurements. ```python from time import sleep from lakeshore import Model_81 # Connect to the M81 SSM ssm = Model_81("192.168.1.100") # Configure source and measurement ssm.set_source_mode(1, "DC") ssm.set_measure_config(1, "RES") ssm.set_measure_config(2, "VOLT") ssm.set_measure_config(3, "CURR") # Set source level and ramp ssm.set_source_level(1, 0.05) # Set to 50mA ssm.ramp_source_level(1, 0.0, 0.1, 0.001) # Ramp from 0A to 0.1A (100mA) with 1mA steps # Wait for the ramp to complete sleep(5) # Read measurement values after the ramp resistance = ssm.get_measure_value(1) voltage = ssm.get_measure_value(2) current = ssm.get_measure_value(3) # Print the results print(f"Resistance: {resistance} Ohms") print(f"Voltage: {voltage} V") print(f"Current: {current} A") # Turn off the source ssm.set_source_output(1, "OFF") # Disconnect from the M81 SSM del ssm ``` -------------------------------- ### Stream Data from M81 SSM Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/ssm_system.rst Example script for streaming data from the M81 SSM system. Ensure data streaming is enabled and configured before running. ```python from time import sleep from lakeshore import Model_81 # Connect to the M81 SSM ssm = Model_81("192.168.1.100") # Configure data streaming (example: stream source level and measure resistance) ssm.set_stream_config(1, "SRC1_LVL") ssm.set_stream_config(2, "MEAS1_RES") # Enable data streaming ssm.set_stream_mode("ON") # Wait for a few seconds to collect data sleep(5) # Read the streamed data data = ssm.get_stream_data() # Process and print the data print("Streamed data:") for row in data: print(row) # Disable data streaming ssm.set_stream_mode("OFF") # Disconnect from the M81 SSM del ssm ``` -------------------------------- ### Use Calibration Curves with Temperature Instrument Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/model_336.rst Example script demonstrating how to use calibration curves with a temperature instrument. This script requires the Lake Shore Python driver. ```python from time import sleep from lakeshore import Model336 def temperature_monitor_curve_example(): # Connect to the Model 336 # Replace "ASRL1::INSTR" with the appropriate VISA resource name # For example, "TCPIP0::192.168.1.100::INSTR" for a network connection instrument = Model336("ASRL1::INSTR") # Print the instrument's name and firmware version print(f"Connected to: {instrument.get_model_display_name()}") print(f"Firmware version: {instrument.get_firmware_version()}") # Get the current temperature reading from input A # The unit of temperature is determined by the calibration curve set # for the sensor connected to input A. current_temp = instrument.get_temperature(1) print(f"Current temperature on input A: {current_temp}") # Get the current temperature reading from input B current_temp = instrument.get_temperature(2) print(f"Current temperature on input B: {current_temp}") # Get the current temperature reading from input C current_temp = instrument.get_temperature(3) print(f"Current temperature on input C: {current_temp}") # Get the current temperature reading from input D current_temp = instrument.get_temperature(4) print(f"Current temperature on input D: {current_temp}") # Example of reading a calibration curve header # This will only work if a calibration curve is loaded for the specified input try: curve_header = instrument.get_curve_header(1) print("\nCalibration Curve Header for Input A:") print(f" Sensor Type: {curve_header.sensor_type}") print(f" Curve Number: {curve_header.curve_number}") print(f" Units: {curve_header.units}") print(f" Description: {curve_header.description}") print(f" Date: {curve_header.date}") except Exception as e: print(f"\nCould not retrieve curve header for input A: {e}") # Example of reading a calibration curve # This will only work if a calibration curve is loaded for the specified input try: curve_data = instrument.get_curve(1) print("\nCalibration Curve Data for Input A (first 5 points):") for i in range(min(5, len(curve_data))): print(f" {curve_data[i][0]} {curve_header.units}, {curve_data[i][1]} K") except Exception as e: print(f"\nCould not retrieve curve data for input A: {e}") # Close the connection to the instrument instrument.close() if __name__ == "__main__": temperature_monitor_curve_example() ``` -------------------------------- ### Output Current and Measure Voltage on Model 643 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/em_power_supply.rst Example script for outputting current and measuring voltage using the Model 643 power supply. Requires the Lake Shore Python driver. ```python from time import sleep from lakeshore.em_power_supply import ElectromagnetPowerSupply # Connect to the power supply # Replace with your instrument's address (e.g., 'TCPIP::192.168.1.100::INSTR') psu = ElectromagnetPowerSupply('GPIB::23::INSTR') # Set the output current to 1A psu.set_current(1.0) # Wait for the current to stabilize sleep(1) # Read the output current and voltage current = psu.get_current() voltage = psu.get_voltage() # Print the values print(f"Current: {current} A") print(f"Voltage: {voltage} V") # Turn off the output psu.set_output(False) ``` -------------------------------- ### Example Script: Querying the hardware error status register from a Model 648 Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/em_power_supply.rst This script demonstrates how to query the hardware error status register from a Model 648 Electromagnet Power Supply using the Lake Shore Python driver. ```APIDOC ## Example Script: Querying the hardware error status register from a Model 648 ### Description This script demonstrates how to query the hardware error status register from a Model 648 Electromagnet Power Supply using the Lake Shore Python driver. ### File `examples/648_status_register.py` ``` -------------------------------- ### M81 Lock-in Resistance Measurement Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/ssm_system.rst Example script for performing a lock-in measurement of resistance using a BCS-10 and VM-10 with the M81 SSM system. ```python from time import sleep from lakeshore import Model_81 # Connect to the M81 SSM ssm = Model_81("192.168.1.100") # Configure the measurement ssm.set_source_mode(1, "DC") ssm.set_source_output(1, "ON") ssm.set_source_level(1, 0.01) ssm.set_measure_config(1, "RES") ssm.set_measure_config(2, "VOLT") ssm.set_measure_config(3, "CURR") ssm.set_measure_config(4, "TEMP") # Set up the lock-in amplifier ssm.set_lockin_config(1, "DC") ssm.set_lockin_config(2, "AC") ssm.set_lockin_config(3, "DC") ssm.set_lockin_config(4, "DC") ssm.set_lockin_frequency(1, 10.0) ssm.set_lockin_amplitude(1, 0.01) ssm.set_lockin_time_constant(1, 0.1) # Start the measurement ssm.set_measure_mode(1, "LOCKIN") ssm.set_measure_mode(2, "DC") ssm.set_measure_mode(3, "DC") ssm.set_measure_mode(4, "DC") # Wait for the measurement to stabilize sleep(5) # Read the measurement values resistance = ssm.get_measure_value(1) voltage = ssm.get_measure_value(2) current = ssm.get_measure_value(3) temperature = ssm.get_measure_value(4) # Print the results print(f"Resistance: {resistance} Ohms") print(f"Voltage: {voltage} V") print(f"Current: {current} A") print(f"Temperature: {temperature} K") # Turn off the source ssm.set_source_output(1, "OFF") # Disconnect from the M81 SSM del ssm ``` -------------------------------- ### Model 155 Sweep Example Script Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/precision_source.rst This script demonstrates how to perform a sweep using the Model 155 Precision Current and Voltage Source with the Lake Shore Python driver. It requires the `PrecisionSource` class to be imported. ```python import time from lakeshore.model_155 import PrecisionSource # Connect to the instrument # Replace with your instrument's connection details # For example, for a USB connection: # instrument = PrecisionSource("USB0::0x1234::0x5678::SN123456::INSTR") # For a TCP/IP connection: # instrument = PrecisionSource("TCPIP0::192.168.1.100::INSTR") # Example connection (replace with your actual connection string) # instrument = PrecisionSource("ASRL/dev/ttyUSB0::INSTR") # --- Dummy connection for demonstration purposes --- class DummyInstrument: def __init__(self): print("Connecting to dummy instrument...") def set_output_state(self, state): print(f"Setting output state to: {state}") def set_current_source_mode(self): print("Setting current source mode.") def set_voltage_source_mode(self): print("Setting voltage source mode.") def set_current(self, current): print(f"Setting current to: {current} A") def set_voltage(self, voltage): print(f"Setting voltage to: {voltage} V") def query(self, command): print(f"Querying: {command}") if command == "*IDN?": return "Lakeshore,Model 155,SN12345,v1.0" return "OK" def close(self): print("Closing connection.") instrument = DummyInstrument() # --- End of dummy connection --- try: # Initialize the instrument print(instrument.query("*IDN?")) # Set to current source mode instrument.set_current_source_mode() # Define sweep parameters start_current = 0.001 # 1 mA end_current = 0.010 # 10 mA num_steps = 10 step_delay = 0.5 # seconds print(f"Starting current sweep from {start_current} A to {end_current} A...") # Enable output instrument.set_output_state(True) time.sleep(1) # Allow output to stabilize # Perform the sweep for i in range(num_steps + 1): current = start_current + (end_current - start_current) * i / num_steps instrument.set_current(current) print(f"Current set to: {current:.5f} A") time.sleep(step_delay) # Set to voltage source mode instrument.set_voltage_source_mode() # Define voltage sweep parameters start_voltage = 1.0 # 1 V end_voltage = 5.0 # 5 V num_steps_v = 5 step_delay_v = 0.5 # seconds print(f"\nStarting voltage sweep from {start_voltage} V to {end_voltage} V...") # Perform the voltage sweep for i in range(num_steps_v + 1): voltage = start_voltage + (end_voltage - start_voltage) * i / num_steps_v instrument.set_voltage(voltage) print(f"Voltage set to: {voltage:.2f} V") time.sleep(step_delay_v) # Disable output instrument.set_output_state(False) print("\nSweep complete. Output disabled.") except Exception as e: print(f"An error occurred: {e}") finally: # Ensure the connection is closed if 'instrument' in locals() and instrument: instrument.close() ``` -------------------------------- ### Model 336: Multi-Output Heater Configuration Source: https://context7.com/lakeshorecryotronics/python-driver/llms.txt Configure PID values, heater setup, and analog monitor outputs for multiple heater channels. Sets closed-loop mode and temperature setpoints. ```python from lakeshore import Model336 # Connect to Model 336 my_model_336 = Model336() # Configure PID values for outputs 1 and 3 my_model_336.set_heater_pid(1, 40, 27, 0) # P=40, I=27, D=0 my_model_336.set_heater_pid(3, 35, 20, 0) # Configure heater output 1: 50 ohm, 0.75A max, power display my_model_336.set_heater_setup( 1, my_model_336.HeaterResistance.HEATER_50_OHM, 0.75, my_model_336.HeaterOutputUnits.POWER ) # Configure analog output 3 as monitor my_model_336.set_monitor_output_heater( 3, my_model_336.InputChannel.CHANNEL_A, my_model_336.InputSensorUnits.KELVIN, 3.65, # high value 1.02, # low value my_model_336.Polarity.UNIPOLAR ) # Set closed-loop mode for heater 1 using channel A my_model_336.set_heater_output_mode( 1, my_model_336.HeaterOutputMode.CLOSED_LOOP, my_model_336.InputChannel.CHANNEL_A ) # Set setpoints my_model_336.set_control_setpoint(1, 1.5) # 1.5 K my_model_336.set_control_setpoint(3, 2.5) ``` -------------------------------- ### Sweep BCS-10 and Stream Data Source: https://github.com/lakeshorecryotronics/python-driver/blob/main/docs/ssm_system.rst Example script to sweep the current of a BCS-10 from 0 mA to 100 mA and stream the measurement data using the M81 SSM system. ```python from time import sleep from lakeshore import Model_81 # Connect to the M81 SSM ssm = Model_81("192.168.1.100") # Configure source and measurement ssm.set_source_mode(1, "DC") ssm.set_measure_config(1, "RES") ssm.set_measure_config(2, "VOLT") ssm.set_measure_config(3, "CURR") # Configure data streaming ssm.set_stream_config(1, "SRC1_LVL") ssm.set_stream_config(2, "MEAS1_RES") ssm.set_stream_config(3, "MEAS2_VOLT") ssm.set_stream_config(4, "MEAS3_CURR") # Enable data streaming ssm.set_stream_mode("ON") # Perform the sweep ssm.set_source_sweep(1, 0.0, 0.1, 0.001, "LIN") # Sweep from 0A to 0.1A (100mA) with 1mA steps # Wait for the sweep to complete and data to be collected sleep(10) # Read the streamed data data = ssm.get_stream_data() # Process and print the data print("Sweep and streamed data:") for row in data: print(row) # Disable data streaming ssm.set_stream_mode("OFF") # Turn off the source ssm.set_source_output(1, "OFF") # Disconnect from the M81 SSM del ssm ```