LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging the data

Solved!
Go to solution

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 

0 Kudos
Message 1 of 6
(229 Views)

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).


  1. Read the data for 10s.
  2. Average the data and display the result.
  3. Back to step 1.

Sounds quite easy…

Best regards,
GerdW


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

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  

0 Kudos
Message 3 of 6
(206 Views)
Solution
Accepted by Davit00

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(189 Views)

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. 

 

0 Kudos
Message 5 of 6
(160 Views)

Really Helpful Vi. Thanks so much 

0 Kudos
Message 6 of 6
(88 Views)