LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Readign from two different tasks with two while loops.

Hi,
      I have to read data from 2 tasks which consists of 3 channels each. Each task is read in a different while loop. when I do this I am getting as error in the Daqmx read VI. Is there any way I can read the data into two while loops with two different tasks?
 
My hardware is: SC2345 box and 6036E Daq card.
 
I created the tasks in the MAX. The data I am reading is Analog Input. When I did the same thing with Digital Output I dont have any issues.
 
To solve the above issue I created one task in MAX with all the 6 channels and used the same task to read the analog data in two different while loops when I did this there was no error but the acuiring data process has became very slow.
 
Any help to solve this issue is appreciated.
 
Mudda.
0 Kudos
Message 1 of 8
(2,885 Views)
You can only have one task running at a time. As you have noted, you can create a combined task (I presume you are using NI-DAQ 7.4 or greater), but as to why the DAQ process is slowed it might be helpful if you post your code.

P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 8
(2,882 Views)

PM,

        Thanks for your reply. My code is little bit complicated it contains two big state machines, the loop time between each state is 1m sec. and in my read state I am waiting 10msec before I read the data. The sampling rate I am using is 2000 samples per second. When I was running the two sate machines with the same task the speed of the read function has tremendously decreased. Please let me know if you have any ideas to bring to normal speed. Does using the same task in two different while loops decrease the speed of data acquisition process?

Thanks,

Mudda.

0 Kudos
Message 3 of 8
(2,874 Views)
Mudda,

One approach I use for situations somewhat like yours is to put the data acquistion task in a loop of its own. All that loop does is acquire the data and put it into a queue (or queues). The analysis processes can each be their own separate state machines. They get data from the DAQ queues as they are ready for it. Think of this as substituting the queue for DAQ in the state machines. This allows the DAQ process to run at its own speed. As long as each loop has a wait (even zero ms) they will share processor time.

Lynn
0 Kudos
Message 4 of 8
(2,865 Views)

Lynn,

        Are there any examples for the solution you described?

 

thanks,

Mudda

0 Kudos
Message 5 of 8
(2,859 Views)
Mudda,

Search the archives for "producer consumer".

Lynn
0 Kudos
Message 6 of 8
(2,857 Views)

Thanks, I was able to get some example. I have couple of questions on the queues.

1) Are there any limitation on using queue's in the program.

2)Do I need to read the data periodically or is it possible to waite for a long time before I read the data. How is the data controlled in the queue is there any buffer size for the queue?

Thank You,

Mudda. 

0 Kudos
Message 7 of 8
(2,853 Views)
1) It is best to only read from a queue in one place. Once an element has been read from the queue (dequeued) it is removed from the queue and another read from a different location would not see that data.

2) A queue is somewhat like an array in than it can grow until reaching limits of memory or indexing. It is possible to specifiy the size of a queue when it is created, but it is probbably better to leave it unbounded for your application.

Look at the help files for queues. Also it can be useful to write some simple test programs to try different things with them before implementing a large queue based program. They are very powerful, but can be somewhat confusing at first.

Lynn
0 Kudos
Message 8 of 8
(2,849 Views)