92 lines
2.7 KiB
Python
92 lines
2.7 KiB
Python
import ch.psi.pshell.epics as epics
|
|
|
|
class Keithley(object):
|
|
def __init__(self, basename):
|
|
self.basename = basename
|
|
self.scanCh = None
|
|
self.ttypeCh = None
|
|
self.nplcCh = None
|
|
self.navgCh = None
|
|
self.tottimeCh = None
|
|
self.doinitCh = None
|
|
self.dotriggerCh = None
|
|
self.dofetchCh = None
|
|
self.readoutCh = None
|
|
|
|
def initialize(self):
|
|
self.scanCh = epics.ChannelInteger(basename + "READSCAN.SCAN")
|
|
self.ttypeCh = epics.ChannelInteger(basename + "TTYPE")
|
|
self.nplcCh = epics.ChannelDouble(basename + "NPLC")
|
|
self.navgCh = epics.ChannelInteger(basename + "NAVG")
|
|
self.tottimeCh = epics.ChannelDouble(basename + "TOTTIME")
|
|
self.doinitCh = epics.ChannelInteger(basename + "DOINIT")
|
|
self.dotriggerCh = epics.ChannelInteger(basename + "DOTRIGGER")
|
|
self.dofetchCh = epics.ChannelInteger(basename + "DOFETCH")
|
|
self.readoutCh = epics.ChannelDouble(basename + "READOUT")
|
|
|
|
def prepare(self, dwell):
|
|
"""
|
|
prepare keithley for gpib polling:
|
|
scan passive, bus triggered, set dwell time
|
|
|
|
dwell = dwell time in seconds (0.1 - 20.0)
|
|
"""
|
|
self.scanCh.putq(0)
|
|
self.ttypeCh.putq(2)
|
|
nplc = 5.
|
|
navg = dwell / 0.1
|
|
if navg > 100:
|
|
nplc *= 2
|
|
navg /= 2
|
|
navg = min(navg, 100)
|
|
nplc = min(nplc, 10.)
|
|
self.nplcCh.putq(nplc)
|
|
self.navgCh.putq(navg)
|
|
|
|
def trig(self):
|
|
"""
|
|
trigger keithleys, wait until done, and read the result into EPICS.
|
|
the value can then be read by pshell from the channel.
|
|
"""
|
|
dwell1 = caget(KEI_SAMPLE + "TOTTIME") / 1000.
|
|
dwell2 = caget(KEI_REF + "TOTTIME") / 1000.
|
|
dwell = max(dwell1, dwell2)
|
|
self.doinitCh.put(1)
|
|
self.dotriggerCh.put(1)
|
|
|
|
def get_dwell(self):
|
|
"""
|
|
get dwell time in seconds.
|
|
"""
|
|
dwell = self.tottimeCh.get() / 1000.
|
|
return dwell
|
|
|
|
def fetch(self):
|
|
"""
|
|
fetch the current value from the keithley into EPICS.
|
|
"""
|
|
#time.sleep(self.get_dwell())
|
|
self.dofetchCh.put(1)
|
|
|
|
def read(self):
|
|
"""
|
|
read the curent value.
|
|
"""
|
|
return self.readoutCh.get()
|
|
|
|
def release(self):
|
|
"""
|
|
switch keithleys to free run.
|
|
0.1 s polling and dwell time
|
|
"""
|
|
self.nplcCh.putq(nplc)
|
|
self.navgCh.putq(navg)
|
|
self.scanCh.putq(9)
|
|
self.ttypeCh.putq(0)
|
|
|
|
KeiSample = Keithley("X03DA-KEITHLEY-1:")
|
|
KeiReference = Keithley("X03DA-KEITHLEY-2:")
|
|
|
|
KeiSample.initialize()
|
|
KeiReference.initialize()
|