From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Average

Solved!
Go to solution

Hello, 

 

I'm trying to average signals collected every 200 ms for 5 mins. I already know how to setup a for loop and get an average of N iternations, but that's basically just noise filtering...I want to take all values over 5 mins and then average them to get a 5 min average of my signal. 

 

What I'm ultimately trying to do is to get a 5min average of my signal and use a shift register to hold than average value to use as my "initial value" or starting pressure in my case. I would then use that starting pressure as and calculate the percent pressure increase over time. After say 30% increase from the averaged 5 min pressure I would run a filter cleaning sequence, and repeat the process and get another 5 min average to use as my new initial value. I basically know how to do all that, but I'm just struggling with averaging the values...and I tried all sort of array stuff and looked at examples for hours and still couldn't figure it out.. 

 

I'm first  trying to make it work on a simple labview program (attached image) and once I figured it out I'll make it work on my actual program..

 

I'm using labview 8... 

 

0 Kudos
Message 1 of 10
(3,180 Views)

Is this VI ok with you to some extent. If not then what problem you think with this VI

 

Let me know.

 

Thanks

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 10
(3,173 Views)

Hey Ranjeet,

 

Thanks for your help, but I can't open the labview file because I have labview 8, is there a way you can save it as labview 8 file. 

 

Thanks,

Amir. 

0 Kudos
Message 3 of 10
(3,152 Views)

Why do you feel your simple example does not work?  Other than the never ending while loop it looks like it should calculate the average of the array you are generating.  Just out of curiosity what is your n value/

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 4 of 10
(3,142 Views)

The mean that is going to be generated in my simple example is the mean of my voltage analog input, meaning the average voltage of 200 iterations. That is going to my voltage at time t. What I want to do is basically somehow log those mean valvues for 5 mins and then spit out an average. So if you look at the table below, I would time the average of all value at 5 mins or 300s...

 

Makes sense?

 

 2-15-2013 12-08-54 PM.jpg

0 Kudos
Message 5 of 10
(3,137 Views)

Your wording is still not 100% clear to me.  I put some code together to demo what I think you are looking for, see attached.  The code produces 20 samples every second then at the end of the second they are averaged together and stored in an array.  Let me know if this is close to what you are looking to do.

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 6 of 10
(3,129 Views)

I'm sorry but I can't open the file you attached beacause I have labview 8.0 

 

 

What I am trying to say is, every second I'm going to get an average of 200 interations from the for loop..so as soon as I run the program 

 

I would get something like:

 

T=1s  Average = 41

T=2s  Average = 12

T=3s  Average = 52

T=4s  Average = 53

.

.

.

T= 299s Average = 15

T= 300s Average = 62

 

So I want to calculate the average of all the averages over 300s...basically sum the averages and divde by the number of points which is going to be 300..

 

2-15-2013 1-31-41 PM.jpg

0 Kudos
Message 7 of 10
(3,120 Views)
Solution
Accepted by Aquaman89

I thought I saved it for version 8.0 but may not have.  Try this one.  I think it is close to what you are looking for.

Herrlin

Just trying to spread the LabVIEW love.
0 Kudos
Message 8 of 10
(3,117 Views)

Thank you for your help herrlin.

 

It was pretty much what I was trying to do. I had to add a 3rd shift register because I really needed the mean of the values in the second column of arrays that. 

 

If you don't mind looking at my program...I'm having another problem and would grealty appreciate your help, again.. 

 

I'm trying to reset the array values back to defualt, i.e. 0, after a specified time and I tried to use an "invoke node" but that didn't help. So I put everything in a case structure, but for some reason the elapsed time would not work, so I don't know if what I'm trying to do would work...

 

If you look at my program it would make sense I hope.. 

 

Thanks Again. 

0 Kudos
Message 9 of 10
(3,083 Views)

One major issue with your VI is that fact that you are wiring false to while loops that terminate only on true.  So you have created infinite loops.  Also the average you added appears to be a running average just as a FYI this maybe what you want.  Running average means average of all available samples.

 

I have attached an example of what I would do to have a reset function on a given time.  I created a basic timer VI as I generally try to steer away from express VIs.  The timer VI is a functional global that is initialized to a given timeout time and then is polled to see if time has elapsed.  Once time has elapsed I use this info to reset the array values and the running average.

 

I am not sure how you will be using this so you may want to tweak it a bit if it will be a top-level VI or a subVI.  Also you should look to improve error handling. Currently the loop won’t stop on an error.  There currently aren’t any VI in it that will generate an error but most likely your sample generation code will. 

Herrlin

Just trying to spread the LabVIEW love.
Download All
0 Kudos
Message 10 of 10
(3,058 Views)