Beating my head against the desk here- been going round and round with this Keithley2400 to take fast readings. One problem I'm having is only 10 readings come back from the system when over 100 is expected... but that's not what this Question is about...
I've coded the example from the PyVisa documents for a "more complex example" and the demo code doesn't work at all. The Keithley 2400 dies on the Sample:Count line. Infact, in the Keithley manual, this function doesn't appear. I'm writing this here so that others who are having the same problem can also commiserate.
The example code which can be found in the PyVisa documentation is as follows:
import visa rm = visa.ResourceManager() rm.list_resources() keithley = rm.open_resource('GPIB0::24::INSTR')
keithley.write("*RST; STATUS:PRESET; *CLS")
interval_in_ms = 500 number_of_readings = 10 keithley.write("STATUS:MEASUREMENT:ENABLE 512; *sre 1") keithley.write("SAMPLE:COUNT %d" % number_of_readings) keithley.write("TRIGGER:SOURCE BUS")
keithley.write("TRIGGER:DELAY %f" % (interval_in_ms / 1000.0)) keithley.write("TRACE:POINTS %d" % number_of_readings) keithley.write("TRACE:FEED SENSE1; FEED:CONTROL NEXT")
keithley.write("INITIATE")
keithley.assert_trigger()
keithley.wait_for_srq()
keithley.query("TRACE:DATA?")
voltages = keithley.query_ascii_values("TRACE:DATA?")
print("Average voltage: ", sum(voltages) / len(voltages))
keithley.query("STATUS:MEASUREMENT?")
keithley.write("TRACE:CLEAR; FEED:CONTROL NEXT")
The problem appears to occur at this line:
keithley.write("SAMPLE:COUNT %d" % number_of_readings)
which is completely unknown in the documentation and by the sourcemeter2400 unit
Current firmware is c32
Hopefully this post helps someone.