-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Opened by ericshear26 at numat#171
Hi, I want to get four Alicat BASIS 2 MFCs to work with my Mac. They are definitely controllers, not meters. I am trying to establish serial connection between one MFC and the computer before I work on the others. The MFCs are connected to a BB8-DB9 breakout box with serial-DB9M cables. The breakout box is connected to the computer by an USB-USB cable. The breakout box is powered separately.
I know the FlowVision program exists for Windows, but the Python method should work on UNIX systems. I have gotten sensors and a stepper motor to work with microcontrollers on this Mac, so this shouldn't be any different.
Here is what I did:
- I pip-installed the alicat package (not sure if it's from the numat or alexrudd2 repository)
- I downloaded the Virtual COM Port driver for MacOS ARM and confirmed a successful installation.
- I confirmed that the computer "sees" the device. The address is /dev/cu.usbserial-DK0EUH0N.
- I downloaded PowerShell (now open source) and got it working in the terminal.
- I checked the baud rate of the serial connection. It keeps defaulting to 9600, because MacOS keeps closing the serial port and the baud rate resets every time. Using the exec 3<> command then the address in the terminal, I was able to hold the port open. When I then tried to change the baud rate to 38400, it returned 19200.
- When I ran it in terminal, I got the following error message:
(base) Eric@CHE-NAR-2G5L2C0 ~ % alicat /dev/cu.usbserial-DK0EUH0N
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.13/bin/alicat", line 8, in <module>
sys.exit(command_line())
~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/__init__.py", line 88, in command_line
asyncio.run(get())
~~~~~~~~~~~^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/__init__.py", line 71, in get
state = await flow_controller.get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/driver.py", line 365, in get
state = await super().get()
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/driver.py", line 131, in get
line = await self._write_and_read(command)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/driver.py", line 345, in _write_and_read
await self._init_task
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/driver.py", line 331, in _init_control_point
self.control_point = await self._get_control_point()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/alicat/driver.py", line 542, in _get_control_point
raise OSError("Could not read control point.")
OSError: Could not read control point.
I ultimately want to run this in a Python IDE, but I'm not sure how to specify the baud rate with the asyncio package. My code looks like this so far:
import serial
import asyncio
from alicat import FlowController
port = '/dev/cu.usbserial-DK0EUH0N' # Connect to controller
baud_rate = 38400 # Baud must match controller's
ser = serial.Serial(port, baud_rate)
async def run_MFCs():
async with FlowController(port, 'A') as MFC_airA:
while True:
readings = await MFC_airA.get()
i = i+1
print(i, readings)
asyncio.sleep(0.5)
asyncio.run(run_MFCs())Thanks for your help and I look forward to getting this to work.