Skip to content

Commit

Permalink
ADD: Error if value > 32000 and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasM2001 committed Dec 2, 2024
1 parent ec75e92 commit f57e199
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions basil/HL/bronkhorst_elflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Bronkhorst_ELFLOW(HardwareLayer):
''' Bronkhorst ELFLOW
Manual can be found here:
https://www.bronkhorst.com/getmedia/77a1438f-e547-4a79-95ad-53e81fd38a97/917027-Manual-RS232-interface.pdf
and here: https://www.bronkhorst.com/getmedia/257147fc-7f5d-4628-9a47-0533cf68ac08/917099-Manual-EL-FLOW-Select.pdf
'''

CMDS = {
Expand Down Expand Up @@ -64,6 +65,10 @@ def set_setpoint(self, value):
if not isinstance(value, int):
raise ValueError(f"Given value has to be of type integer, is {type(value)}!")

if value > 32000:
raise ValueError(f"The valid range is 0 to 32000, the set value is {value}!. Setting setpoint to 32000")
value = 32000

hex_val = hex(value)[2:] # [2:] to remove the 0x from the beginning of the hex number
command = f"{self.CMDS['set_setpoint']}" + f"{hex_val.zfill(4)}" # hex should have at least 4 digits
self._intf.write(command)
Expand Down Expand Up @@ -97,8 +102,9 @@ def get_mode(self):
def get_flow(self):
"""This should give the flow in l/min
"""

# first get the max capacity in %
# first get the max capacity in capacity unit
# the max capacity depends on e.g the fluid, which can be changed
# Capacity unit is a command, which returns the used unit in hex
self._intf.write(self.CMDS['get_capacity'])
ret = self.read()
cap_100 = struct.unpack('!f', bytes.fromhex(ret[11:]))[0] # read from the 11th digits to translate what the capacity is
Expand Down

0 comments on commit f57e199

Please sign in to comment.