AN EXAMPLE

The example beginning in Figure 18.1 Traffic Light Subroutine shows a subroutine implementing traffic lights in ST for the ControlLogix processor. The variable ’state’ is used to keep track of the current state of the lights. Timer enable bits are used to determine which transition should be checked. Finally the value of ’state’ is used to set the outputs. (Note: this is possible because ’=’ and ’:=’ are not the same.) This subroutine would be stored under a name such as ’TrafficLights’. It would then be called from the main program as shown in Figure 18.1 The Main Traffic Light Program.

 

Figure 18.1 The Main Traffic Light Program

 

Figure 18.1 Traffic Light Subroutine