pythonhardwarepyvisa

How to set V-Source output on the `Keithley 617 programmable electrometer` with python?


I want to control the V-Source of the Keithley 617.

Here is what I tried so far:

I found and try out the documentation of the Keithley 6517b:

from pymeasure.instruments.keithley import Keithley6517B

instrument_address = '<Device Adress>'

Keithley = Keithley6517B(instrument_address)
keithley.apply_voltage()              # Sets up to source current
keithley.source_voltage_range = 200   # Sets the source voltage
                                      # range to 200 V
keithley.source_voltage = 20          # Sets the source voltage to 20 V
keithley.enable_source()              # Enables the source output

keithley.measure_resistance()         # Sets up to measure resistance

keithley.ramp_to_voltage(50)          # Ramps the voltage to 50 V
print(keithley.resistance)            # Prints the resistance in Ohms

keithley.shutdown()                   # Ramps the voltage to 0 V
                                      # and disables output 

but sadly, I get the following error after a view second when calling keithley.apply_voltage():
VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

I also tried to communicate via pyvisa directly:

import pyvisa

def set_voltage(voltage_value):
    try:
        # Connect to the Keithley 617 Electrometer
        rm = pyvisa.ResourceManager()
        electrometer = rm.open_resource(instrument_address)  # Replace with your instrument's address

        

        # Set the voltage value
        electrometer. Write(f'SOUR:VOLT {voltage_value}') #returns a 15
        
        # Enable the voltage output
        electrometer. Write('OUTP ON') #returns a 9

        # Close the connection
        electrometer.close()

        print(f"Voltage set to {voltage_value} V successfully.")
    except Exception as e:
        print(f"Error: {e}")

# Example usage
if __name__ == '__main__':
    voltage_to_set = 20.0 # Replace with the desired voltage value
    set_voltage(voltage_to_set)

This doesn't throw an error, but also doesn't change any settings of the device.

To be clear: communication with the device seems to work. I can also measure e.G. the voltage without any problems. The Problem is to programmatically control the V-Source.


Solution

  • The following worked for me:

    import pyvisa
    
    
    
    rm = pyvisa.ResourceManager() # Connect to the Keithley 617 Electrometer
    instrument_address = 'ASRL8::INSTR' # as an example - to list all devices use: rm.list_resources()
    electrometer = rm.open_resource(instrument_address) 
    
    electrometer.write(f'O1V20.0X') # turn voltage on and set it to 20V
    electrometer.write(f'O0V5.5X') # turn voltage off and set it to 5.5V
    
    electrometer.close() # Close the connection
    

    So use the command structure O+[On:1 or Off:0]+V+[Voltage value]+X