fixes for flamesample

- fixes in SwitchDrive
- increase range when reading is zero in autorange
- add debugging log msgs
This commit is contained in:
l_samenv
2023-10-25 10:14:53 +02:00
parent 8cb9154bb5
commit c80b4ac5fb
2 changed files with 39 additions and 26 deletions

View File

@ -235,6 +235,9 @@ class ResChannel(Channel):
return None
result = float(self.communicate('RDGR?%d' % self.channel))
if result == 0:
if self.autorange:
rng = int(max(self.minrange, self.range)) # convert from enum to int
self.write_range(min(self.MAX_RNG, rng + 1))
return None
if self.autorange:
self.fix_autorange()
@ -251,8 +254,10 @@ class ResChannel(Channel):
lim -= 0.05 # not more than 4 steps at once
# effectively: <0.16 %: 4 steps, <1%: 3 steps, <5%: 2 steps, <20%: 1 step
elif rng < self.MAX_RNG:
self.log.debug('increase range due to error %d', rng)
rng = min(self.MAX_RNG, rng + 1)
if rng != self.range:
self.log.debug('range change to %d', rng)
self.write_range(rng)
self._last_range_change = now
return result