Пример #1
0
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.")
Пример #2
0
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.")    
Пример #3
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]
Пример #4
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]
Пример #5
0
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.")
Пример #6
0
def enable_live_readings():
  gpib.write("ARM:COUN INF")  # infinite arm count
  gpib.write("TRIG:DEL 0")    # zero trigger delay
  gpib.write("INIT")          # start measurements
Пример #7
0
def enable_voltage_source():
  gpib.write("O1X")
Пример #8
0
def current_mode():
  gpib.write("SOUR:FUNC VOLT")
  gpib.write("SOUR:VOLT 0")
  gpib.write("CONF:CURR")
  gpib.write("FORM:ELEM CURR")
  time.sleep(1)
Пример #9
0
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
Пример #10
0
def display_voltage_source():
  gpib.write("D1X")
Пример #11
0
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]
Пример #12
0
def resistance_mode():
    gpib.write("CONF:RES")
    gpib.write("FORM:ELEM RES")
Пример #13
0
def voltage_mode():
    gpib.write("SOUR:FUNC CURR")
    gpib.write("SOUR:CURR 0")
    gpib.write("CONF:VOLT")
    gpib.write("FORM:ELEM VOLT")
    time.sleep(1)
Пример #14
0
def current_mode():
  gpib.write("F1X")
  time.sleep(1)
Пример #15
0
def disable_voltage_source():
  gpib.write("SOUR:VOLT 0")
Пример #16
0
def voltage_mode():
  gpib.write("F0X")
  time.sleep(1)
Пример #17
0
def set_voltage_source(voltage):
  if abs((voltage / 0.05) - round(voltage / 0.05)) > 1e-10:
    print 'Warning: The voltage source in the Keithley 617 has a ' \
    'maximum resolution of 50 mV.'
  gpib.write("V" + "%.2f" % voltage + "X")
Пример #18
0
def resistance_mode():
  gpib.write("F2X")
  time.sleep(1)
Пример #19
0
def disable_voltage_source():
    gpib.write("SOUR:VOLT 0")
Пример #20
0
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
Пример #21
0
def resistance_mode():
  gpib.write("CONF:RES")
  gpib.write("FORM:ELEM RES")
Пример #22
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
Пример #23
0
def set_voltage_source(voltage):
    if abs((voltage / 5e-6) - round(voltage / 5e-6)) > 1e-10:
        print 'Warning: The voltage source in the Keithley 2400 has a ' \
        'maximum resolution of 5 uV.'
    gpib.write("SOUR:VOLT " + str(voltage))
Пример #24
0
def set_voltage_source(voltage):
  if abs((voltage / 5e-6) - round(voltage / 5e-6)) > 1e-10:
    print 'Warning: The voltage source in the Keithley 2400 has a ' \
    'maximum resolution of 5 uV.'
  gpib.write("SOUR:VOLT " + str(voltage))
Пример #25
0
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)
Пример #26
0
def voltage_mode():
  gpib.write("SOUR:FUNC CURR")
  gpib.write("SOUR:CURR 0")
  gpib.write("CONF:VOLT")
  gpib.write("FORM:ELEM VOLT")
  time.sleep(1)
Пример #27
0
def current_mode():
    gpib.write("SOUR:FUNC VOLT")
    gpib.write("SOUR:VOLT 0")
    gpib.write("CONF:CURR")
    gpib.write("FORM:ELEM CURR")
    time.sleep(1)
Пример #28
0
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)
Пример #29
0
def enable_live_readings():
    gpib.write("ARM:COUN INF")  # infinite arm count
    gpib.write("TRIG:DEL 0")  # zero trigger delay
    gpib.write("INIT")  # start measurements
Пример #30
0
def disable_voltage_source():
  gpib.write("O0X")