Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Need an object or function to compute a Running Average

Each minute, I must compute the average of the 180 most recent values for a parameter, each of which was computed at one-minute intervals from current measurements. Referred to as a 3-hour Running Average, this is commonly used with environmental measurements. Other (shorter) time periods are also used. Some of the one-minute values are themselves averages of the values sampled during the minute, some are the maximum or minimum value found during the minute.

Any suggestions of how to do it within Lookout?
0 Kudos
Message 1 of 9
(4,471 Views)
Greetings,

From what you have described, it sounds as if you need more of a rolling average instead of a running average. Unfortunately we don't have an object to direct accomplish this for you, and it is a little more difficult when you key in the fact that you need to average 180 elements. In order to implement this though, it will take a little time and effort to utilize a combination of objects and expressions. Two methods come to mind:

1. Use a Sequencer object to multiplex through 6 different Sample objects. You know that the averages occur once a minute so you can set up your Sequencer to write a average to a Sample object, then transition to the next state and write the next average to the next Sample object and so forth. Then create an express
ion that adds up the first 30 elements of the 6 sample objects and divide by 180.

2. Daisy-chain 6 Sample objects together. You could use 5 expressions to write the 35th element of 1 Sample object to the 1st element of the next Sample object. Then create an expression that adds up the 35 elements of the first 5 Sample objects and the first 5 elements of the 6th, then divide by 180.

Hope this helps.

Patrick R.
Message 2 of 9
(4,469 Views)
Just thinking out loud and writing from ignorance here, so bear with me: Could this work?:

Construct a 180-element data table against which the averaging algorithm is run and some other mechanism used to create a shift register effect on the table data (apologies, PLC background).

Just a thought.
0 Kudos
Message 3 of 9
(4,469 Views)
I had tossed around the same Idea. I had also thought about using DDE to have a dynamic exchange with Microsoft Excel, but either way, when it came to the part of implementing the shift registers, I couldn't quite figure out how that could be done; easily anyway. It definately could work, but I am just thinking that by utilizing the natural shifting of the sample object, it may alleviate some thought and programming. Let me know how you are thinking of doing it though and I may be able to contribute some ideas.
0 Kudos
Message 4 of 9
(4,468 Views)
Patrick:

Many thanks. "Rolling Average" could be correct. I just checked the regs, and they avoid the issue by calling it a 3-hour average computed once a minute.

On a quick read, either method you suggested should be workable. We are a little new to Lookout, but I think we can do it.

Hopefully, NI will add a Rolling Average object to assure market penetration for this type of environmental calculation. We get these odd averages all the time, but until now, data reduction was done after the fact on a spreadsheet and entered into a written report. Now, we want to display the average to the equipment operator in real time so he knows when he is about to bust the regulatory restrictions so that he can be proactive.

Thanks.

Doug East
GreenTree Ser
vices, Inc.
Exton, PA
0 Kudos
Message 5 of 9
(4,467 Views)
Thanks for your reply.

We will have to read the manual again, but we will give it a try. We are already writing the one-minute data to a file, and my backup option was to read that file with a Visual Basic program and display the result on screen. We would prefer to do it all in the one Lookout program if we can.
0 Kudos
Message 6 of 9
(4,467 Views)
Even easier: use the centerline (CL) datamember of the x chart. It will create a rolling average from 2 to 4000 samples. You do not need to dispaly the X chart on a panel if you do not want.

Regards,
Tommy Scharmann
Message 7 of 9
(4,467 Views)
I hope I'm replying to the right person.

No Lookout guru here so I don't know how to implement the actual mechanics of the thing but, I know of two basic methods:

1. Copy element N+1 to element N, increment N, repeat.

2. Copy all elements of file (table) N to table P+1 for length x, copy P+1, etc. back to N+1. The data is now shifted up one position and the first position in N is available for new data.

I'm sure a counter object would have to be involved here somewhere.

Lookout doesn't have the loop capabilities that ladder logic does, which complicates (for me anyway) this sort of thing.

Hope this helps.
0 Kudos
Message 8 of 9
(4,466 Views)
Tommy:

Thanks for the suggestion. x chart is not yet in my Lookout vocaulary, but I will look it up over the weekend.

Doug
0 Kudos
Message 9 of 9
(4,466 Views)