From 5b0da3ba981f7d0eaebd6ac77e6a13a306d140a3 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 28 Nov 2023 10:12:27 +0100 Subject: [PATCH] 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 --- cfg/addons/flamesample_cfg.py | 10 +++++++--- frappy_psi/ls372.py | 8 ++++++-- frappy_psi/parmod.py | 26 ++++++++++++++------------ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cfg/addons/flamesample_cfg.py b/cfg/addons/flamesample_cfg.py index f34e038..854d7ad 100644 --- a/cfg/addons/flamesample_cfg.py +++ b/cfg/addons/flamesample_cfg.py @@ -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, ) diff --git a/frappy_psi/ls372.py b/frappy_psi/ls372.py index ad22fbb..ce9d6c7 100644 --- a/frappy_psi/ls372.py +++ b/frappy_psi/ls372.py @@ -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""" diff --git a/frappy_psi/parmod.py b/frappy_psi/parmod.py index 205d2da..0070026 100644 --- a/frappy_psi/parmod.py +++ b/frappy_psi/parmod.py @@ -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'):