I am trying to make a function that count the number of True BOOL inn a specific Array and return the count to an INT AlarmArrayActiveAlarms.
I have tried the following, but the INT AlarmArrayActiveAlarms just keeps counting forever if one BOOL is True.
Any ideas what I am doing wrong? in this case i would expect the INT to return 3.
I am using a Modicon M340 PLC, with Unity Pro.
I have tried the following, but the INT AlarmArrayActiveAlarms just keeps counting forever if one BOOL is True.
Any ideas what I am doing wrong? in this case i would expect the INT to return 3.
I am using a Modicon M340 PLC, with Unity Pro.
Code:
AlarmTrigger: ARRAY[0..200] OF BOOL
AlarmArrayCounter :INT
AlarmArrayActiveAlarms: INT
AlarmTrigger[73] := true;
AlarmTrigger[74] := true;
AlarmTrigger[75] := true;
FOR AlarmArrayCounter:=0 TO 200 DO
IF AlarmTrigger[AlarmArrayCounter] = True THEN
AlarmArrayActiveAlarms := AlarmArrayActiveAlarms + 1;
END_IF;
END_FOR;