LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

high speed daq streaming with queue

Solved!
Go to solution

Hello,

I am hoping the experts here can help with my problem.  I am trying to stream high speed (1-2 MSPS) DAQ data to disk.  I want to utilize a queue and 2 parallel loops, one to read the data from the DAQ and put it in the queue, and the other to pull from the queue and write to disk. 

In my first test I am able to do that when I use a single double as the queue element.  I run the code with a sine wave input and can extract that from the .bin file of doubles that I am streaming to.  This does not support the data rates that I need, so I want to use and array as the queue element and then read larger chunks of data from the DAQ.  It appears to me that the data is read correctly,  but when I read the data from the file it looks like it is missing samples.  Any help/suggestions is appreciated.  I will post my code.  Thanks

0 Kudos
Message 1 of 5
(3,772 Views)
Solution
Accepted by topic author whitsy

Hi whitsy,

 

why don't you use the built-in feature of DAQmx to stream the DAQ data directly into a TDMS file?

 

On your VI:

When using WriteToBinaryFile you use the default setting of including the array size within the data. Maybe this is disturbing you when reading the data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,759 Views)

GerdW,

I did not know that this TDMS streaming was a thing, or now that I know it is a thing what the performance is.  As I had stated earlier I will be trying to stream up to 2 MBPS to disk.  

There is a 2nd reason why I wanted to try the queue.  At a later time I may be adding some kind of signal processing to the data in real time and I wanted to utilize the 4 cores of my computer for this.

I will look into the TDMS for my immediate concern, but I was looking to see if anybody saw anything glaring in my vi as to why my logged data was wrong.  Thanks

0 Kudos
Message 3 of 5
(3,718 Views)
Solution
Accepted by topic author whitsy

The Stream To TDMS functionality in DAQmx is more efficient than a Producer/Consumer.  It avoids layers of software to get the data to a file, making it efficient.  Granted, it might still struggle with the data rates you need, but it will be better.

 

The only thing I saw in your code as far as structure was the wait in the consumer loop.  You typically want your consumers to run as fast as possible.  If they get ahead of the producers, then they will sleep waiting for data to dequeue.  So very rarely should you have a wait in the consumer loop.


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 4 of 5
(3,706 Views)

Gerdw,

I change me .vi to write to a tdms file. Everything is working great. Thanks, whits. 

 

0 Kudos
Message 5 of 5
(3,667 Views)