Citect - Comparing 6 variables and indentifiing the Variable with Highest value ?

EICS

Member
Join Date
Dec 2008
Location
Melbourne, Australia
Posts
323
This is a Citect SCADA question

I have Six variables of type REAL (Float) to compare and determine (identify) which variable has the highest value and then identify that Variable name.

Lets Call them

VarA = 5, VarB = 60, VarC = 45, VarD = 145, VarE = 90, VarF = 128

I'm struggling to find a way to do this logic simply and easily.


i need to identify which variable has the highest value example "VarD"


any Suggestions from the wealth of knowledge on this forum welcomed.
 
Last edited:
Sorry, cancel request i worked it out with citect
function max where it can compare 2 variables for the higher value, did this a few times for a good result.

FUNCTION
TEST()

STRING sTagbase;

REAL rTestA = 105;
REAL rTestB = 20;
REAL rTestC = 305;
REAL rTestD = 140;
REAL rTestE = 250;
REAL rTestF = 6;

REAL rTestMax;

WHILE True DO

// compare
rTestMax = Max(rTestA, rTestB);
IF rTestmax = rTestA THEN
rTestMax = Max(rTestA, rTestC);
ELSE
rTestMax = Max(rTestb, rTestC);
END // rTest max will have the highest value of A, B or C

rTestMax = Max(rTestC, rTestD);
IF rTestmax = rTestC THEN
rTestMax = Max(rTestC, rTestE);
ELSE
rTestMax = Max(rTestD, rTestE);
END // rTest max will have the highest value of A, B, C, D or E

rTestMax = Max(rTestE, rTestF);
IF rTestmax = rTestE THEN
rTestMax = rTestE;
ELSE
rTestMax = rTestF;
END // rTest max will have the highest value of A, B, C, D, E or F

IF rTestMax = rTestA THEN
sTagbase = "FM_D1FIB1";
ELSE IF rTestMax = rTestB THEN
sTagbase = "FM_D1FIB2";
ELSE IF rTestMax = rTestC THEN
sTagbase = "FM_D1FIB3";
ELSE IF rTestMax = rTestD THEN
sTagbase = "FM_D1FIB4";
ELSE IF rTestMax = rTestE THEN
sTagbase = "FM_D1FIB5";
ELSE IF rTestMax = rTestF THEN
sTagbase = "FM_D1FIB6";
END;END;END;END;END;END;
 
yes well done.... sometimes you get bogged down and miss the simple things

another 20 mins earlier and i would have used your suggestion.

Thanks Geoff for your reply.
 
Brute force works well too.
if a>b and a>c and a>d and a>e and a>f then a


But this only shows if a is biggest, you need also compare b,c,d,e,f separatetly.


another code:




value_max:= -32767
tag_number := 0

if in1 > value_max then
value_max = in1
tag_number = 1
end_if

if in2 > value_max then
value_max = in2
tag_number = 2
end_if

if in3 > value_max then
value_max = in3
tag_number = 3
end_if

if in4 > value_max then
value_max = in4
tag_number = 4
end_if

if in5 > value_max then
value_max = in5
tag_number = 5
end_if
 

Similar Topics

Hello, the system we use is Scada 7.5 series. We have usb key activ now we need additional key to make the system work, how do we solve this...
Replies
0
Views
82
So i've been at this for a long while, i have Citect Scada 2018, i have full access to everything but i can't seem to find any option or...
Replies
0
Views
99
Hello, i've been at this for months now, i tried creating accounts on the aveva website but it seems to never approve my accounts or at least when...
Replies
3
Views
127
Hello, I have a running project on Citect v5.42 and simatic net v6.4 I have created a new spare PC and loaded all software like Citect, station...
Replies
0
Views
88
Hello everyone, In a factory where we installed Citect 7.20 the computer began to show the first signs of end of life. They never considered...
Replies
0
Views
94
Back
Top Bottom