Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request for Alicat Python Library #15

Merged
merged 19 commits into from
Jan 5, 2022
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ Example Connections

Installation
============

```
pip install alicat
```

If you don't like pip, you can also install from source:

```
git clone https://github.com/numat/alicat.git
cd alicat
Expand Down Expand Up @@ -80,10 +77,48 @@ You can also set the gas type and flow rate / pressure.

```python
flow_controller.set_gas('N2')
flow_controller.set_gas(8) # Optionally set a gas by its number; find the full gas table in the Alicat manual.
flow_controller.set_flow_rate(1.0)
flow_controller.set_pressure(20)
```

For firmware 5v and greater, create and set gas mixes using COMPOSER software loaded into the device. Mixes can contain up to five gases, and are stored in gas indices 236-255.

```python
flow_controller.create_mix(mix_no=236, name="Mix1", gases={'N2': 50, 'O2': 30, 'CO2': 20})
flow_controller.set_gas(236)
flow_controller.delete_mix(236)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool!!


Additional features include override commands to increase device functionality.

```python
flow_controller.lock() # Lock the front display.
flow_controller.unlock() # Unlock the front display.
flow_controller.hold() # Hold the valve in its current position.
flow_controller.cancel_hold() # Cancel the valve hold.
flow_controller.tare_volumetric() # Tare volumetric hold.
flow_controller.tare_pressure() # Tare pressure.
flow_controller.reset_tot() # Reset totalizer, if totalizer functionality included.
```

For flow controllers, read and write PID loop settings for device tuning.

```python
flow_controller.write_PID_looptype("PD2I")
flow_controller.write_PID_P(4000)
flow_controller.write_PID_D(10)
flow_controller.write_PID_I(4000)
print(flow_controller.read_PID())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also cool! I've been meaning to add PID tweaking to this code since day 1, so it's great to see it here.


>>>{
'loop_type': 'PD2I',
'P': '4000',
'D': '10',
'I': '4000'
}
```

### Alicat Addressing

You can have multiple controllers on the same port by using Alicat's `A`-`D` addresses
Expand Down
15 changes: 13 additions & 2 deletions alicat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def command_line():
"'/dev/ttyUSB0'. Use e.g. 'tcp://192.168.1.100:4000 "
"to read devices routed through a converter.")
parser.add_argument('--address', '-a', default='A', type=str, help="The "
"device address, A-D. Should only be used if multiple "
"flow controllers are connected to one port.")
"device address, A-Z. Should only be used if multiple "
"flow controllers are connected to one port or if"
"device ID is not A.")
parser.add_argument('--set-gas', '-g', default=None, type=str,
help="Sets the gas type. Supported gas types are: "
"'Air', 'Ar', 'CH4', 'CO', 'CO2', 'C2H6', 'H2', "
Expand All @@ -35,6 +36,16 @@ def command_line():
parser.add_argument('--stream', '-s', action='store_true',
help="Sends a constant stream of flow controller "
"data, formatted as a tab-separated table.")
parser.add_argument("--lock", "-l", action="store_true",
help="Locks device display.")
parser.add_argument("--unlock", "-u", action="store_true",
help="Unlocks device display.")
parser.add_argument("--hold", "-hd", action="store_true",
help="Holds the valve at the present value.")
parser.add_argument("--cancel-hold", "-c", action="store_true",
help="Cancel valve hold.")
parser.add_argument("--reset-totalizer", "-r", action="store_true",
help="Reset current value of totalizer to zero.")
args = parser.parse_args()

if args.port.startswith('tcp://'):
Expand Down
Loading