diff --git a/frappy_psi/bronkhorst.py b/frappy_psi/bronkhorst.py index b870e9e5..bdd914d6 100644 --- a/frappy_psi/bronkhorst.py +++ b/frappy_psi/bronkhorst.py @@ -75,7 +75,7 @@ class Sensor(HasIO, Readable): reply = self.communicate(f':{length}{self.addr:02X}04{param}{param}') if reply[:11] != f':{length}{self.addr:02X}02{param}': return CommunicationFailedError(f'bad reply: {reply}') - val = int(reply[11:14], 16) / 32000 * scale + val = int(reply[11:15], 16) / 32000 * scale return val def read_value(self): @@ -85,8 +85,8 @@ class Sensor(HasIO, Readable): class Controller(Sensor, Writable): def set_par(self, length, param, scale, value): - reply = self.communicate(f':{length}{self.addr:02X}01{param}{round(value/scale):04X}') - if reply[:8] != f':04{self.addr:02X}0000': + reply = self.communicate(f':{length}{self.addr:02X}01{param}{round(value * 32000 / scale):04X}') + if reply[:11] != f':04{self.addr:02X}000005': raise CommunicationFailedError(f'bad reply: {reply}') return self.get_par(length, param, scale) @@ -94,8 +94,7 @@ class Controller(Sensor, Writable): return self.get_par(*SETPOINT, self.scale) def write_target(self, value): - val = value / self.scale * 32000 - return self.set_par(*SETPOINT, self.scale, val) + return self.set_par(*SETPOINT, self.scale, value) class HasRamp(Drivable):