From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I Acquire data and make tdms file for a variable period using low level api

Hiii,

I am using NI-cDAQ 9134 and module 9223 for data acquisition. I have developed a code which acquiring the data for 1 minute at 1M sampling rate using Write to measurement file. But since the file size is 1.34GB thus, we require to make a smaller file say of 15seconds or 30 seconds. I tried to develope that code also but since I have used producer consumer model , thereby on providing a delay to consumer the memory is getting full. Also, it is writing data of 1 second only. I have attached both the codes, kindly give some suggestions.

Download All
0 Kudos
Message 1 of 5
(2,933 Views)

There are lots of Producer-consumer DAQmx examples out, you should study some of them. I really recommend using a typdefinied cluster, so you do not need to use 2 Queues!

The main problem with your VIs is that, you do not understand the main concept how a Producer-consumer design works: you put timing in your Consumer loop. The consumer should only act when it Dequeues an element from the Queue, and do not slow it down!

Regarding to your question how to save your data, here are some hints:

  • You say you want to sample data with 1 MHz. Do you want to save only part of this data, or you want to average it?
  • If you do not need all the 1 million data points per sec, just sample it slower. Maybe you do not even need hardware timed acquisiton, just use software timing plus "on demand" DAQmx Read...?
  • Another option: you know you get 1M points per second into the consumer via the Queue. Just put a shift register into your Consumer loop, and count up. At every 15 seconds make a Case structure input true, and in this True case write the actual data package to file (hint: modulo devision)

The most simple solution even do not require a Producer-consumer design: just use the TDMS file format along with the "DAQmx Configure Logging VI": http://www.ni.com/white-paper/9574/en/

 

Edit: and do not have anything in your Producer, only the DAQmx Read and the Enqueue function, display data/work with data only in the Consumer loop.

0 Kudos
Message 2 of 5
(2,908 Views)

Thank you sir for the help. Actually we need this much rate only since we have to acquire underwater acoustics. Also, we are using 3 channels to acquire data having 1M sampling rate per channel. We require only some points from 1 millions points which needs to be above some threshold value which we define. I also need to time stamp the data using low level apis only , which i am not able to get. I am just getting information of 3 seconds only. I used various techniques but didnt work anything. I am just a beginner in using Labview , it would be really helpful if i get to see some examples.

0 Kudos
Message 3 of 5
(2,896 Views)

I already wrote you what to do:

  • Delete the time delay from the consumer loop
  • Use low level TDMS file functions in the consumer loop, and write the data to three channels (http://zone.ni.com/reference/en-XX/help/371361J-01/glang/tdms_file_write/)
  • Move your Graphs to the Consumer loop
  • Create a shift register in the consumer loop, and check how many seconds are elapsed using a modulo devision, if you get the required value, write out the required data to TDMS:
    • pppppp.png

 

Take the available LV tutorials if you are a beginner in LabVIEW: http://www.learnni.com/

0 Kudos
Message 4 of 5
(2,887 Views)

Hello sir,

 Moving graphs to the consumer loop  is creating trouble in logging file.

I have removed thye delay. But i am getting buffer overflow error. I am using write to measurement vi since I want to have time stamping channel apart from 3 channels information in one file only. I tried it using low level api for writing tdms file but it was not providing me the time stamping information in seperate channel.

0 Kudos
Message 5 of 5
(2,831 Views)