We have defined and correlated the time sequencing of the phases for both sets of traffic lights in the block SEQUENCE. Since, however, we see the traffic lights system as a module of a bus system, e.g. CAN bus, we have to make input and output variables available in the block PLC_PRG. We want to start-up the traffic lights system over an ON switch and we want to send each of the six lamps (each traffic light red, green, yellow) the corresponding "signal command" for each step of the SEQUENCE. We are now declaring appropriate Boolean variables for these six outputs and one input, before we create the programme in the editor, and are allocating them, at the same time, to the corresponding IEC addresses.
The next step is declare the variables Light1 and Light2 of the type Phases in the declaration editor.
These deliver the Boolean value of each of the six lights to the above mentioned six outputs for each step of the block SEQUENCE. We are not, however, declaring the output variables which are foreseen within the PLC_PRG block but under Resources for Global Variables instead. The Boolean input variable IN, which is used to set the variable START in the block SEQUENCE to TRUE, can be set in the same way. ON is also allocated to an IEC address.
Select the tab “Resources” and open the list “Global Variables”.
Make the declaration as follows:
The name of the variable (e.g., IN) is followed, after AT, by a percent sign which begins the IEC address. I stands for input, Q for output, B (used in the example) stands for byte and the individual bits of the module are addressed using 0.0, 0.1, 0.2, etc.