24.01.2015 Views

PLC Programming

  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

'Login' to get into simulation mode. Start program with 'Online' 'Start'. Open POU ABLAUF by a<br />

double-click on entry "ABLAUF" in the Object Organizer. The program is started now, but to get it run,<br />

variable START must be TRUE. Later this will be set by <strong>PLC</strong>_PRG but at the moment we have to set<br />

it manually within the POU. To do that, perform a double-click on the line in the declaration part,<br />

where START is defined (START=FALSE). This will set the option "" behind the variable in<br />

turquoise color. Now select command 'Online' 'Write values' to set this value. Thereupon START will<br />

be displayed in blue color in the sequence diagram and the processing of the steps will be indicated<br />

by a blue mark of the currently active step.<br />

When you have finished this intermediate test use command 'Online' 'Logout' to leave the simulation<br />

mode and to continue programming.<br />

"SEQUENCE" second expansion level<br />

In order to ensure that our diagram has at least one alternative branch, and so that we can turn off our<br />

traffic light unit at night, we now include in our program a counter which, after a certain number of<br />

TRAFFICSIGNAL cycles, turns the unit off.<br />

At first we need a new variable COUNTER of the type INT. Declare this as usual in the declaration<br />

part of SEQUENCE, and initialize it in Init with 0.<br />

Action Init, Second Version<br />

Now select the transition after Switch1 and insert a step and then a transition. Select the resulting<br />

transition and insert an alternative branch to its left. After the left transition insert a step and a<br />

transition. After the resulting new transition insert a jump after Switch1.<br />

Name the new parts as follows: the upper of the two new steps should be called "Count" and the lower<br />

"Off". The transitions are called (from top to bottom and from left to right) EXIT, TRUE and<br />

DELAY.OK. The new part should look like the part marked with the black border in the following<br />

image:<br />

3-8 CoDeSys V2.3

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

Saved successfully!

Ooh no, something went wrong!