Pedestrian Crossing
hard
Adds a queued pedestrian request and walk phase to a two-direction traffic light.
What it teaches
Keeps Traffic Light 2-Way’s Enable control, then adds an event queue. A one-shot records one button press, a latch remembers it, and the state machine serves it only after all-red.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Enable | Input | BOOL | 0 | 1 runs the crossing; 0 resets it and shows red in both directions |
| In_WalkRequest | Input | BOOL | 0 | Pedestrian push button |
| Cfg_GreenTime | Input | DINT | 3000 | Duration of each green phase in milliseconds |
| Cfg_AmberTime | Input | DINT | 1500 | Duration of each amber phase in milliseconds |
| Cfg_AllRedTime | Input | DINT | 2000 | Duration of each all-red phase in milliseconds |
| Cfg_WalkTime | Input | DINT | 2500 | Duration of the walk phase in milliseconds |
| Out_NSGreen | Output | BOOL | 0 | North-south green light |
| Out_NSAmber | Output | BOOL | 0 | North-south amber light |
| Out_NSRed | Output | BOOL | 0 | North-south red light |
| Out_EWGreen | Output | BOOL | 0 | East-west green light |
| Out_EWAmber | Output | BOOL | 0 | East-west amber light |
| Out_EWRed | Output | BOOL | 0 | East-west red light |
| Out_Walk | Output | BOOL | 0 | Pedestrian walk signal |
| Sts_Waiting | Output | BOOL | 0 | 1 while a new walk request is queued |
Required behavior
- When In_Enable is 0, both directions show red, Out_Walk is 0, and any queued request is cleared.
- Without a request, the six traffic phases match Traffic Light 2-Way.
- Each 0-to-1 transition of In_WalkRequest queues one request and turns on Sts_Waiting.
- A queued request never shortens green or amber. It is served after the next all-red phase.
- During the walk phase, both traffic directions stay red and Out_Walk is 1 for Cfg_WalkTime.
- Starting a walk clears the queued request. A new press during the walk queues another request for a later gap.
- Holding the button does not create repeated requests. The button must be released before another press is counted.