8 extending the program with an alternative branch, Extending the program with an alternative branch, Drive plc developer studio – Lenze DDS v2.3 User Manual
Page 33: Program example

Drive PLC Developer Studio
Program example
3-11
l
DDS EN 2.3
40.Enter the following actions for the step “ Init” into the editor window and define the actions for
the other steps in the same way.
Step
Actions
Status Light1/Light2
Init
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=3)
CHANGE1
CAL
LIGHT1(STATE:=4)
CAL
LIGHT2(STATE:=3)
CAL
WAIT1(SETTIME:=t#2s)
GREEN1
CAL
LIGHT1(STATE:=1)
CAL
LIGHT2(STATE:=3)
CAL
WAIT1(SETTIME:=t#5s)
CHANGE2
CAL
LIGHT1(STATE:=2)
CAL
LIGHT2(STATE:=3)
CAL
WAIT1(SETTIME:=t#2s)
RED1
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=3)
CAL
WAIT1(SETTIME:=t#1s)
CHANGE3
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=4)
CAL
WAIT1(SETTIME:=t#2s)
GREEN2
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=1)
CAL
WAIT1(SETTIME:=t#5s)
CHANGE4
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=2)
CAL
WAIT1(SETTIME:=t#2s)
RED2
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=3)
CAL
WAIT1(SETTIME:=t#1s)
This completes the first phase of our program. You can now compile the program and test it in a
simulation.
3.2.8
Extending the program with an alternative branch
To include at least one alternative branch in our chart so that we can turn the traffic lights off over
night, we will include a counter to deactivate the system after a specific number of traffic light cycles.
Firstly, we will need a new variable COUNTER of type INT.
41.To edit the organization unit PLC_PRG, activate its editor window by selecting
Object
Organizer, tab Organization units and double-clicking PLC_PRG .
42.Use the declaration editor to declare as local variable (between the keywords VAR and
END_VAR
) the variable COUNTER of type INT.
43.Initialize the variable COUNTER in the step “ Init” with 0:
Step
Actions
Status Light1/Light2
Init
CAL
LIGHT1(STATE:=3)
CAL
LIGHT2(STATE:=3)
LD
0
ST
COUNTER
Show/Hide Bookmarks