LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Measurement file at different Sampling Rates

Solved!
Go to solution

Hello Experts,

 

I am new to LabView beyond the basic use. I am measuring data at two different sampling rates (1000 Hz and 200 000 Hz). I would like to write data to a measurment file (or files) and I need to make sure the data is synhronized. 

I have a cDAQ NI9185 with a NI 9203 (reading flowrate and temperature of a process continiously at 1000 Hz) and a NI 9222 reading from a fast pressure sensor at 200 000 Hz. How can I write this data and keep the times synhronized. example: Every 200 samples, one sample of the slower card is read, keeping everything in sync. 

GasperB_0-1776953247075.png

 

Thank you!

0 Kudos
Message 1 of 6
(417 Views)

Hi Gasper,

 


@GasperB wrote:

How can I write this data and keep the times synhronized. example: Every 200 samples, one sample of the slower card is read, keeping everything in sync. 


Several suggestions:

  • Don't use ExpressVIs, the will make your code more complicated in the end.
  • Learn basic DAQmx functions, as explained here and in all those example VIs in the example finder!
  • Read waveforms with DAQmxRead, so your measurement data automatically come with a timestamp (and dt).
  • Save all the data to a TDMS file (maybe even to different channel groups), so you got them in a compact data format.
  • As you write waveforms to the file you will ALWAYS have timestamps for each sample in post-processing!

How well do you need to "synchronize" your data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(389 Views)
Solution
Accepted by GasperB

Because your 9185 automatically selects the chassis backplane clock as the master timebase, your code (just) needs to share a start trigger for synchronized measurements.
Try code like this (I modified a shipping DAQmx example):

dsbNI_0-1777052789030.png

 

And I will echo some of Gerd's suggestions (emphasis mine):

  • Read waveforms with DAQmxRead, so your measurement data automatically come with a timestamp (and dt).
  • Save all the data to a TDMS file (maybe even to different channel groups), so you got them in a compact data format.
  • As you write waveforms to the file you will ALWAYS have timestamps for each sample in post-processing!



Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
Download All
Message 3 of 6
(334 Views)

Hello DSB. 

 

After a bit of tweaking your solution ended up being the correct one. I especially didnt know the difference of TDMS and .lvm, as I was using a normal .lvm to store my data, which was giving me buffer problems. Things are working now. Thank you again. 

 

Regards

Message 4 of 6
(201 Views)

@GasperB wrote:

Hello DSB. 

 

After a bit of tweaking your solution ended up being the correct one. I


One more tweak may be necessary, if it has not been already fixed. In the solution, you have two different sample rates but are acquiring the SAME number of points for each loop. Adjust the number of points for each task such that Sample Rate x Number of Points equals the same time interval for both tasks, e.g., sample rates of 1000 and 500 would have Number of points 100 and 50 respectively.

Message 5 of 6
(167 Views)

@mcduff wrote:
...two different sample rates but are acquiring the SAME number of points for each loop. Adjust the number of points for each task such that Sample Rate x Number of Points equals the same time interval for both tasks.

good catch: I forgot to change the name (and default value) of the control "Samples per Loop" which should have been renamed "block duration" and saved with default value of 0.1 s. The code was/is implemented such that each Read acquires the same duration of samples.

Definitely want:
task1(block duration) = task1(samples to read)/task1(sample rate) = task2(samples to read)/task2(sample rate) = task2(block duration)

I bet changing name and default value were some of the tweaks implemented by OP.  ; )

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