def read_one(interval=0): #gpib.write("ARM:COUN 1") #gpib.write("ARM:SOUR BUS") gpib.write("TRIG:COUN 1") # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay gpib.write("INIT") # start measurement #gpib.write("*TRG") gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) RAV = 1 << 6 reading_available = measurement_event & RAV while not reading_available: #print str(measurement_event) + ", " + str(reading_available) time.sleep(interval) gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) reading_available = measurement_event & RAV #gpib.write("*CLS") # clear event registers #time.sleep(interval) gpib.write("FETC?") gpib.write("++read 10") Datum = gpib.readline() print "reading: " + Datum return Datum
def read_one(interval = 0): #gpib.write("ARM:COUN 1") #gpib.write("ARM:SOUR BUS") gpib.write("TRIG:COUN 1") # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay gpib.write("INIT") # start measurement #gpib.write("*TRG") gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) RAV = 1 << 6 reading_available = measurement_event & RAV while not reading_available: #print str(measurement_event) + ", " + str(reading_available) time.sleep(interval) gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) reading_available = measurement_event & RAV #gpib.write("*CLS") # clear event registers #time.sleep(interval) gpib.write("FETC?") gpib.write("++read 10") Datum = gpib.readline() print "reading: " + Datum return Datum
def read_old(interval=0, samples=1, update_graph=do_nothing): RAV = 1 << 6 gpib.write("TRIG:COUN 1") # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay Time = [] Data = [] CurrentSample = 1 Datum = gpib.readline() gpib.write("INIT") # start measurement while CurrentSample <= samples: reading_available = 0 while not reading_available: #print str(measurement_event) + ", " + str(reading_available) time.sleep(interval) gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) reading_available = measurement_event & RAV gpib.write("FETC?") gpib.write("++read 10") gpib.write("INIT") # start measurement Datum = gpib.readline() #print Datum #Data = Data + [float(Datum[4:Datum.find(',')])] Data = Data + [float(Datum)] Time = Time + [(CurrentSample - 1) * interval] CurrentSample = CurrentSample + 1 update_graph(Time[-1], Data[-1]) # call graph update function gpib.write("ARM:COUN INF") # return instrument to live mode gpib.write("TRIG:DEL 0") gpib.write("INIT") # start measurements if samples > 1: return Time, Data else: return float(Datum)
def read_old(interval = 0, samples = 1, update_graph = do_nothing): RAV = 1 << 6 gpib.write("TRIG:COUN 1") # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay Time = [] Data = [] CurrentSample = 1 Datum = gpib.readline() gpib.write("INIT") # start measurement while CurrentSample <= samples: reading_available = 0 while not reading_available: #print str(measurement_event) + ", " + str(reading_available) time.sleep(interval) gpib.write("STAT:MEAS?") # read measurement event register gpib.write("++read 10") measurement_event = int(gpib.readline()) reading_available = measurement_event & RAV gpib.write("FETC?") gpib.write("++read 10") gpib.write("INIT") # start measurement Datum = gpib.readline() #print Datum #Data = Data + [float(Datum[4:Datum.find(',')])] Data = Data + [float(Datum)] Time = Time + [(CurrentSample - 1) * interval] CurrentSample = CurrentSample + 1 update_graph(Time[-1], Data[-1]) # call graph update function gpib.write("ARM:COUN INF") # return instrument to live mode gpib.write("TRIG:DEL 0") gpib.write("INIT") # start measurements if samples > 1: return Time, Data else: return float(Datum)
def read_one(interval = 0): if interval == 0: gpib.write("B1Q0G2X") # store data as fast as possible elif interval == 1: gpib.write("B1Q1G2X") # store data every 1 s elif interval == 10: gpib.write("B1Q2G2X") # store data every 10 s elif interval == 60: gpib.write("B1Q3G2X") # store data every 60 s elif interval == 600: gpib.write("B1Q4G2X") # store data every 600 s elif interval == 3600: gpib.write("B1Q5G2X") # store data every 3600 s else: raise Error("ERROR: The Keithley 617 allows sample intervals of " + \ "0, 1, 10, 60, 600, or 3600 seconds.") #gpib.flushInput() # discard any previous readings samples = 2 Data = [] CurrentSample = 1 Datum = gpib.readline() while CurrentSample <= samples: if ",%03d" % CurrentSample in Datum: Data = Data + [float(Datum[4:Datum.find(',')])] CurrentSample = CurrentSample + 1 time.sleep(interval) elif ",%03d" % (CurrentSample -1) in Datum: time.sleep(interval) gpib.write("B1X") # get a reading Datum = gpib.readline() gpib.write("Q7X") # turn off data storage return Data[-1]
def read(interval=0, samples=1, update_graph=do_nothing, *args): gpib.write("ARM:COUN 1") # arm instrument gpib.write("TRIG:COUN %d" % samples) # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay Time = [] Data = [] CurrentSample = 0 gpib.write("READ?") # start measurement while len(Data) < samples: while CurrentSample < len(Data): update_graph(Time[CurrentSample], Data[CurrentSample], figure) CurrentSample = CurrentSample + 1 time.sleep(interval) DataString = gpib.readline() DataString = DataString.split(',') for i in range(len(DataString)): if len(DataString[i]) > 0: #print DataString[i] if DataString[ i] != '\x00\x00\x00': # some 2400s return this if no data Time.append(float(len(Data) * interval)) Data.append(float(DataString[i])) while CurrentSample < len(Data): update_graph(Time[CurrentSample], Data[CurrentSample], *args) CurrentSample = CurrentSample + 1 if samples > 1: return Time, Data else: return Data[0]
def read(interval = 0, samples = 1, update_graph = do_nothing, *args): gpib.write("ARM:COUN 1") # arm instrument gpib.write("TRIG:COUN %d" % samples) # setup trigger count gpib.write("TRIG:DEL %f" % interval) # setup trigger delay Time = [] Data = [] CurrentSample = 0 gpib.write("READ?") # start measurement while len(Data) < samples: while CurrentSample < len(Data): update_graph(Time[CurrentSample], Data[CurrentSample], figure) CurrentSample = CurrentSample + 1 time.sleep(interval) DataString = gpib.readline() DataString = DataString.split(',') for i in range(len(DataString)): if len(DataString[i]) > 0: #print DataString[i] if DataString[i] != '\x00\x00\x00': # some 2400s return this if no data Time.append(float(len(Data) * interval)) Data.append(float(DataString[i])) while CurrentSample < len(Data): update_graph(Time[CurrentSample], Data[CurrentSample], *args) CurrentSample = CurrentSample + 1 if samples > 1: return Time, Data else: return Data[0]
def read_multiple(interval = 0, samples = 1, update_graph = do_nothing, *args): if interval not in [0, 1, 10, 60, 600, 3600]: raise Error("ERROR: The Keithley 617 allows interval values of " + \ "0, 1, 10, 60, 600, and 3600") if samples > 100: raise Error("ERROR: The Keithley 617 allows a maximum of 100 samples.") #gpib.flushInput() # discard any previous readings if interval == 0: gpib.write("B1Q0G2X") # store data as fast as possible elif interval == 1: gpib.write("B1Q1G2X") # store data every 1 s elif interval == 10: gpib.write("B1Q2G2X") # store data every 10 s elif interval == 60: gpib.write("B1Q3G2X") # store data every 60 s elif interval == 600: gpib.write("B1Q4G2X") # store data every 600 s elif interval == 3600: gpib.write("B1Q5G2X") # store data every 3600 s else: raise Error("ERROR: The Keithley 617 allows sample intervals of " + \ "0, 1, 10, 60, 600, or 3600 seconds.") Time = [] Data = [] CurrentSample = 1 time.sleep(interval) Datum = gpib.readline() while CurrentSample <= samples: if ",%03d" % CurrentSample in Datum: Data = Data + [float(Datum[4:Datum.find(',')])] if interval == 0: # Keithley617 manual page 3-24 Time = Time + [(CurrentSample - 1) * 0.360] else: Time = Time + [(CurrentSample - 1) * interval] CurrentSample = CurrentSample + 1 # call graph update function update_graph(Time[-1], Data[-1], *args) time.sleep(interval) elif ",%03d" % (CurrentSample -1) in Datum: time.sleep(interval) gpib.write("B1X") # get a reading Datum = gpib.readline() gpib.write("Q7X") # turn off data storage return Time, Data
def open_connection(): gpib.open_connection() gpib.set_address(24) gpib.clear_selected_device() # clear keithley gpib.write("*IDN?") # ask instrument to identify itself reading = gpib.readline() if "KEITHLEY INSTRUMENTS INC.,MODEL 2400" in reading: gpib.write("OUTP ON") # Enable the Keithley's output else: raise Error("ERROR: The Keithley 2400 is not responding.")
def open_connection(): gpib.open_connection() gpib.write("++addr 27") # set GPIB address to the Keithley 617 gpib.clear_selected_device() # Reset Keithley gpib.write("C0X") # turn off zero check gpib.write("C0X") # again, just to make sure :) reading = gpib.readline() # make sure Keithley's turned on if not "DC" in reading: raise Error("ERROR: The Keithley 617 is not responding, make "\ "sure it is turned on.")