01-29-2021 04:56 AM
hello i have created a task the read the counter
with nidaqmx.Task() as task:
task.ci_channels.add_ci_count_edges_chan('Dev1/ctr0', initial_count=0, edge=Edge.RISING, count_direction=CountDirection.COUNT_UP)
tsk = task.read()
print(tsk)
every time i read the task the counter start from 0
how i can have a continuos reading in order to display it continuosly?
Thanks
01-29-2021 06:04 AM
This is due to a subtle "convenience" feature of DAQmx.
When you call read() on a task that isn't running, it will automatically start the task, do the reading, then stop the task again. So each time you call read(), you're getting a fresh task start (which defaults the initial count to 0) followed by an immediate read() before any edges can increment the count.
Instead, explicitly start the task yourself and then enter into a loop that reads repeatedly. Then you'll start seeing cumulative counts. (It's probably also a good idea to add some kind of brief time delay function in the loop).
-Kevin P
01-29-2021 07:57 AM
thanks for your reply but i can read for example in this way
task.read(1024)
In this case i have a list of value, but if i show them i'm in delay from the real value measured.
01-29-2021 08:36 AM
Sorry, but I'm afraid I have no familiarity with the python API for DAQmx functions. I'm just pretty familiar with DAQmx itself through lots of LabVIEW-based programming.
For example, I don't know how that read(1024) function is implemented. Is it simply a loop that iterates 1024 times, takes 1 reading each time, and accumulates the results? If so, then the "delay" you talk about may just be the time it takes to execute those 1024 reads.
-Kevin P
01-29-2021 11:51 AM
I understand
I have read many post, but i'm not able to find one solution for read a counter continuously with python