08-25-2021 11:52 AM
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
Solved! Go to Solution.
08-25-2021 11:56 AM
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.
08-25-2021 12:04 PM - edited 08-25-2021 12:05 PM
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.
08-25-2021 12:15 PM
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:
I tried to convert this array to cluster and I received different errors. That's why I am confused about this too.
Thanks,
MMj
08-25-2021 01:22 PM
For the down sampling, I've made an example, you can try to recreate it yourself:
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).
08-27-2021 12:25 PM
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:
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
08-27-2021
12:31 PM
- last edited on
05-09-2025
09:44 PM
by
Content Cleaner
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.
09-02-2021 01:09 PM
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
09-03-2021 02:13 AM - edited 09-03-2021 02:20 AM
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.
More problems:
Example:

09-05-2021 06:41 AM
@GerdW wrote:
- 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…
- 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