11-29-2024 03:23 AM
Hello,
I am LabVIEW beginner, So probably this question will sound easy.
I am acquiring continuous data and displaying it without logging the data. I want to average my data for every 10 seconds and display the average. but every time 10 second pass, I want the average to start with the zero ( not taking previous value into the calculation). I guess it has to do something with the shift register but I can't wrap my head around it.
Any directions which way should I go to solve my problem?
Thanks in advance
Solved! Go to Solution.
11-29-2024 04:41 AM
Hi Davit,
@Davit00 wrote:
I guess it has to do something with the shift register but I can't wrap my head around it.
Unfortunately you forgot to attach your code.
(Downconvert when using a recent LabVIEW version. I prefer LV2019, others may suggest "LV2021 or older".)
@Davit00 wrote:
I want to average my data for every 10 seconds and display the average. but every time 10 second pass, I want the average to start with the zero ( not taking previous value into the calculation).
Sounds quite easy…
11-29-2024 05:00 AM
Hi I attached the code now, it is pretty short and easy but I just started it so it is missing a lot of functions that needs to have. sampling rate on DAQ clock instead of 1 is going to be 100. now I am not connected to the actual DAQ device so I am using the simulated one.
A bit more about the nature of the measurement. it is displacement measurement with the laser sensors. progress bars showing displacement from the reference points which I need to implement in the code where user can set top and zero points which then will become the range of the distance being measured.
Should I change while loop with timed while loop to acquire data for just 10 seconds and then place it in another while loop so acquisition wont stop after first 10 seconds?
Thanks
11-29-2024 05:39 AM
Hi Davit,
@Davit00 wrote:
Hi I attached the code now, it is pretty short and easy
You missed the sentence on downconversion of your VI… (File->Save for previous)
@Davit00 wrote:
sampling rate on DAQ clock instead of 1 is going to be 100. now I am not connected to the actual DAQ device so I am using the simulated one.
So you want to read 1000 samples (=10s * 100S/s): set a timeout of 12s and read 1000 samples…
@Davit00 wrote:
Should I change while loop with timed while loop to acquire data for just 10 seconds and then place it in another while loop so acquisition wont stop after first 10 seconds?
No. Not at all!
All you need is one main loop…
11-29-2024 09:44 AM
Just want to add 2 cents to your question,
there is a structure called running Average, where the mean is calculated at every new point, you start with a shift register that is initialized on the first iteration, and is an array filled with the same number of the first data read. Then at every iteration, the array on the shift register has it's value updated and the mean is calculated at every new data.
With this solution you can have average data from start and access to an average number at every new data being acquired.