11-12-2021 04:28 AM
Hi everyone,
First of all, I want to remark that my knowledge with labview is limited, and that I never worked previously with real-time data processing.
I have done a vi to obtain data from ultrasonic acelerometers. The experiment lasts several hours, so it is not possible to record all the data in a single file. In addition, I only need the data for the regions when a specific threshold is exceeded.
In the vi I have programmed, there is a while loop that process the data every 2 seconds. In the firsts iterations it calculates the threshold, and for the next ones , the data is only written to a text file if there is any peak above this threshold/trigger .
This kind of vi works well for me up to 100kHz sampling frequency. For higher sampling frequencies (500kHz) the while loop starts to have a delay... and above 500 kHz it runs out of memory. I really don't need 2 seconds iterations, it could be done for 0.5 seconds or less. However, the problem here is the same, the while loop has not enough time to write the file.
Could anyone help me with ideas for a more efficient way to re-write this program?
Thank you in advance for your time!
11-12-2021 09:26 AM - edited 11-12-2021 09:27 AM
Just based on what I see, if it we're me, I'd setup a Queue to take the data that you want to save to a file and offload it to another loop. That would be the biggest benefit that I see.
11-12-2021 01:09 PM
Additionally, use the lower-level file primitives so you can be sure to open the file only once while looping over all your writes using a file function that takes in a file *refnum* rather than a file *path*.
-Kevin P
11-13-2021 04:08 AM
Hi,
one more comment: usually it is a bad idea to have a wait next to a DAQ(mx) Read function with a well-defined sample rate… (It doesn't matter if you use DAQmx or ULx.)
Usually you set a reasonable amount of samples to read (and process)!
11-13-2021 10:27 AM
Several comments (repeating some already mentioned):
Bob Schor
11-15-2021 05:12 AM
Thank you everyone for the suggestions!!
Special thanks for Bob Schor for this really detailed explanation.
I will try to implement all the changes proposed and I will give feedback as soon as I test it