Hi, I'm trying to ask a Keithley 2440 to loop through relatively fast sets of 4 wire measurements, report the data, and repeat. I have tried RS232 serial communications with pyserial, which worked alright but was not able to communicate quickly and therefore had a low duty cycle of time collecting data vs. not, so I switched to GPIB (NI GPIB-USB-HS with PyVISA in Python 2.7). Now I have managed to get the Keithley set up for the right current for the 4 wire measurement, but often have errors of the output not turning off after a given period of time and the Keithley has not successfully reported any values back to my computer with my recent attempts at these controls. I got most of the SCPI commands from a coworker who was using a LabVIEW program to control his Keithley a couple of years ago. Current code looks like this:
import visa
import numpy as np
from pylab import *
import matplotlib.pyplot as plt
import time
number_loops = 20
count = 10
DIVoutput = np.zeros((count*number_loops,5)) # make sure this is at least larger than loops*trig count!!!!
NPLC = 6
COUNT = 10
rm = visa.ResourceManager()
rm.list_resources()
('ASRL1::INSTR', 'ASRL2::INSTR', 'GPIB0::24::INSTR')
inst = rm.open_resource('GPIB0::24::INSTR')
inst.timeout = 25000 # in milliseconds
time.sleep(0.001)
print(inst.query("*IDN?"))
print(inst.query(':ROUT:TERM?'))
inst.write(':ROUT:TERM FRON')
print(inst.query(':ROUT:TERM?'))
inst.write('*RST')
inst.write(':FORM:ELEM VOLT,CURR,TIME;DATA SREAL;BORD NORM')
inst.write('ENSE:AVER:TCON MOV OFF')
inst.write('YSTEM:AZEROTAT OFF')
inst.write(':TRIGEL 0.0')
inst.write('OURCEELAY 0.0')
inst.write('YST:AZERO OFF')
inst.write('ISP:ENAB OFF')
inst.write('YST:BEEPTAT OFF')
inst.write(':AVER OFF')
inst.write('YST:RSEN ON')
inst.write('YST:AZERO ONCE')
for i in range(number_loops):
#START OF LOOP
inst.write(':CURR:NPLC '+str(NPLC)+';')
inst.write('OUR:FUNC CURR')
inst.write('OUR:CURR 1e-3')
inst.write("ENS:FUNC 'VOLTC'")
inst.write(':VOLTROT 5')
inst.write('UTP ON')
inst.write(':ARM:COUN 1;:TRIG:COUN '+str(count)+';OUR:CURR:MODE FIX;')
inst.write(':ARMOUR IMM;:ARM:TIME 0.01;:TRIGOUR IMM;:TRIGEL 0')
inst.write(':TRIG:CLE;:INIT')
inst.write('UTP OFF')
b=inst.query_ascii_values('FETC?')
a=(inst.read())
inst.close()
I get errors like "UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 3: ordinal not in range(128)" when I do this.
Does anyone have an example of code that effectively gets 4 wire measurements out of a Keithley at faster than 1 Hz? I'd be happy with anything that pretty much works and has a higher than 50% "up" time of actually taking measurements.
Thanks in advance for any help.