fixes in convergence, mercury, phytron, triton

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

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