TheWaterboy
Lifetime Supporting Member + Moderator
Can the following be made into a SINGLE Ladder so it could be incorporated with more ladder code and then made into an AOI?
I have been trying and can't figure out how.
The FOR instruction calls a separate routine so that's out since an AOI can only have one routine. I can't devise an alternative method in ladder.
I have been trying and can't figure out how.
The FOR instruction calls a separate routine so that's out since an AOI can only have one routine. I can't devise an alternative method in ladder.
Code:
// Counts Alarm Bits
AlarmBitsTrue:=0;
For I := 0 to (NumOfArrayWords-1) DO
Element :=Alarm_Buffer[I];
While (Element <> 0) do
Element := (Element & (Element -1));
AlarmBitsTrue := AlarmBitsTrue +1;
end_while;
end_for;
BitCount := AlarmBitsTrue;
If (BitCount > 0) then
AlarmPresent:=1;
else
AlarmPresent:=0;
end_if;