# Import functions from time import sleep from visa import instrument # Set keithley current and read voltage def keithleySetCurrent(current,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 CURR') #Select current source k2400.write(':SENS:VOLT:RANG:AUTO ON') #Auto Measure Range k2400.write(':SENS:FUNC "VOLT"') #Voltage measure function. k2400.write(':FORM:ELEM VOLT') #Voltage reading only. k2400.write(':SOUR:CURR:LEV ' + str(current)) sleep(0.1); k2400.write('read?') voltage = k2400.read_values() return voltage