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 />

"TRAFFICSIGNAL" declaration<br />

Let us now turn to the POU TRAFFICSIGNAL. In the declaration editor you declare as input variable<br />

(between the keywords VAR_INPUT and END_VAR) a variable named STATUS of the type INT.<br />

STATUS will have four possible conditions, that is one for the TRAFFICSIGNAL phases green, yellow,<br />

yellow/red andred.<br />

Correspondingly our TRAFFICSIGNAL has three outputs, that is RED, YELLOW and GREEN. You<br />

should declare these three variables. Then the declaration part of our function block TRAFFICSIGNAL<br />

will look like this:<br />

Function block TRAFFICSIGNAL, declaration part<br />

"TRAFFICSIGNAL" body<br />

Now we determine the values of the output variables depending on the input STATUS of the POU. To<br />

do this go into the body of the POU. Click on the field to the left beside the first network (the gray field<br />

with the number 0001). You have now selected the first network. Choose the menu item 'Insert' 'Box'.<br />

In the first network a box is inserted with the operator AND and two inputs:<br />

Click on the text AND, so that it appears selected and change the text into EQ. Select then for each of<br />

the two inputs the three question marks and overwrite them with "STATUS" respecively "1".<br />

Click now on a place behind the EQ Box. Now the output of the EQ operation is selected. Choose<br />

'Insert' 'Assign'. Change the three question marks to GREEN. You now have created a network<br />

with the following structure:<br />

STATUS is compared with 1, the result is assigned to GREEN. This network thus switches to GREEN<br />

if the preset state value is 1.<br />

3-2 CoDeSys V2.3

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

Saved successfully!

Ooh no, something went wrong!