LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer Loop for Analog Input task

Hello,

 

I use a PCIe-6343 DAQ card to acquire signals from 10 channels. I am trying to do the following task. I have an experiment that runs for up to a minute. I would like to record the data continuously for the entire minute. Let's say I acquire at 10kHz for 60 sec. With such a high number of samples, I am running into memory issues. Hence, I plan to continuously write to a TDMS file using a producer consumer loop. However, I am unable to use the loop to acquire exactly the number of samples (10k*60). I looked at the examples and it is not too helpful for me.

 

Any ideas on how to proceed with this? 

 

Thanks,

Rahul

 

 

0 Kudos
Message 1 of 4
(228 Views)

Thank you for showing your code -- it really helps us to know "what you know" and "what you've tried".

 

I'm going to guess that you are using the Dreaded DAQ Assistant (my apologies if my guess is wrong).  if so, you need to banish this monster and learn to use DAQmx (look up "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications" (or words very similar to that).

 

Create a State Machine (I'm a very big fan of the Channel Message Handler for this).  Set your A/D in DAQmx to acquire, say, 1000 samples (0.1 second) (the "Acquire" state) and keep calling this state (by making the Next State "Acquire") until you've collected 600 (which will be 10 seconds).  Inside the Acquire state, your "Producer", export the data to the Consumer (I use a Stream Channel for this).  You'll want the file already opened in the Consumer (you can figure out how to do this -- one way would be to have the Producer do this before the Consumer starts, or, alternatively, have the Producer send not only the 1/10 second data but also the File Name to use, and put some smarts in the Consumer to open a file the first time it is called with that filename).  [You'll notice I'm talking off the top of my head, because I don't have anything helpful from you ...].

 

The beauty of the Producer/Consumer is that the Queue or Stream is "elastic" and can expand so that if it takes a whole second to get the Consumer ready to write data to disk, it doesn't matter, because once it starts writing, it will run faster than the Producer and quickly "catch up" and be waiting when the next dollup comes down to it.  

 

Oops -- gotta go, end of the day.  Have a nice weekend.

 

Bob Schor

0 Kudos
Message 2 of 4
(179 Views)

@yezdi777 wrote:

Hello,

 

I use a PCIe-6343 DAQ card to acquire signals from 10 channels. I am trying to do the following task. I have an experiment that runs for up to a minute. I would like to record the data continuously for the entire minute. Let's say I acquire at 10kHz for 60 sec. With such a high number of samples, I am running into memory issues. Hence, I plan to continuously write to a TDMS file using a producer consumer loop. However, I am unable to use the loop to acquire exactly the number of samples (10k*60). I looked at the examples and it is not too helpful for me.

 

Any ideas on how to proceed with this? 

 

Thanks,

Rahul

 

 


You should show some code. But, producer-consumer NOT needed. Use the built in logging function of DAQmx, it will save data to TDMS files for you, all you need is one loop.

 

I am guessing if you look at the example finder, Analog input Voltage - Continuous, it will do 90% of what you want. You will have to modify for UI, etc..

0 Kudos
Message 3 of 4
(167 Views)

The shipping example 

<examples>\DAQmx\Analog Input\Voltage - Continuous Input.vi

seems like a good starting point to meet your requirements.

You can manually stop the loop when experiment is over, or you can program the loop to stop automatically after 60 s (or an equivalent number of iterations).

The example supports DAQmx logging to TDMS files. Streaming to disk in smaller block sizes (such as 0.1 s) means that you don't have to acquire 60 s of data in a single block, so your application never needs to have too much memory allocated.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 4 of 4
(158 Views)