Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
21
Добавлен:
11.10.2020
Размер:
3.39 Mб
Скачать

Programming Example 55

Controlling a Traffic Signal Unit

x Action Green1

The first expansion phase of our program is completed. Now you can compile it and also test the simulation.

3.1.14"SEQUENCE" second expansion level

In order to ensure that our diagram has at least one alternative branch, and so that we can turn off our traffic light unit at night, we now include in our program a counter which, after a certain number of TRAFFICSIGNAL cycles, turns the unit off.

At first we need a new variable COUNTER of the type INT. Declare this as usual in the declaration part of PLC_PRG, and initialize it in Init with 0.

x Action Init, Second Version

Now select the transition after Switch1 and insert a step and then a transition. Select the resulting transition and insert an alternative branch to its left. After the left transition insert a step and a transition. After the resulting new transition insert a jump after Switch1.

Name the new parts as follows: the upper of the two new steps should be called "Count" and the lower "Off". The transitions are called (from top to bottom and from left to right) EXIT, TRUE and DELAY.OK. The new part should look like the part marked with the black border in the following image:

x Program SEQUENCE, Second Expansion Level, Instruction Part

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

56 Programming Example

Controlling a Traffic Signal Unit

Now two new actions and a new transition condition are to be implemented. At the step Count the variable COUNTER is increased by one:

x Action Count

The EXIT transition checks whether the counter is greater than a certain value, for example 7:

x Transition EXIT

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

Programming Example 57

Controlling a Traffic Signal Unit

At Off the state of both lights is set at 5(OFF), (or each other number not equal 1,2,3 or 4) the COUNTER is reset to 0, and a time delay of 10 seconds is set:

x Action Off

3.1.15The result

In our hypothetical situation, night falls after seven TRAFFICSIGNAL cycles, for ten seconds the TRAFFICSIGNAL turns itself off, then we have daylight again, the traffic light unit turns itself on again, and the whole process starts again from the beginning.

3.1.16PLC_PRG

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.

x Declaration LIGHT1 and LIGHT2

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

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

58 Programming Example

Controlling a Traffic Signal Unit

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:

x Declaration of the Input-/Output Variables for a CAN-Configuration

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 this example) stands for byte and the individual bits of the module are addressed using 0.0 (0.1, 0.2, etc.). We will not do the needed controller configuration here in this example, because it depends on which target package you have available on your computer. Please see PLC configuration for further information.

We now want to finish off the block PLC_PRG.

For this we go into the editor window. We have selected the Continuous Function Chart editor and we consequently obtain, under the menu bar, a CFC symbol bar with all of the available elements (see The Continuous Function Chart Editor).

Click on the right mouse key in the editor window and select the element Box. Click on the text AND and write "SEQUENCE" instead. This brings up the block SEQUENCE with all of the already defined input and output variables. Insert two further block elements which you name PHASES. Phases is a function block and this causes you to obtain three red question marks over the block which you replace with the already locally declared variables LIGHT1 and LIGHT2. Now set an element of the type Input, which award the title ON and six elements of the type Output which you award variable names to, as described, namely L1_green, L1_yellow, L1_red, L2_green, L2_yellow, L2_red.

All of the elements of the programme are now in place and you can connect the inputs and outputs, by clicking on the short line at the input/output of an

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

Соседние файлы в папке 759-332