LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

High speed data acquisition - The application is not able to keep up with the hardware acquisition.

Dear all,

 

I am using NI USB-6361 DAQ card, which has a sampling rate of 1M/s according to its specification. However, when I tried to read the output signal and write to a file, the acquisition wouldn't last long with a rate more than 100k/s. For example, if I used a rate of 1M/s, the data acquisition did happen for a short period of time, then stopped. I need the process to last for at least a few seconds.

 

I don't know if it is a problem of the Labview program or my laptop. Please have a look at my VI. Any suggestions will be appreciated!

 

Thank you!

Capture.PNG

 

 

0 Kudos
Message 1 of 15
(6,896 Views)

I don't know what your level of skill/knowledge in LabVIEW is, so if you don't understand the following, please ask.  There will also be examples of these built-in to LabVIEW in the Help menu.

 

You'll want to do one of two things, if not both:

1. Use DAQmx VIs instead of DAQ assistant express VIs.  More complicated to set up, but a lot more obvious what you're doing and easier to debug.

2. Use 2 parallel loops.  Gather your samples in one, and send them to the second to be written to disk and/or displayed on screen.  That way any lag on your disk access doesn't delay sample acquisition.  The most common way is to create a queue reference outside both loops, and put an Enqueue in the sampling loop and a Dequeue in the disk writing loop.

 

 

Message 2 of 15
(6,876 Views)

I think it's because the writing is in your while loop. Writing to the hard drive take time, enough time for the buffer to be full. You don' have to write the data on every loop, you should stack it in memory and write it at a slower speed. Ideally in an other loop.

You should communicate between your two loop using ideally a queue. It come down to the "producer consumer" model described by NI here : http://www.ni.com/white-paper/3023/en/

You can use other mean to achieve that but that's the one i would recommend.

Message 3 of 15
(6,870 Views)

As Kyle said use the DAQmx VI's, but newer versions of the DAQmx API have logging built in, that is, no need for another loop. Look under the DAQmx examples in the example finder that contain logging.

 

mcduff

Message 4 of 15
(6,858 Views)

Hi Kyle,

 

I change the VI as shown below. It gives me some output but obviously it is not the correct one (the sampling rate in the output is not what I set for the acquisition). Would you please give me some suggestions?

 

1.PNG

Message 5 of 15
(6,821 Views)

Make your queue type a waveform instead of a single sample.  Currently, you are just getting the first sample of each data read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 15
(6,813 Views)

 Hi Crosrulz,

 

I changed the data type as waveform but I am not sure if it is correct. Also, the signals are from 2 channels only the first one is written to file in the previous VI. I changed the VI like this but I am still getting only one file with the data from one channel. Would you please give me some suggestion?

 

I am a newbie and my questions might be naive, but your suggestions really help me learn a lot. Thanks in advance.Capture.PNG 

0 Kudos
Message 7 of 15
(6,787 Views)

Data Flow.  Your loops on the bottom cannot run until the top completes.  You need to move your Enqueue for the second channel into the DAQ loop.

 

A much simpler solution would be to go into the DAQ Assistant and go to the "Logging" tab.  You can have DAQmx stream the data straight to a TDMS file and you do not need to deal with all of this Producer/Consumer.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 15
(6,775 Views)

You are right. But I need a high sampling rate such as 200k/s or so. That's why I use the Producer/Consumer structure, as suggested by some of the replies in this post.

0 Kudos
Message 9 of 15
(6,769 Views)

I am getting closer and closer to my goal, but another problem rises. Now I have 3 while loops, one for the data acquisition and enqueuing, and the other two for data logging. I want to terminate the data acquisition, while keep the logging happening until all data obtained is written into the files. So I presume that I should click the "Stop" button for the first loop (upper left one) and keep the VI running.

 

I can get two output files now. However the data points are only from one second. That means, when I set the sample rate at DAQ assistant to be 1M/s, I got 1M points, even if I ran the VI for several seconds. Is the VI overwriting whatever data is there in the file every time the queue gets a new batch of data?

0 Kudos
Message 10 of 15
(6,760 Views)