Python Forum

Full Version: Alicat Flow Meter data acquisition
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everybody.

I have this code that I use to graph and acquire temperature data from three thermocouples using nidaqmx:

import nidaqmx
import matplotlib.pyplot as plt

plt.ion()

i=0

with nidaqmx.Task() as task:
    task.ai_channels.add_ai_thrmcpl_chan("Dev1/ai0:2")
    while i<50:
        data = task.read(number_of_samples_per_channel=1)
        plt.scatter(i,data[0],c='r')
        plt.scatter(i,data[1],c='b')
        plt.scatter(i,data[2],c='y')
        plt.pause(1)
        i=i+1
        print (data)
Now I need to graph and acquire data from an Alicat Flow meter in the same way that the previouos code, so I tried this:

import asyncio
import matplotlib.pyplot as plt
from alicat import FlowMeter

plt.ion()

i=0

with asyncio.Task() as task:
    async def get():
        while i<50:
            data2 = task.read(FlowMeter("COM3:A"))
            plt.scatter(i,data2,c='r')
            plt.pause(1)
            i=i+1
            print(await data2.get())

asyncio.run(get())
This is the error code I get:
Error:
Traceback (most recent call last): File "C:\Users\marenr\My Documents\LiClipse Workspace5\thermocouple data acquisition\Data_acquisition.py", line 9, in <module> with asyncio.Task() as task: ^^^^^^^^^^^^^^ TypeError: Task() missing required argument 'coro' (pos 1)
I would really appreciate on suggestions on how I would need to update my code to be able to plot and acquire data from the flow meter. I believe the main problem I had is that in the latter code I didn´t know how to deal with the asyncio.

I´m using window 10 pro

Thanks in advance.