Siemens Program function Block logic

kirk

Lifetime Supporting Member
Join Date
Jul 2003
Location
Houston
Posts
71
Siemens S7-1500

I am trying to write some logic I just can't quite wrap my head around the cleanest way to write it, and was hoping for some advice

The short version is I need to see if a number is in range.

I have 4 tags (REAL Values). I want to make sure any value is within 20% of the other values.

The Long version:
I have 4 values that need to be averaged.
I am alarming on the average.
If any value is way off, I want to remove it from the equation.
So if all 4 values are within 20% of each other I add and divide by 4, if there is an outlier, I want to add and divide by 3.


I was going to use a simple IN_RANGE command, but the Tag_Min and Tag_Max are variable based on any of the other 3 values in the equation

I am thinking I can build a function block that does this, since I have multiple places in the program I want to use it.


Any help or insight is greatly appreciated.
 
There is no easy way to do this.
I am not sure about what you mean by 20%. 20% of full range? That would be a lot.
Also, I would use a function not a function block because it doesn't look like you need to save state between calls.

I would average the 4 numbers and then set the IN_RANGE value to the average+20% and average-20% then check if all 4 numbers are in range. If all are all in range then you are done. If one number is out of range then repeat with the other 3 numbers.

What it 2 numbers are 20% different from the other 2 numbers?

I think there is something wrong that you are trying to cover up with software. How often is there 1 or more numbers more than 20% of the average?
 
my guess,

if all PV max value had same value,

PV1+PV2+PV3+PV4 / 4 (divider) = average

PV1(real value) / PVmax(real value) X 100% compare with <20% if active move value '3' to (divider)

active the bit,

if - PV2(real value) / PVmax(real value) X 100% compare with <20% if active move value '2' to (divider)

and cutoff/disable the PV1 comparisan,

and so on
 
Hi,

This sounds like something from functional safety :).

You have to site down and think this over.
If you are going to look if a single value is 20% deviated from the average of the others (including itself?), you are looking at a big big deviation.
For 4 values, I would look at the highest and lowest value. And compare those. Or like stated above, compare to the values ranked 2nd and 3rd.

I thought our 2oo3 was complicated, I guess 3oo4 is the next?
 
Yes, it can be done in an FC, no need for FB.

What you have to clarify, is what is meant by "any value is within 20% of the other values".
Is that meant absolutely or relatively ? Can the values have negative sign ?
 

Similar Topics

Hi everyone, I want to upload the program from my CPU317TF-2 DP to my PC via connecting to CP 343-1 Advanced since it has LAN ports and the CPU...
Replies
1
Views
167
Hi there! This is something so old and having machine with it....... Last time unit was powered around 3yr ago and it did not work since than...
Replies
5
Views
230
First of all, it's a pleasure to join this community, I already have a few years of exp in this sector but never registered on a plc forum, so...
Replies
4
Views
786
Hi, There's a problem I face with upgrading the OS from XP which has the Step 7 Lite installed to windows 10. As I can't use a cracked version of...
Replies
2
Views
618
I have converted a Siemens OP7 program to a new Delta DOP107BV. It is all working as expected except for the timer values. I am using MW36 as the...
Replies
6
Views
940
Back
Top Bottom