fixes on 2023-11-27

- ls372 autorange: wait one sec. more for switching
- keep only one channel, even after target is reached
- intermediate target only when T is raise, but not when lowered
This commit is contained in:
l_samenv 2023-11-28 10:12:27 +01:00
parent c80b4ac5fb
commit 5b0da3ba98
3 changed files with 27 additions and 17 deletions

View File

@ -24,6 +24,7 @@ Mod('ts_low',
minrange=13,
range=22,
tolerance = 0.1,
vexc = 3,
htrrng=4,
)
@ -32,7 +33,8 @@ Mod('ts_high',
'sample Cernox',
channel = 1,
switcher = 'lsc_channel',
minrange=9,
minrange=11,
vexc = 5,
range=22,
tolerance = 0.1,
htrrng=5,
@ -45,7 +47,9 @@ Mod('ts',
value=Param(unit='K'),
low='ts_low',
high='ts_high',
min_high=0.6035,
max_low=1.6965,
#min_high=0.6035,
#max_low=1.6965,
min_high=0.6,
max_low=1.7,
tolerance=0.1,
)

View File

@ -231,7 +231,7 @@ class ResChannel(Channel):
def _read_value(self):
"""read value, without update"""
now = time.monotonic()
if now + 0.5 < max(self._last_range_change, self.switcher._start_switch) + self.pause:
if now - 0.5 < max(self._last_range_change, self.switcher._start_switch) + self.pause:
return None
result = float(self.communicate('RDGR?%d' % self.channel))
if result == 0:
@ -241,7 +241,7 @@ class ResChannel(Channel):
return None
if self.autorange:
self.fix_autorange()
if now + 0.5 > self._last_range_change + self.pause:
if now - 0.5 > self._last_range_change + self.pause:
rng = int(max(self.minrange, self.range)) # convert from enum to int
if self.status[0] < self.Status.ERROR:
if abs(result) > self.RES_SCALE[rng]:
@ -386,6 +386,10 @@ class TemperatureLoop(HasConvergence, TemperatureChannel, Drivable):
htrrng = Parameter('', EnumType(HTRRNG), readonly=False)
_control_active = False
def doPoll(self):
super().doPoll()
self.set_htrrng()
@Command
def control_off(self):
"""switch control off"""

View File

@ -22,7 +22,7 @@
"""modules to access parameters"""
from frappy.core import Drivable, EnumType, IDLE, Attached, StringType, Property, \
Parameter, FloatRange, Readable, ERROR
Parameter, FloatRange, BoolType, Readable, ERROR
from frappy.errors import ConfigError
from frappy_psi.convergence import HasConvergence
from frappy_psi.mixins import HasRamp
@ -148,6 +148,7 @@ class SwitchDriv(HasConvergence, Drivable):
max_low = Parameter('maximum low target', FloatRange(unit='$'), readonly=False)
# disable_other = Parameter('whether to disable unused channel', BoolType(), readonly=False)
selected = Parameter('selected module', EnumType(low=LOW, high=HIGH), readonly=False, default=0)
autoswitch = Parameter('switch sensor automatically', BoolType(), readonly=False, default=True)
_switch_target = None # if not None, switch to selection mhen mid range is reached
# TODO: copy units from attached module
@ -165,13 +166,13 @@ class SwitchDriv(HasConvergence, Drivable):
self.write_target(self.target)
return
else:
high = get_value(self.high, mid) # return mid then high is invalid
high = get_value(self.high, mid) # return mid when high is invalid
if high < mid:
self.value = self.high.value
self._switch_target = None
self.write_target(self.target)
return
if not self.isBusy():
if not self.isBusy() and self.autoswitch:
low = get_value(self.low, self.max_low)
high = get_value(self.high, self.min_high)
low_valid = low < self.max_low
@ -184,8 +185,9 @@ class SwitchDriv(HasConvergence, Drivable):
if not high_valid and not self.high.control_active:
set_enabled(self.high, False)
return
set_enabled(self.low, True)
set_enabled(self.high, True)
# keep only one channel on
#set_enabled(self.low, True)
#set_enabled(self.high, True)
def get_selected(self):
low = get_value(self.low, self.max_low)
@ -219,13 +221,13 @@ class SwitchDriv(HasConvergence, Drivable):
this, other = other, this
selected = HIGH
elif target < self.min_high * 0.75 + self.max_low * 0.25:
if self.value > self.max_low:
target1 = max(self.min_high, target)
self._switch_target = LOW
this, other = other, this
selected = HIGH
else:
selected = LOW
#if self.value > self.max_low:
# target1 = max(self.min_high, target)
# self._switch_target = LOW
# this, other = other, this
# selected = HIGH
#else:
selected = LOW
elif self.selected == HIGH:
this, other = other, this
if hasattr(other, 'control_off'):