I am trying to learn structured text on the controllogix platform and have managed to fault the processor by creating an infinite loop.
My problem is i cannot understand what is wrong with my code.
Started with the following code:
Which function as expected. The "Lamps" tag is then copied to the outputs in a separate routine to switch on the outputs (using a Logix trainer suitcase). both of these routines are called continuously with no conditions for the "JSR".
I then changed the code as follows:
which created the infinite loop. I have tried several changes to this code trying to resolve the error but I am still faulting the processor.
I just wanted to create a running lamp going through each output in turn.
can anybody point me at a good resource for Structured text, and critique my code?
My problem is i cannot understand what is wrong with my code.
Started with the following code:
Code:
FOR y := 1 TO 10 DO
Lamps := Lamps + 1;
FOR x := 1 TO 1000 DO
x := x + 1;
END_FOR
END_FOR
IF Lamps > 150 THEN
Lamps := 0;
END_IF
Which function as expected. The "Lamps" tag is then copied to the outputs in a separate routine to switch on the outputs (using a Logix trainer suitcase). both of these routines are called continuously with no conditions for the "JSR".
I then changed the code as follows:
Code:
Lamps := 1;
FOR y := 0 TO 15 DO
Lamps := Lamps *2;
FOR x := 1 TO 1000 DO
x := X + 1;
END_FOR;
END_FOR;
IF Lamps > 2048 THEN
Lamps := 0;
ELSE Lamps := Lamps;
END_IF;
which created the infinite loop. I have tried several changes to this code trying to resolve the error but I am still faulting the processor.
I just wanted to create a running lamp going through each output in turn.
can anybody point me at a good resource for Structured text, and critique my code?