Closedown

This commit is contained in:
gac-x03da
2018-02-09 15:39:01 +01:00
parent 8b4607c104
commit 963e58e3b3
3 changed files with 86 additions and 21 deletions

View File

@@ -1,9 +1,14 @@
import ch.psi.pshell.epics as epics
class Keithley(object):
RANGE_STATES = ['AUTO', '20 mA', '2 mA', '200 uA', '20 uA', '2 uA', '200 nA', '20 nA', '2 nA', '200 pA', '20 pA']
TTYPE_STATES = ['IMM', 'TLIN', 'BUS', 'EXT']
USER_MODE_STATES = ['def setting', 'poll curr fast', 'poll curr medi', 'poll curr slow', 'trig setting', 'trigger BUS', 'trigger TLIN', 'trigger EXT', 'poll volt medi']
def __init__(self, base_name, base_channel):
self.base_channel = base_channel
self.base_name = base_name
self.rangeCh = None
self.scanCh = None
self.ttypeCh = None
self.nplcCh = None
@@ -15,6 +20,7 @@ class Keithley(object):
self.readoutCh = None
def initialize(self):
self.rangeCh = epics.ChannelInteger(self.base_name + "Range", self.base_channel + "RANGE")
self.scanCh = epics.ChannelInteger(self.base_name + "Scan", self.base_channel + "READSCAN.SCAN")
self.ttypeCh = epics.ChannelInteger(self.base_name + "TType", self.base_channel + "TTYPE")
self.nplcCh = epics.ChannelDouble(self.base_name + "Nplc", self.base_channel + "NPLC")
@@ -24,7 +30,14 @@ class Keithley(object):
self.dotriggerCh = epics.ChannelInteger(self.base_name + "DoTrigger", self.base_channel + "DOTRIGGER")
self.dofetchCh = epics.ChannelInteger(self.base_name + "DoFetch", self.base_channel + "DOFETCH")
self.readoutCh = epics.ChannelDouble(self.base_name + "Readout", self.base_channel + "READOUT")
# DOZCHOFF
# ZCH_SP
# DOCURRENT
# DORESET
# DOSETDEFAULT
# USER_MODE
self.rangeCh.initialize()
self.scanCh.initialize()
self.ttypeCh.initialize()
self.nplcCh.initialize()
@@ -34,7 +47,19 @@ class Keithley(object):
self.dotriggerCh.initialize()
self.dofetchCh.initialize()
self.readoutCh.initialize()
def setup():
"""
EXPERIMENTAL
to set up the keithley after Reset, there are two options
1) do set defaults, set scan, set range
2) set user mode, set range
"""
self.dosetdefaultCh.write(1)
self.scanCh.write(9)
def prepare(self, dwell):
"""
prepare keithley for gpib polling:
@@ -92,6 +117,34 @@ class Keithley(object):
self.scanCh.write(9)
self.ttypeCh.write(0)
def reset(self):
"""
switch to zero check
"""
self.doresetCh.write(1)
def set_range(self, value):
"""
set the current range.
value can be:
- float: current limit in A.
values between 2e-11 and 2e-3 set a fixed range.
values greater than 0.02 select AUTO.
- str: state label of EPICS channel (cf. self.RANGE_STATES)
- int: state index of EPICS channel
"""
if isinstance(value, float):
try:
v = int(-math.log10(value / 2)) - 1
v = max(v, 0)
v = min(v, len(RANGE_STATES)-1)
except ValueError:
v = 0
elif isinstance(value, str):
value = self.RANGE_STATES.index(value)
self.rangeCh.write(value)
KeiSample = Keithley("SampleKeithley", "X03DA-KEITHLEY-1:")
KeiReference = Keithley("ReferenceKeithley", "X03DA-KEITHLEY-2:")

View File

@@ -86,13 +86,13 @@ def trig_scienta():
time.sleep(0.1)
else:
image_id = Scienta.currentImageCount
print time.time(), " trig_scienta: start"
# print time.time(), " trig_scienta: start"
Scienta.start()
print time.time(), " trig_scienta: waitReady"
# print time.time(), " trig_scienta: waitReady"
Scienta.waitReady(-1)
print time.time(), " trig_scienta: waitNewImage"
# print time.time(), " trig_scienta: waitNewImage"
Scienta.waitNewImage(3000, image_id)
print time.time(), " trig_scienta: return"
# print time.time(), " trig_scienta: return"
from keithley import KeiSample, KeiReference
@@ -115,11 +115,15 @@ def trig_keithleys():
KeiReference.trig()
def wait_keithleys():
"""
wait for one dwell time so that the keithleys can finish their measurement.
if we polled them too early, they would produce an error message.
"""
time.sleep(KeiSample.get_dwell())
def fetch_keithleys():
"""
read the keithleys into EPICS.
read the keithley readings into EPICS.
this requires that at least the dwell time has passed since the last trigger.
the value can then be read from the SampleCurrent and ReferenceCurrent devices.
"""
@@ -284,18 +288,18 @@ def before_readout():
sample_scienta = True
break
print time.time(), " before_readout: beam"
#print time.time(), " before_readout: beam"
wait_beam()
print time.time(), " before_readout: trig"
#print time.time(), " before_readout: trig"
trig_keithleys()
print time.time(), " before_readout: wait"
#print time.time(), " before_readout: wait"
if sample_scienta:
trig_scienta()
else:
wait_keithleys()
print time.time(), " before_readout: fetch"
#print time.time(), " before_readout: fetch"
fetch_keithleys()
print time.time(), " before_readout: return"
#print time.time(), " before_readout: return"
def after_readout(rec):
if get_exec_pars().persist:

View File

@@ -30,7 +30,7 @@ elif RANGE == "C K-edge":
STARTPOS = (250.0)
ENDPOS = (330.0)
STEPS = 0.2
LATENCY = 5.0
LATENCY = 1.0
DWELL = 1.0
KEI_DIODE = "X03DA-KEITHLEY-1:"
@@ -40,8 +40,10 @@ if BEAM == "G600 1x1":
# G600 1x1 reference sscan_2268 (elog:119)
#SampleCurrentGain.write("L, 10^7")
#RefCurrentGain.write("L, 10^9")
caput(KEI_DIODE + "RANGE", 6) # 200 nA
caput(KEI_RMU + "RANGE", 8) # 2 nA
KeiSample.set_range(200e-9)
KeiReference.set_range(2e-9)
#caput(KEI_DIODE + "RANGE", 6) # 200 nA
#caput(KEI_RMU + "RANGE", 8) # 2 nA
FrontendHSize.write(1.5)
FrontendVSize.write(1.4)
ExitSlit.write(100.0)
@@ -49,8 +51,10 @@ elif BEAM == "G600 6x10":
# G600 6x10 reference sscan_2268 (elog:119)
#SampleCurrentGain.write("L, 10^5")
#RefCurrentGain.write("L, 10^7")
caput(KEI_DIODE + "RANGE", 4) # 20 uA
caput(KEI_RMU + "RANGE", 6) # 200 nA
KeiSample.set_range(20e-6)
KeiReference.set_range(200e-9)
#caput(KEI_DIODE + "RANGE", 4) # 20 uA
#caput(KEI_RMU + "RANGE", 6) # 200 nA
FrontendHSize.write(6.5)
FrontendVSize.write(10.4)
ExitSlit.write(100.0)
@@ -58,8 +62,10 @@ elif BEAM == "G1200 1x1":
# G1200 1x1 reference sscan_2264 (elog:114)
#SampleCurrentGain.write("L, 10^7")
#RefCurrentGain.write("L, 10^9")
caput(KEI_DIODE + "RANGE", 6) # 200 nA
caput(KEI_RMU + "RANGE", 8) # 2 nA
KeiSample.set_range(200e-9)
KeiReference.set_range(2e-9)
#caput(KEI_DIODE + "RANGE", 6) # 200 nA
#caput(KEI_RMU + "RANGE", 8) # 2 nA
FrontendHSize.write(1.5)
FrontendVSize.write(1.4)
ExitSlit.write(100.0)
@@ -67,8 +73,10 @@ elif BEAM == "G1200 6x10":
# G1200 6x10 reference sscan_2266 (elog:116)
#SampleCurrentGain.write("L, 10^6")
#RefCurrentGain.write("L, 10^8")
caput(KEI_DIODE + "RANGE", 5) # 2 uA
caput(KEI_RMU + "RANGE", 7) # 20 nA
KeiSample.set_range(2e-6)
KeiReference.set_range(20e-9)
#caput(KEI_DIODE + "RANGE", 5) # 2 uA
#caput(KEI_RMU + "RANGE", 7) # 20 nA
FrontendHSize.write(6.5)
FrontendVSize.write(10.4)
ExitSlit.write(100.0)