Conditional input summing on RedLion Crimson 3

M0Dark

Member
Join Date
Dec 2020
Location
Manchester
Posts
18
I have 7 input meters to my Red Lion HMI and I need to get 4 readouts on the panel which give the sum of all of meters selected for that output:

I have a page on the HMI where each of the inputs can be allocated to OFF or one of the outputs.

INPUTS
FT1, FT2, FT3, FT4, FT5, FT6, FT7
OUTPUTS
Flow_Sum1, Flow_Sum2, Flow_Sum3, Flow_Sum4

Is there a way I can quickly get the Software to allocate the correct outputs dynamically rather than me writing the 128 variants of the sum out for each output?
 
I think the attached does what you want. I did it in Crimson 3.0 so you can run it in the emulator. There is a program that runs when the page is displayed, the program is where the choice about which SUM to add to is made.
 
Thanks BryanG.
Annoyingly I can't work out how to actually test anything with the emulator as all of my inputs come from Testbed meters through signal conditioners into the HMI, and getting those signals to come over our network to my PC is beyond me.
I have created a tag for each sum that uses the following code to work out what to display, (Sum1 shown):
//Dynamically set the value of flow rate 1 depending on which flow meters were assigned to it.

int F1, F2, F3, F4, F5,F6, F7; //variables to fill with flow rates if required

if (F50_Meter_Select==1) //Was DN50 Meter selected?
F1=Analogue_Inputs.FT1; //Add it to sum if yes
else
F1=0; //Else add nothing

if (F150_Meter_Select==1) //Was DN50 Meter selected?
F2=Analogue_Inputs.FT2; //Add it to sum if yes
else
F2=0; //Else add nothing

if (F300_Meter_Select==1) //Was DN50 Meter selected?
F3=Analogue_Inputs.FT3; //Add it to sum if yes
else
F3=0; //Else add nothing

if (F600_Meter_Select==1) //Was DN50 Meter selected?
F4=Analogue_Inputs.FT4; //Add it to sum if yes
else
F4=0; //Else add nothing

if (FX4_Meter_Select==1) //Was DN50 Meter selected?
F5=Analogue_Inputs.Aux_4; //Add it to sum if yes
else
F5=0; //Else add nothing

if (FX2_Meter_Select==1) //Was DN50 Meter selected?
F6=Analogue_Inputs.Aux_2; //Add it to sum if yes
else
F6=0; //Else add nothing

if (FAir_Meter_Select==1) //Was DN50 Meter selected?
F7=Analogue_Inputs.Air_Flow; //Add it to sum if yes
else
F7=0; //Else add nothing

return F1+F2+F3+F4+F5+F6+F7;
 
You could simplify your code a bit by using the += operator to keep a running total. (x+=y is equivalent to x:=x+y)

Code:
//Dynamically set the value of flow rate 1 depending on which flow meters were assigned to it.
 
int total := 0;

if (F50_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.FT1;       //Add it to sum if yes
    
if (F150_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.FT2;    //Add it to sum if yes
    
if (F300_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.FT3;       //Add it to sum if yes
    
if (F600_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.FT4;       //Add it to sum if yes

if (FX4_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.Aux_4;  //Add it to sum if yes

if (FX2_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.Aux_2;  //Add it to sum if yes

if (FAir_Meter_Select==1)       //Was DN50 Meter selected?
    total += Analogue_Inputs.Air_Flow;  //Add it to sum if yes

return total;
 
As John showed, you don't need the Else parts of the program, they are redundant in his version.


The only way to simplify it further would be if you could put the data in to Arrays, which is what I did in my example. You can do all the calculations in one program if you use Arrays because you can step through each input automatically. You can run my example in the Simulator, enter data on the screen and it will update the totals once a second.
 

Similar Topics

Hi I have a Crimson 3.1 project which have conditional images and buttons managed by parameters shared with a PLC across a Modbus interface...
Replies
2
Views
876
In GT designer 3, the rig operator wants me to display a text string on the screen when a bit goes TRUE, and make it disappear when the bit goes...
Replies
5
Views
1,919
Hi all. I am attempting to have a button open up a popup screen but only if a certain controller tag has a value > 10. I have played around with...
Replies
3
Views
3,533
Hey guys, I'm working on an existing system where the old programmer (from like 25 years ago) used a bunch of conditional scripts in Wonderware...
Replies
2
Views
1,778
Hi all, This may or may not be a simple question. Another programmer has used a single OTE instruction on a rung with no other conditions to be...
Replies
12
Views
7,829
Back
Top Bottom