Hi, I am new in PLC programs and I have a question. For a traffic light, I have to change from green to yellow and from yellow to red with 2 sec. delay. The problem is that when I activate the change the state is in green and after every 2 sec. is going in yellow for a very short time and then back to green again. Probably I am not using the TON timer properly. Thanks in advance:
CMD_STOP:
state := ST_GREEN;
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
state := ST_YELLOW;
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
state := ST_RED;
END_IF
END_IF
END_IF
CMD_STOP:
state := ST_GREEN;
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
state := ST_YELLOW;
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
timer(in := FALSE);
timer(in := TRUE, pt := T#2s);
IF timer.Q THEN
state := ST_RED;
END_IF
END_IF
END_IF