24.01.2015 Views

PLC Programming

  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Controlling a Traffic Signal Unit...<br />

Action Off<br />

The result<br />

<strong>PLC</strong>_PRG<br />

In our hypothetical situation, night falls after seven TRAFFICSIGNAL cycles, for ten seconds the<br />

TRAFFICSIGNAL turns itself off, then we have daylight again, the traffic light unit turns itself on again,<br />

and the whole process starts again from the beginning. If you like, do another test of the current<br />

version of your program in simulation mode before we go on to create the POU <strong>PLC</strong>_PRG.<br />

We have defined and correlated the time sequencing of the phases for both sets of traffic lights in the<br />

block SEQUENCE. Since, however, we see the traffic lights system as a module of a bus system, e.g.<br />

CAN bus, we have to make input and output variables available in the block <strong>PLC</strong>_PRG. We want to<br />

start-up the traffic lights system over an ON switch and we want to send each of the six lamps (each<br />

traffic light red, green, yellow) the corresponding "signal command" for each step of the SEQUENCE.<br />

We are now declaring appropriate Boolean variables for these six outputs and one input, before we<br />

create the programme in the editor, and are allocating them, at the same time, to the corresponding<br />

IEC addresses.<br />

The next step is declare the variables Light1 and Light2 of the type Phases in the declaration editor.<br />

Declaration LIGHT1 and LIGHT2<br />

These deliver the Boolean value of each of the six lights to the above mentioned six outputs for each<br />

step of the block SEQUENCE. We are not, however, declaring the output variables which are<br />

foreseen within the <strong>PLC</strong>_PRG block but under Resources for Global Variables instead. The Boolean<br />

input variable IN, which is used to set the variable START in the block SEQUENCE to TRUE, can be<br />

set in the same way. ON is also allocated to an IEC address.<br />

Select the tab Resources and open the list Global Variables.<br />

Make the declaration as follows:<br />

3-10 CoDeSys V2.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!