LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading asynch Timer and DAQ in CVI

I have an application in CVI that uses a DAQ card for continuous analog acquisition of multiple channels. I am using double buffered I/O and service the buffer using DAQ_monitor every 10 milliseconds to display the most recent data on a strip chart. although this runs well with a single interval timer, I decided to use the Asynchrous Timer function panel to put some of the work in a separate thread.

I created an Asynch timer that runs at 10 ms. In the callback timer thread, I service the DAQ card. I call DAQ_Monitor first to get out the resulting data into a Thread Safe Queue and then go on to service the double buffer activity.

In a the main thread, I use an interval timer at 10 ms to look for work from the data acquisition
. In particular, I plot the data on from the Thread Safe Queue on the stripchart.

My problem is that the call to DAQ_Monitor does not seem to return and hangs the application. Is there some interference between the use of the Asynch timer and the DAQ activity (in the same thread) that I might not be aware of?
0 Kudos
Message 1 of 2
(2,922 Views)
genek,
There really shouldn't be any issue with using DAQ_Monitor in a separate thread. Many people have used that technique to get their data rather than depending on the half buffer transfers.

Have you isolated the hang directly to the DAQ_Monitor call? Is it possible that some other call in the timer is causing the hang? For instance, you could change the timer so that the only call made is the one to DAQ_Monitor. This would continuously overwrite your data, but just for troubleshooting, you would know whether DAQ monitor or some other call is stopping the program.

Similarly, you could do the same with the other functions in your timer.

Are you performing error checking to make sure that the operation is still running before you use DAQ_Monitor? It may be tha
t the acquisition has stopped due to an error (like a hardware buffer overrun). Then DAQ_Monitor would have a problem trying to transfer from an acquisition that is not in progress.

I hope one of these two ideas can get you moving again.

John N
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,922 Views)