KeithleySetVoltage.py
From OptoelectronicsWiki
- Python Function to set Keithley voltage and read current
- Import functions
from time import sleep from visa import instrument
- Set keithley voltage and read current
def keithleySetVoltage(voltage,GPIB):
try: k2400 = instrument('GPIB1::' + str(GPIB),timeout = 20) except: try: k2400 = instrument('GPIB::' + str(GPIB),timeout = 20) except: print ' no GPIB' return k2400.write('*rst; status:preset; *cls') k2400.write(':SOUR:FUNC:MODE VOLT') #Select current source k2400.write(':SENS:CURR:RANG:AUTO ON') #Auto Measure Range k2400.write(':SENS:FUNC "CURR"') #Voltage measure function. k2400.write(':FORM:ELEM CURR') #Voltage reading only. k2400.write(':SOUR:VOLT:LEV ' + str(voltage)) sleep(0.1); k2400.write('read?') current = k2400.read_values() return current