flamedil as of 2023-07-03
This commit is contained in:
parent
b4cfdcfc1a
commit
6ac3938b78
@ -45,8 +45,7 @@ Mod('ts',
|
|||||||
value=Param(unit='K'),
|
value=Param(unit='K'),
|
||||||
low='ts_low',
|
low='ts_low',
|
||||||
high='ts_high',
|
high='ts_high',
|
||||||
min_high=1.3,
|
min_high=0.6,
|
||||||
max_low=1.7,
|
max_low=1.7,
|
||||||
tolerance=0.1,
|
tolerance=0.1,
|
||||||
disable_other=False,
|
|
||||||
)
|
)
|
||||||
|
@ -207,8 +207,17 @@ class ResChannel(Channel):
|
|||||||
STATUS_MASK = 0x3f # mask T_OVER and T_UNDER
|
STATUS_MASK = 0x3f # mask T_OVER and T_UNDER
|
||||||
|
|
||||||
def communicate(self, command):
|
def communicate(self, command):
|
||||||
|
# TODO: remove this and change to query
|
||||||
return self.switcher.communicate(command)
|
return self.switcher.communicate(command)
|
||||||
|
|
||||||
|
def query(self, command):
|
||||||
|
return parse(self.switcher.communicate(command))
|
||||||
|
|
||||||
|
def change(self, command, *args):
|
||||||
|
cmd, _, qarg = command.partition(' ')
|
||||||
|
args = ','.join([qarg] + [f'{a:g}' for a in args])
|
||||||
|
return parse(self.switcher.communicate(f'{command}?{qarg};{command} {args}'))
|
||||||
|
|
||||||
def read_status(self):
|
def read_status(self):
|
||||||
if not self.enabled:
|
if not self.enabled:
|
||||||
return [self.Status.DISABLED, 'disabled']
|
return [self.Status.DISABLED, 'disabled']
|
||||||
@ -361,6 +370,7 @@ class TemperatureChannel(ResChannel):
|
|||||||
|
|
||||||
|
|
||||||
class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
|
class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
|
||||||
|
loop = Property('lakshore loop', IntRange(0, 1), default=0) # TODO: implemented specific issues of loop 1
|
||||||
target = Parameter('setpoint', FloatRange(0, unit='$'))
|
target = Parameter('setpoint', FloatRange(0, unit='$'))
|
||||||
control_active = Parameter('we are controlling', BoolType(), default=0)
|
control_active = Parameter('we are controlling', BoolType(), default=0)
|
||||||
minheater = Parameter('minimal heater current', FloatRange(0, 0.01, unit='A'), readonly=False, default=0)
|
minheater = Parameter('minimal heater current', FloatRange(0, 0.01, unit='A'), readonly=False, default=0)
|
||||||
@ -373,7 +383,7 @@ class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
|
|||||||
def control_off(self):
|
def control_off(self):
|
||||||
"""switch control off"""
|
"""switch control off"""
|
||||||
self._control_active = False
|
self._control_active = False
|
||||||
self.communicate(f'RANGE 0,0;RANGE?0')
|
self.communicate(f'RANGE {self.loop},0;RANGE?{self.loop}')
|
||||||
self.read_control_active()
|
self.read_control_active()
|
||||||
|
|
||||||
def min_percent(self):
|
def min_percent(self):
|
||||||
@ -384,21 +394,21 @@ class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
|
|||||||
def set_htrrng(self):
|
def set_htrrng(self):
|
||||||
if self._control_active:
|
if self._control_active:
|
||||||
newhtr = int(self.htrrng) if self._control_active else 0
|
newhtr = int(self.htrrng) if self._control_active else 0
|
||||||
htrrng = int(self.communicate('RANGE?0'))
|
htrrng = int(self.communicate(f'RANGE?{self.loop}'))
|
||||||
if htrrng != newhtr:
|
if htrrng != newhtr:
|
||||||
if newhtr:
|
if newhtr:
|
||||||
self.log.info('switched heater on %d', newhtr)
|
self.log.info('switched heater on %d', newhtr)
|
||||||
self.communicate(f'RANGE 0,{newhtr};RANGE?0')
|
self.communicate(f'RANGE {self.loop},{newhtr};RANGE?{self.loop}')
|
||||||
if self.minheater:
|
if self.minheater:
|
||||||
self.log.info('underflow open loop')
|
self.log.info('underflow open loop')
|
||||||
self._underflow = True
|
self._underflow = True
|
||||||
self.communicate(f'OUTMODE 0,2,{self.channel},0,0,1,3;*OPC?')
|
self.communicate(f'OUTMODE {self.loop},2,{self.channel},0,0,1,3;*OPC?')
|
||||||
self.communicate(f'MOUT {self.min_percent()};*OPC?')
|
self.communicate(f'MOUT {self.loop}{self.min_percent()};*OPC?')
|
||||||
elif self._underflow:
|
elif self._underflow:
|
||||||
self.log.info('switch to control after underflow')
|
self.log.info('switch to control after underflow')
|
||||||
self._underflow = False
|
self._underflow = False
|
||||||
self.communicate(f'OUTMODE 0,5,{self.channel},0,0,1,3;*OPC?')
|
self.communicate(f'OUTMODE {self.loop},5,{self.channel},0,0,1,3;*OPC?')
|
||||||
self.communicate(f'SETP 0,{self.target};SETP?0')
|
self.communicate(f'SETP {self.loop},{self.target};*OPC?')
|
||||||
|
|
||||||
def read_control_active(self):
|
def read_control_active(self):
|
||||||
self.set_htrrng()
|
self.set_htrrng()
|
||||||
@ -406,23 +416,31 @@ class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
|
|||||||
|
|
||||||
def read_target(self):
|
def read_target(self):
|
||||||
if self._control_active:
|
if self._control_active:
|
||||||
return float(self.communicate('SETP?0'))
|
return float(self.communicate('SETP?{self.loop}'))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def write_htrrng(self, value):
|
def write_htrrng(self, value):
|
||||||
if self._control_active:
|
if self._control_active:
|
||||||
self.communicate('RANGE 0,{int(value)};*OPC?')
|
self.communicate('RANGE {self.loop},{int(value)};*OPC?')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def write_target(self, target):
|
def write_target(self, target):
|
||||||
outmode = (5, self.channel, 0, 0, 1, 3)
|
outmode = (5, self.channel, 0, 0, 1, 3)
|
||||||
prev = parse(self.communicate('OUTMODE?0'))
|
prev = parse(self.communicate('OUTMODE?{self.loop}'))
|
||||||
if outmode != prev:
|
if outmode != prev:
|
||||||
self.communicate('OUTMODE 0, %g,%g,%g,%g,%g,%g;*OPC?' % tuple(outmode))
|
self.communicate('OUTMODE {self.loop}, %g,%g,%g,%g,%g,%g;*OPC?' % tuple(outmode))
|
||||||
self.communicate('MOUT 0,{self.min_percent()};*OPC?')
|
self.communicate('MOUT {self.loop},{self.min_percent()};*OPC?')
|
||||||
for chan in self.switcher.channels.values():
|
for chan in self.switcher.channels.values():
|
||||||
chan._control_active = False
|
chan._control_active = False
|
||||||
self._control_active = True
|
self._control_active = True
|
||||||
self.read_control_active()
|
self.read_control_active()
|
||||||
self.convergence_start()
|
self.convergence_start()
|
||||||
return float(self.communicate(f'SETP 0,{target};SETP?0'))
|
return float(self.communicate(f'SETP {self.loop},{target};SETP?{self.loop}'))
|
||||||
|
|
||||||
|
#def write_ctrlpars(self, ctrlpars):
|
||||||
|
# p, i, d = self.change(f'PID {self.loop}', ctrlpars['p'], ctrlpars['i'], ctrlpars['d'])
|
||||||
|
# return {'p': p, 'i': i, 'd': d}
|
||||||
|
|
||||||
|
#def read_ctrlpars(self):
|
||||||
|
# p, i, d = self.query(f'PID? {self.loop}')
|
||||||
|
# return {'p': p, 'i': i, 'd': d}
|
||||||
|
@ -130,7 +130,7 @@ def set_enabled(modobj, value):
|
|||||||
modobj.write_enabled(value)
|
modobj.write_enabled(value)
|
||||||
|
|
||||||
|
|
||||||
def get_value(self, obj, default):
|
def get_value(obj, default):
|
||||||
"""get the value of given module. if not valid, return the limit (min_high or max_low)"""
|
"""get the value of given module. if not valid, return the limit (min_high or max_low)"""
|
||||||
if not getattr(obj, 'enabled', True):
|
if not getattr(obj, 'enabled', True):
|
||||||
return default
|
return default
|
||||||
@ -151,28 +151,29 @@ class SwitchDriv(HasConvergence, Drivable):
|
|||||||
def doPoll(self):
|
def doPoll(self):
|
||||||
super().doPoll()
|
super().doPoll()
|
||||||
if not self.isBusy():
|
if not self.isBusy():
|
||||||
low = self.get_value(self.low, self.max_low)
|
low = get_value(self.low, self.max_low)
|
||||||
high = self.get_value(self.high, self.min_high)
|
high = get_value(self.high, self.min_high)
|
||||||
low_valid = low < self.max_low
|
low_valid = low < self.max_low
|
||||||
high_valid = high > self.min_high
|
high_valid = high > self.min_high
|
||||||
if low_valid > high_valid:
|
if high_valid and high > self.max_low:
|
||||||
self.write_selected(self.selected.low)
|
if not low_valid:
|
||||||
elif high_valid > low_valid:
|
set_enabled(self.low, False)
|
||||||
self.write_selected(self.selected.high)
|
return
|
||||||
if high_valid or low_valid:
|
if low_valid and low < self.min_high:
|
||||||
set_enabled(self.low, low_valid)
|
if not high_valid:
|
||||||
set_enabled(self.high, high_valid)
|
set_enabled(self.high, False)
|
||||||
else: # both invalid: measure both!
|
return
|
||||||
set_enabled(self.low, True)
|
set_enabled(self.low, True)
|
||||||
set_enabled(self.high, True)
|
set_enabled(self.high, True)
|
||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
return self.low.value if self.selected == self.selected.low else self.high.value
|
return self.low.value if self.selected == self.selected.low else self.high.value
|
||||||
|
|
||||||
def read_status(self):
|
def read_status(self):
|
||||||
status = self.low.status if self.selected == self.selected.low else self.high.status
|
status = self.low.status if self.selected == self.selected.low else self.high.status
|
||||||
# merge with convergence status
|
if status[0] >= ERROR:
|
||||||
return merge_status(status, super().read_status())
|
return status
|
||||||
|
return super().read_status() # convergence status
|
||||||
|
|
||||||
def read_target(self):
|
def read_target(self):
|
||||||
if self.selected == self.selected.low:
|
if self.selected == self.selected.low:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user