LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Callbacks vs. Threads for Acquiring Data?

I'm pretty much a noob when it comes to LabWindows/CVI and am currently going through both application examples and others written by co-workers, I can see two reasonable methods for acquiring data from a DAQ task and I'm curious what other people prefer to do.

One method is to setup up the task normally and create a thread using a CVICALLBACK as the thread function to read data using DAQmxReadAnalogF64.
Another is to use DAQmxRegisterEveryNSamplesEvent and register a CVICALLBACK that processes what's read every time that it acquires its data.

Is one of these methods better? It seems to me that both are virtually the same so I guess another question would be; is there a benefit in terms of device processing/acquisition time if I use a thread?

Thanks.
0 Kudos
Message 1 of 3
(3,191 Views)
I'm not a big NI-DAQ user but I believe the issue you are debating is a legacy from old NI-DAQ since NI-DAQmx creates background theads for data acquistion automatically.

I'd say use what ever method makes your program's organization easier and more straight forward to understand.

--wally.

0 Kudos
Message 2 of 3
(3,163 Views)

Hi coanda,

The methods that you describe are very similar. Using the DAQmxRegisterEveryNSamplesEvent registers a CVICallBack which will occur each time N samples are placed in the buffer. You can call the DAQmxReadAnalogF64 inside of the callback. This will take place in the DAQmx thread. If you were to create your own callback that would call the DAQmxReadAnalogF64 based on the acquired samples, you would be creating the same functionality as the DAQmxRegisterEveryNSamplesEvent.

Steve B

0 Kudos
Message 3 of 3
(3,097 Views)