numat / alicat

Python driver and command line tool for Alicat mass flow controllers.
GNU General Public License v2.0
21 stars 27 forks source link

set_flow_rate throws error when maximum ramp rate != 0 #108

Open brubaked opened 4 months ago

brubaked commented 4 months ago

A maximum ramp rate can be set on Alicat flow controllers. When this ramp rate is set to a non-zero value, the set_flow_rate command throws an error since the current setpoint does not equal the commanded setpoint. TheAlicay _unit_id_LS command returns both the current setpoint and the commanded setpoint. Using this command to verify that the instrument has correctly received the commanded setpoint would allow the set_flow_rate command to work while a maximum flow rate is set.

alexrudd2 commented 4 months ago

Thank you for the suggestion.

I assume you are referring to this error? https://github.com/numat/alicat/blob/718024d4894029420969a886073e2f3beee13863/alicat/driver.py#L467-L468

Nobody at numat maintains these any more, but I should be able to take a look.

brubaked commented 4 months ago

Yep, that's the one!

alexrudd2 commented 4 months ago

Does this code work? It'll take me a little bit to test on a real device.

        if current is not None and abs(current - setpoint) > 0.01:
            # possibly the setpoint is being ramped
            command = f'{self.unit}LS'
            line = await self._write_and_read(command)
            if not line:
                raise OSError("Could not set setpoint.")
            try:
                commanded = float(line.split()[2])
            except IndexError:
                raise OSError("Could not set setpoint.")
            if commanded is not None and abs(commanded - setpoint) > 0.01:
                raise OSError("Could not set setpoint.")