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

Cant get info through BB3-232 Alicat platform #92

Closed LilyGGGGGGG closed 8 months ago

LilyGGGGGGG commented 8 months ago

Hi Guys,

I am trying to access alicat information through python in anaconda. I have my code written like this: import asyncio import nest_asyncio from alicat import FlowController

nest_asyncio.apply() async def get(): async with FlowController(address="COM9", unit='A',baudrate=19200) as flow_controller: flow_controller.timeout=None data = await flow_controller.get()

    return data       

loop = asyncio.get_event_loop() ans = loop.run_until_complete(get()) massflow = ans['mass_flow']

it works when I connect a single MFC through 8-pin din cable to RS-232 to PC, but it did not work when I try to use this code to get data through alicat BB3-232 platform that allows me to connect multiple MFCs together. it gives me this error message: File ~\anaconda3\Lib\site-packages\alicat\driver.py:474 in _get_control_point value = int(line.split('=')[-1])

ValueError: invalid literal for int() with base 10: ' 37\r\x00'

it seems like when the signal goes through the platform, extra data was generated. Please help me solve this issue. Thank you so much!!

alexrudd2 commented 8 months ago

Are there any other devices connected to the breakout box? Is it possible that a Mass Flow Meter is responding instead of an MFC?

LilyGGGGGGG commented 8 months ago

Are there any other devices connected to the breakout box? Is it possible that a Mass Flow Meter is responding instead of an MFC?

I don't believe so. I am trying to connect 2 MFCs through this breakout box so that the total flowrate at downstream will be the same if one MFC needs to change the flowrate.

alexrudd2 commented 8 months ago

Try putting a print(line) in driver.py:473.

I've not seen this before; the breakout box shouldn't modify the signal at all. Does it work with only one MFC at a time? Is it possible they both have the same address (A)?

LilyGGGGGGG commented 8 months ago

I put this code: " print('what did the line say?', line) print('How many indices?', len(line)) " in the driver.py. when I ran the connection where it is connected through 8-pin din cable to RS-232, it gives this result: what did the line say? A 122 = 37 How many indices? 12 when I ran the connection through BB3-232 with only one MFC connected on this box, it gives me this result: hat did the line say? F 122 = 37 How many indices? 14 and the error message :" value = int(line.split('=')[-1])

ValueError: invalid literal for int() with base 10: ' 37\r\x00' "

It is also interesting to point out that when I asked python to get MFC data from BB3-232, it will not give me the "w" in "what" from the print command.

alexrudd2 commented 8 months ago

Strange. It appears the breakout box is adding \x00.

Can you try value = int(line.strip().split('=')[-1]) or value = int(line.replace('\x00', '').split('=')[-1])?

LilyGGGGGGG commented 8 months ago

Thank you so much! This code "value = int(line.replace('\x00', '').split('=')[-1])" made it work, now I can control multiple MFCs through the breakout box now. It still cannot print the "w" in "what", but I'm just grateful the code is running now! Thanks again!