fixes in convergence, mercury, phytron, triton

This commit is contained in:
zolliker 2022-06-01 09:21:47 +02:00
parent 3563a0db16
commit 68e2e06905
4 changed files with 18 additions and 15 deletions

View File

@ -60,8 +60,8 @@ class HasConvergence:
def cleanup(self, state):
state.default_cleanup(state)
if self.stopped:
if self.stopped is Stop: # and not Restart
if state.stopped:
if state.stopped is Stop: # and not Restart
self.status = WARN, 'stopped'
else:
self.status = WARN, repr(state.last_error)

View File

@ -341,6 +341,7 @@ class TemperatureLoop(TemperatureSensor, Loop, Drivable):
enable_ramp = Parameter('enable ramp rate', BoolType(), readonly=False)
setpoint = Parameter('working setpoint (differs from target when ramping)', FloatRange(0, unit='$'))
auto_flow = Parameter('enable auto flow', BoolType(), readonly=False)
tolerance = Parameter(default=0.1)
_last_setpoint_change = None
def doPoll(self):
@ -452,6 +453,7 @@ class ValvePos(HasInput, MercuryChannel, Drivable):
class PressureLoop(PressureSensor, Loop, Drivable):
channel_type = 'PRES,AUX'
output_module = Attached(ValvePos, mandatory=False)
tolerance = Parameter(default=0.1)
def read_control_active(self):
active = self.query('PRES:LOOP:FAUT', off_on)

View File

@ -31,7 +31,7 @@ from secop.lib import clamp
class PhytronIO(StringIO):
end_of_line = '\x03' # ETX
timeout = 0.2
timeout = 0.5
identification = [('0IVR', 'MCC Minilog .*')]
def communicate(self, command, expect_response=True):
@ -65,8 +65,9 @@ class Motor(PersistentMixin, HasIO, Drivable):
offset = PersistentParam('', FloatRange(unit='deg'), readonly=False, default=0)
sign = PersistentParam('', IntRange(-1,1), readonly=False, default=1)
encoder = Parameter('encoder reading', FloatRange(unit='deg'))
sameside_offset = Parameter('offset when always approaching from the same side',
FloatRange(unit='deg'), readonly=False, default=0)
backlash = Parameter("""backlash compensation\n
offset for always approaching from the same side""",
FloatRange(unit='deg'), readonly=False, default=0)
abslimits = Parameter('abs limits (raw values)', default=(0, 0),
datatype=TupleOf(FloatRange(unit='deg'), FloatRange(unit='deg')))
userlimits = PersistentParam('user limits', readonly=False, default=(0, 0), initwrite=True,
@ -74,7 +75,7 @@ class Motor(PersistentMixin, HasIO, Drivable):
ioClass = PhytronIO
fast_poll = 0.1
_sameside_pending = False
_backlash_pending = False
_mismatch_count = 0
_rawlimits = None
@ -122,10 +123,10 @@ class Motor(PersistentMixin, HasIO, Drivable):
else:
self.status = self.Status.BUSY, 'driving'
else:
if self._sameside_pending:
if self._backlash_pending:
# drive to real target
self.set('A', self.sign * (self.target + self.offset))
self._sameside_pending = False
self._backlash_pending = False
return pos
if (self.encoder_mode == 'CHECK' and
abs(enc - pos) > self.encoder_tolerance):
@ -176,12 +177,12 @@ class Motor(PersistentMixin, HasIO, Drivable):
if self.status[0] == self.Status.ERROR:
raise HardwareError('need reset')
self.status = self.Status.BUSY, 'changed target'
self._check_limits(value, value + self.sameside_offset)
if self.sameside_offset:
# drive first to target + sameside_offset
self._check_limits(value, value + self.backlash)
if self.backlash:
# drive first to target + backlash
# we do not optimize when already driving from the right side
self._sameside_pending = True
self.set('A', self.sign * (value + self.offset + self.sameside_offset))
self._backlash_pending = True
self.set('A', self.sign * (value + self.offset + self.backlash))
else:
self.set('A', self.sign * (value + self.offset))
self.setFastPoll(True, self.fast_poll)
@ -207,7 +208,7 @@ class Motor(PersistentMixin, HasIO, Drivable):
@Command
def reset(self):
"""reset error, set position to encoder"""
"""Reset error, set position to encoder"""
self.read_value()
if self.status[0] == self.Status.ERROR:
enc = self.encoder + self.offset

View File

@ -32,7 +32,7 @@ open_close = Mapped(CLOSE=False, OPEN=True)
actions_map = Mapped(NONE=actions.none, COND=actions.condense, COLL=actions.collect)
class Action(MercuryChannel):
class Action(MercuryChannel, Writable):
channel_type = 'ACTN'
value = Parameter('running action', EnumType(actions))
target = Parameter('valve target', EnumType(none=0, condense=1, collect=3), readonly=False)