LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Customized rate of data logging

Solved!
Go to solution

Hi, 

I am a civil engineer and I don't have too much experience with LabVIEW. I've wrote the attached application to acquire data of 7 different device/sensor during a long fatigue test. Since each test would run for 2-3 days, I need to record the data in a text file with 50 Hz rate to have the minimum needed data for analysis. But the modules and chasse that I am using run for at least 1612.9 Hz and it will create a hug file with a lot of excessive data points. I am looking for any help including example or any guidance from experts to write a structure within my application to just log data with 50 Hz rate. more details: 

1. I am using LabVIEW 2020 SP1 on a PC with windows 10. 

2. NI compactDAQ-9178 chasse

3. NI-9235 module to acquire 4 different quarter bridge strain gauge analog data.

4. NI-9237 module to acquire 2 different full bridge strain gauge analog data (also using special scaling for each individual channel).

5. NI-9205 module to acquire 2 different direct voltage analog data (NSRE type, with special scaling for each individual channel).

6. This is a fatigue cyclic test. I am running sinusoidal loading regime with 2 Hz frequency. I need to have 20-25 points in each cycle to have the results (including peak and valley of load and other sensors). More data will make a trouble to process the results. So 25 point in each cycle (i.e. data acquisition with 50 Hz rate) would be the best and sufficient rate.

Any help would be appreciated. 

MMJ

 

Download All
0 Kudos
Message 1 of 10
(2,975 Views)

Also, I need to have XY plot to plot Load vs. Displacement results along the test. Is that possible with existing vi's? I tried to used XY chart and XY graph, but they plot my data versus time. 

 

Thanks for any help on this too. 

0 Kudos
Message 2 of 10
(2,973 Views)

It is very common to not log the entire raw data from hardware, you just have to decide how to downsample it. Since you're collecting data at 1613 Hz, but you want data at 50 Hz, You can wait until you have 32 data samples and that will get you approximately to 50 Hz. (Since you're probably collecting more than 1 sample with each read, you would actually break your data into 32 sample chunks). Once you have your 32 points, you can average those to a single point, or just take 1 and dump the other 32 samples (probably noisier). Then add your new sample to an array and continue collecting data.

 

I would not write to a file at 50 Hz. I would collect a couple seconds to 1 minute worth of data before writing to a file, because that can take longer than 20 ms.

 

The XY graph does not plot versus time, that's just the default axis label. You can feed it any X and Y data you desire and it will plot Y vs. X.

0 Kudos
Message 3 of 10
(2,969 Views)

Thanks for your comprehensive response. Actually I can say I am a beginner in LabVIEW. Despite your explanation was very clear and comprehensive, I am not sure how I can make a structure that can implement it. Is there any example that I can look at to learn how I can implement this structure within my application?

 

Also about the XY plot: I have arrays of data. I used "Index array" function to separate the desired X and Y data from the whole data. But when I wire them data to "Plot XY" function and I receive this error: 

MohsenJavid_0-1629911643438.png

I tried to convert this array to cluster and I received different errors. That's why I am confused about this too. 

Thanks,

MMj

0 Kudos
Message 4 of 10
(2,964 Views)
Solution
Accepted by MohsenJavid

For the down sampling, I've made an example, you can try to recreate it yourself:

Capture.PNG

 

For the XY graph, you cannot use "convert to cluster", it's expecting a certain kind of cluster. Since you can cluster up pretty much any data type, just putting your data into a cluster is not specific enough. You should have the context help open (ctrl + h) and then hover over the graph to see what kind of data is accepted. Click on "detailed help" to see more examples. Use the "bundle" node to create a cluster, and "build array" to create an array (for multiple plots).

 

capture 2.png

0 Kudos
Message 5 of 10
(2,944 Views)

Thank you so much for your help. I used this logic that you have shared. But when I wire it to "write to text file" function, I receive buffer size error. Please see the following screen shot:

MohsenJavid_0-1630085147348.png

 

The buffer size error is the reason that I put express VIs and DAQ assist aside and am using DAQmx functions. 

 

I really appreciate your time. 

Thanks, 

MMJ

0 Kudos
Message 6 of 10
(2,888 Views)
Solution
Accepted by MohsenJavid

We would need to actually see code to make sure you aren't doing something wrong.

 

But at a preliminary diagnosis, you may need to use a Producer/Consumer setup.  The idea being that you use a loop to collect data from the DAQ and then a second loop to write to the file.  You use a queue to pass the data from the DAQ loop to the log loop.



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
0 Kudos
Message 7 of 10
(2,885 Views)

Hi again, 

 

I really appreciate your help. Please see the attached VIs. I set the hardware acqusition rate to 2000 Hz and used the logic to down sample it to 40 Hz using Producer-consumer logic and also while loop. Both of them are resulting in buffer size issue. I actually don't know where I am missing or doing it wrong. Any help would be appreciated. 

 

MJ

0 Kudos
Message 8 of 10
(2,836 Views)
Solution
Accepted by MohsenJavid

Hi Mohsen,

 


@MohsenJavid wrote:
I set the hardware acqusition rate to 2000 Hz and used the logic to down sample it to 40 Hz using Producer-consumer logic and also while loop. Both of them are resulting in buffer size issue.

  1. One big problem is to set the "number of samples" at the DAQmxTiming function, especially for a sample mode of "continuous"! Please read the help for this function, it has a section which explains the meaning of the "number of samples" input and when you should (not) use it…
  2. Another problem is to set the same "number of samples" at DAQmxTiming and DAQmxRead function. It's really not a good idea to set the sample buffer exactly the same size as the amount of data to read…

 

More problems:

  • Inefficient data handling! Why don't you use a FOR loop to calculate the mean for all waveforms (no need to index each waveform individually!)? Why do you need to index several waveforms and build new arrays to show them on a chart (use ArraySubset!)?
  • Putting (potentially slow) file functions inside a tight DAQ loop! With the number you provide you try to read new samples at 20Hz (samplerate 2kHz, number of samples to read 100): you try to write to the file at the same speed. Using a producer-consumer scheme to place file handling in its own loop might help here…
  • cleanup the blockdiagram!
  • cleanup the frontpanel! Why are there 2 indicators way off from the rest of the frontpanel elements?
  • why do you read waveforms from DAQmx when all the datahandling (basically) only needs the samples? Why not read a 2D array of samples instead?

Example:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(2,821 Views)

@GerdW wrote:
  1. One big problem is to set the "number of samples" at the DAQmxTiming function, especially for a sample mode of "continuous"! Please read the help for this function, it has a section which explains the meaning of the "number of samples" input and when you should (not) use it…
  2. Another problem is to set the same "number of samples" at DAQmxTiming and DAQmxRead function. It's really not a good idea to set the sample buffer exactly the same size as the amount of data to read…

Related shameless plug.  The various special meanings of "number of samples" has been causing confusion for a very long time...

 

 

-Kevin P

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 10 of 10
(2,806 Views)