Moving Average in S7-300

Hal9000

Member
Join Date
Jun 2010
Location
London
Posts
140
Does anyone know if there is a standard block to perform Moving Average in S7-300?

I can't see one in the library, even though Siemens suggest MOV_AVG

My CPU is S7-315 PN/DP
 
Hi, Thanks for the information.

I've downloaded the OSCAT311_Step7.zip file from the link and I can see the FILTER_MAV_DW in the .pdf document.

I've not used this material before, so I would be grateful if you could tell me what do I do with the zip file? Do I simply retrieve like a normal S7 archile file and drop it into S7_LIB?

Regards,

Justin
 
If you have any problems with what you have, I'll be glad to share a rolling average function that takes X samples, throws out the high & low, and averages the rest. I have it for INT and for REAL inputs.
 
Hi Paul,

I would be very grateful if you could, I think your solution sounds more in line with what I need.

Basically I need to average my PV over say 10s and chop out some noise. My PV is a REAL.

Correct me if I'm wrong, but when you throw out highs and lows is that classed as "weighted", or am I completely on the wronmg track?

Cheers for now,

Justin
 
Not sure about the weighted question. It probably wouldn't be too hard for someone to remove the "throwing out high and low" part.

Here is a library with the requested rolling average code.
 
Correct me if I'm wrong, but when you throw out highs and lows is that classed as "weighted", or am I completely on the wronmg track?

I think this would be called a "Winsorized mean":

http://en.wikipedia.org/wiki/Winsorized_mean

If you know that your signal has more outliers than noise in it, a median filter will give you a better signal than a simple first degree low-pass filter.
 
Thanks Paul,

I don't have S7 simulator on my PC, so I won't be able to test it until I get to site.

If I want to sample say 60 values at 1/value/sec. Should I simply call the block once a second to do this?

Justin
 
This has me wondering

It was mentioned that the PV was being filtered, is this a PV for a PID? If so then has anybody considered what adverse affects this will have on the response on the PID? Does anybody know how this will affect the bandwidth of the feedback device?

Excuse me for being an old fuddy duddy engineer but tried reducing the source of the noise first?

The sample time and the number of samples affect the bandwidth of the filter. Do you know how? If not, then why 10 samples as opposed to 20 or 30 or even 2?
 
Thanks Paul,

I don't have S7 simulator on my PC, so I won't be able to test it until I get to site.

If I want to sample say 60 values at 1/value/sec. Should I simply call the block once a second to do this?

Justin

Exactly. I put examples in the library in OB1. Right now they are being called every 100ms. Change the timer preset to 1 second and make the length "60" and then run it in the simulator.

This code uses an FC and a global DB.
 
It was mentioned that the PV was being filtered, is this a PV for a PID? If so then has anybody considered what adverse affects this will have on the response on the PID? Does anybody know how this will affect the bandwidth of the feedback device?

Excuse me for being an old fuddy duddy engineer but tried reducing the source of the noise first?

The sample time and the number of samples affect the bandwidth of the filter. Do you know how? If not, then why 10 samples as opposed to 20 or 30 or even 2?

These are excellent question for the original poster.

I use a rolling average for display purposes. For example on low-end systems with low margins it is common to use inexpensive load-cell amplifiers. This signal always fluctuates, making the displayed weight on the HMI go up & down. It bothers the operators. So I filter the display tag with a 5-second rolling average. In the PLC code I use the value from the amplifier.

I have used a 3-second rolling average for the PV of a PID loop controlling temperature in a room the size of two football fields. The loop is called once per second and tuned S L O W.

But you are concerned about loops that must react fast...
 
The PV I mentioned is not being used as a PV in my PID loop. Instead I'm reading two Integers over modbus, one is a whole part the other the fraction part. I convert these two integers to a real and display the "inlet water temp" on my MP377.

The issue is my modbus values are a little erratic, I've proved it's not my code because I get the same effect in Kepware. So I suspect it's a feature in the slave device. This is why I would like to chop off the high and low and then say average over a minute.

The averaged value will then (hopefully) be more stable and I will use this in a fallback routine to switch my PID loop to manual if the temp goes above 35 deg C > 30sec.

If it doesn't work I will arrange to have a temp transmitter installed and wired back as a 4-20mA.
 
Are you reading the data from the modbus device data "consistantly" as you would for a Profibus device ?
 

Similar Topics

Hi all, I'm trying to set up a moving average in PME 8.6 and apparently there is such an instruction (MAVG) but when I try to insert it into an...
Replies
6
Views
2,213
I know unity pro comes with a AVGMV block. Does anyone know how to use it so it samples input values over a time period of say 60 seconds and...
Replies
3
Views
4,556
How can I average values in an array when the array is not full? For example, I have an array of size 1440. However, if only six values are...
Replies
6
Views
4,402
Hello all, The task at hand is a little tricky for me... a novice at best... This is all about an alarm and storing data into rs batch. I have...
Replies
3
Views
5,429
Hi all, I am pretty new to the PLCs and I had a question about data handling. I get readings from a pressure sensor and display it to the screen...
Replies
15
Views
5,959
Back
Top Bottom