Sample Program Action Switch1 With Green2 TRAFFICSIGNAL1 is red (STATUS:=3), TRAFFICSIGNAL2 green (STATUS:=1), and the delay time is at 5000. Action Green2 At Switch2 the STATUS of TRAFFICSIGNAL1 changes to 4 (yellow-red), that of TRAFFICSIGNAL2 to 2 (yellow). A time delay of 2000 milliseconds is now set. Action Switch2 With Green1 TRAFFICSIGNAL1 is green (STATUS:=1), TRAFFICSIG-NAL2 is red (STATUS:=3), and the time delay is set at 5000. Action Green1 The first expansion phase of our program is completed. Now you can com-pile it and also test the simulation.
In order to ensure that our diagram has at least one alternative branch, and so that we can turn off our traffic light unit at night, we now include in our program a counter which, after a certain number of TRAFFICSIGNAL cycles, turns the unit off. At first we need a new variable COUNTER of the type INT. Declare this as usual in the declaration part of PLC_PRG, and initialize it in Init with 0. TX1200 38 Version: 1.3