2 Pedestrian traffic light
This "UML state diagram" sample illustrates the basic functionality of the UML state diagram and contains the following UML SC elements:
Sample project: TF1910_UmlSC_Sample2_PedestrianLight.zip
Overview
UML SC is used to program the behavior of a pedestrian traffic light. A green-phase request can be sent via a push button on the visualization. The pedestrian traffic light has the two states, "Red" and "Green".
If a green phase is requested, the traffic light switches to green after the time "cTimeWaitForGreen" has elapsed. The traffic light switches back to red once the time "cTimeGreenPhase" has elapsed.
The two states "Red" and "Green" each contain an ENTRY action and a DO action.
- The ENTRY actions are used to switch the traffic light to red or green. In addition, the respective timer function block (of type TON) is reset. The ENTRY action is called once whenever the corresponding state is activated.
- In the DO actions a Red or Green counter is incremented. This indicates that a DO action is called permanently as long as the corresponding state is active. The respective timer function block is also called.
- The Q output of the respective timer function block is used as a transition between the states, so that the state is changed after the corresponding time has elapsed.
Visualization
In addition to the convenient online mode of the UML SC diagram, the behavior of the pedestrian lights, the values of the counters and the waiting time that has already elapsed can be tracked via the visualization.