Average calculation siemens S7-315

pejo

Member
Join Date
Jan 2008
Location
Stabroek
Posts
5
I want to take a sample every minute from the analogue value, and after 24h calculate the average value. Does Siemens has a standard SFB for this or do I have to write it myself? Does anyone have already written something similar?

thx
 
I'm not aware that such standard FB exists, but it is fairly easy to write it...
Try searching forum, there were similar threads. If you still need help, we'll make it together
 
I did the same the other day, but on AB.
Make a fifo with 24 positions, load the fifo every minute as you said, then begin to download the fifo thru a fifo unload instruction when the fifo is filled out, then you make the average of the 24 values located in the fifo register, just sum the 24 values and divides by 24. From that point on every data that is entered into the fifo queue, can be used to average the fifo register when the data in the 24th position leaves out the queue.
 
I assume that by 24h you mean values for 24 Hours, values being read every minute. That adds up to a lot of data (1440 values).

What you can do is use Time of day interrupts for Minute and 24 Hours. In your Minute routine simply add the latest value to an accumulating Total(REAL). In your Day routine divide the Total by 1440 to produce your average and clear the Total.

As an alternative you could store all the one minute readings for one hour. Add them and divide by 60 to produce an hourly average.
Store 24 hourly averages and at the end of the day average the averages to obtain your daily average.
 
I’m also thinking the same way. Last night I program something to calculate the average value every minute. After 24h I write this value into a DB, I use the day from the PLC to calculate the DW I need.

When I finish the tests I will post this.
 

Similar Topics

Does this instruction calculate values during a single scan, or does it require number of scans based on element count in the array? For Example...
Replies
3
Views
113
Hi, I need a bit of help. We have a labeler that is experiencing some crazy down time and we want to show the supervisors a few more metrics to...
Replies
3
Views
1,820
Hi! Currently I'm trying to implement an average calculator in a S5-95U. In order to do the job, I'm using the folowing equation: M(k) =...
Replies
16
Views
8,607
Hi Guys! I have resently got my hands on a small project, getting data from a check weigher that speaks Modbus RTU. I want to use the ML1100...
Replies
6
Views
6,922
Hello, I'm a novice seeking advice. I need to claculate and display a running average for the number of items passing by on a conveyor. The...
Replies
24
Views
11,310
Back
Top Bottom