Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

"Real-Time" Acquisition & Display of Lower Frequency Device Data Using NIDaq32.DLL (via C/C++)

I have a measurement system that is highly modular written in C/C++ utilizing COM via ATL. The application (EXE) communicates with a COM object I wrote in a separate DLL. This COM object is responsible for communicating with the Nidaq (6.3) libraries via DLL calls (GetProcAddress).

I have a simple turnpot meter (0-5V) connected to 3 channels (0,1,2). Sampling rate is 250Hz. I have been trying my best efforts to acquire the data and "simultaneously" display it in a window. I have implemented the acquisition using asynchronous and double-buffering approach. As an example, the total # of scans is 1000 and the buffer was 20 so I could get 10 samples at a time (with the DAQ_DB_H
alfReady). I setup a separate thread to do the acquiring, where every 10 scans (when buffer half full) I would obtain and write to a global buffer of TotalSamples * 3 Channels. I then setup a windows timer for every 250 ms to get the "next" 10 samples and display on the screen.

The problem is that when the acquisition thread is normal priority, sometimes the displaying causes the thread to miss data (nidaq already began writing over the buffer I wanted). When I set the acquisition thread to highest priority, the data is not displayed until the acquisition has completed.

Any thoughts?
0 Kudos
Message 1 of 2
(2,328 Views)
I would suggest increasing the size of your buffer and the number of samples read. Try setting your buffer to 200 and the number of samples to read each time to 100. You have to get over the overhead of transferring the data. In most cases the DAQ devices do not like to transfer small chunks of data, because it uses a DMA transfer.

Also, it is possible that your drawing function is just taking to much time to complete. Have you run some tests to see how much time it takes to complete? I would suggest using the Measurement Studio Graph controls for displaying data to a screen.

Finally, you might have graph the data after you finish acquiring it. I understand this is only a valid solution for non continuous cases.

I hope this helps,

Joshua
0 Kudos
Message 2 of 2
(2,328 Views)