beautypg.com

5 we write a little program, Controlling a traffic signal unit, Introduction – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 79: Create pou, What does trafficsignal do, What does wait do, We write a little program, L-force | plc designer, 5we write a little program

background image

L-force | PLC Designer

We Write a Little Program

DMS 3.2 EN 02/2011 TD29

77

5

We Write a Little Program

5.1

Controlling a Traffic Signal Unit...

5.1.1

Introduction

Let us now start to write a small example program. It is for a simple traffic signal unit
which is supposed to control two traffic signals at an intersection. The red/green
phases of both traffic signals alternate and, in order to avoid accidents, we will insert
yellow or yellow/red transitional phases. The latter will be longer than the former.

In this example you will see how time dependent programs can be shown with the
language resources of the IEC1131-3 standard, how one can edit the different
languages of the standard with the help of »PLC Designer«, and how one can easily
connect them while becoming familiar with the simulation of »PLC Designer«.

5.1.2

Create POU

Starting always is easy: Start PLC Designer and choose 'File' 'New'.

In the dialog box which appears, the first POU has already been given the default

name PLC_PRG. Keep this name, and the type of POU should definitely be a program.
Each project needs a program with this name. In this case we choose as the language
of this POU the Continuous Function Chart Editor (CFC)

Now create three more objects with the command 'Project' 'Object Add' with the
menu bar or with the context menu (press right mouse button in the Object
Organizer). A program in the language Sequential Function Chart (SFC) named
SEQUENCE, a function block in the language Function Block Diagram (FBD) named
TRAFFICSIGNAL, along with a POU WAIT, also of the type function block, which we
want to program as an Instruction List (IL).

5.1.3

What does TRAFFICSIGNAL do?

In the POU TRAFFICSIGNAL we will assign the individual trafficsignal phases to the
lights, i.e. we will make sure that the red light is lit red in the red phase and in the
yellow/red phase, the yellow light in the yellow and yellow/red phases, etc.

5.1.4

What does WAIT do?

In WAIT we will program a simple timer which as input will receive the length of the

phase in milliseconds, and as output will produce TRUE as soon as the time period is
finished.