Need Advice - Running Average Calculation

I think that RMA's comments stem from his time in Germany rather than the rest of Europe. The prominence of STL in Germany stems from the almost total domination that the S5 had in this country and is far less evident elsewhere. In fact STL is commonly known as "German Programming" in some parts of europe.
 
A running average is a different thing than an instantaneous average. The equation for a running average is

((Average - (Average/N)) + C)/N
Where N is the number of samples and C is the number of items in the newest sample.

However, I agree with those who said it doesn't sound like he wants a running average but a rolling total.
 
Thanks for the clarification(s). I do indeed want a rolling total, as described in the original post but mis-titled. OkiePC's response does just what I need.

Thanks for the help.
 
RMA said:
First my apologies for an Off-Topic comment!

OK, I assume this is AB ladder, but frankly I wouldn't find it any easier to understand if it was in Siemens Ladder. Surely this is something that cries out to be done in STL or ST. And don't tell me that it's easier for the maintenance guys if it's done in ladder. I can't believe an average electrician with little programming experience can easily understand this.

Perhaps I see this wrong, because ladder is so much more common in US than in Europe, but I'd be curious to know what others think.

Give me ladder, In Siemens many of the instructions availabe in other PLC's to make it easy are missing and have to be built.
 
You know when you look at this it is not a running average. what i'm trying to do is get instantaneous average of bottle passing by on a conveyor.

If you take the totals included in the array and not divide them by 10 you will get instantaneous average speed. correct?
 
that depends do you want to know how many pass by per minute? if so then take the total every minute or overy 10 seconds and multiply the total by 6. place that value into the array. when you collect 10 samples devide by ten to get you average per minute. It's all in how you define what you term running average. Another way of doing this is to measure the time it takes from bottle A to bottle B devide that into 60 sec (1 Minute) so for example using simple math it with 2 seconds between each bottle you'll get 30 bottles a minute. However I would term this as the estimated rate per minute not average, average is value devided by the number of samples. So its up to you how you wish to determine the average in that we cannot tell you how many samples over what period of time your average is developed from
 
Last edited:
to explain the last part a little clearer take the distance between bottle a and bottle b devide that time into 60 sec this gives the estimated rate per minute place this value into your array use a counter to keep track of how many values are in said array. Then when you determine if you want your average to update every 30 sec or 1 min total the array then devide the number of samples(counter) into the total to get the average rate per minute. Just keep in mind and you may want to include this into your code if said conveyer is stopped you'll have to decide how you wish this to affect your values.
 
instantaneous average ???

contradictory - an average is based on the accumulation of more than one occurrance, so an instantaneous average is impossible, by definition.

the only two averages i know about....

1. average since the measurements started - cumulative average

2. average over the preceding XXX timeunits - rolling average

the first is easy to achieve, just accumulate the measured quantity, and divide by elapsed time units.

the second needs a block of data storage to record the instantaneous measurements covering the required rolling average period. this data is "shifted" each time a new measurement is acquired. The oldest will be lost. The rolling average is the sum of the data storage divided by its size.
 

Similar Topics

I'm currently working on a PLC setup and could use some advice on the best way to manage my power supply units (PSUs). Here's the configuration...
Replies
3
Views
419
So, I'm about to start my first ever project that include a servo motor Here some of the component i bought for the project so far: - PLC: Omron...
Replies
0
Views
391
Dear connoisseurs of antiquity and non-standard solutions, welcome) I don’t really hope, but suddenly someone had a deal and, most importantly...
Replies
0
Views
587
Hey guys, We have a metal container at work, we fill with saw dust (20fts x 15fts x 10fts) with the top open but we normally put a container...
Replies
4
Views
1,549
heya guys, For my project, i'm currently looking to add this type of linear encoder. The control company i'm working with told me they had bad...
Replies
6
Views
1,227
Back
Top Bottom