It is advisable to bring the algorithm of the traffic light. Light signals sides (directions) 1 and 3 C1 regulate traffic movement on the road and, accordingly, the sides 2 and 4 regulate traffic on the road B.
Let on side 1 (on the side of 3) included a stoplight (CR1). On the side of 2 (on the side of 4) included the green signal (ZEL2). After a predetermined time interval on the side 2, the green flashing, but still on the side of 1 red. Then a flashing green signal is switched off at the same time on both sides of the yellow signal is activated (VC). Further on one side, the green signal (green 1), while the two side red (CR2), etc. Typically, a flashing green light, as well as yellow, it is switched on for 3 … 4. Red and green signals are included in the specified time intervals, which are determined by traffic volume and the traffic situation at the intersection.
We call conditional activation time CR2 (or ZEL1) interval №1. Accordingly, the operating time ZEL2 (or CR1) — interval №2. The above intervals the device is programmed in increments
1 with a range of from 1 to 99 seconds.
The control interface includes a keyboard (key S1 … S4), and a display unit (display) of the two 2-bit digital 7-segment display HG1 and HG2. The keypad buttons are assigned as follows:
— S1 (A) — increasing the value given by the selected time interval (№1 or №2), c;
— S2 (V) — decreases the value specified by the selected time interval (№1 or №2), c;
— S3 (P) — the choice given by the interval. If the indicator is on the point h HG1.2, the selected interval №2. When the point h indicator HG2.2 selected interval №1. After pressing the button preset buttons S1 and S2, the parameter data stored in the memory of the microcontroller;
— S4 (C) — «Start / Stop» button — the button to start or stop.
Digits display interface have the following functions:
-1 digit (display HG1) indicates tens of seconds intervals la number 2;
— 2 rank (indicator HG1.2) — seconds interval unit №2;
— 3 rank (indicator HG2.1) — tens of seconds interval №1;
— 4 digits (LED HG2.2) — seconds interval unit №1.
Immediately after power-on indicators displayed zero values intervals №1 and №2, point h HG1.2 indicator is turned on, point h indicator HG2.2 — off. At first the buttons S1 and S2 set the required value range №1. After pressing the S3 button setpoint №1 interval corresponds to the data memory of the microcontroller. Point h HG1.2 indicator turns off point h indicator HG2.2 included. Similarly, the buttons S1 and S2 set the required value range №2 and pushing the S3 key is rewritten in the memory of the microcontroller. Point h HG1.2 indicator is activated, point h indicator HG2.2 off. After setting the above parameters necessary to run the press S4, and the timer №1 goes into working mode, point h indicator HG1.2 included.
In addition, the device has a mode of operation with a flashing yellow signal. To put the device in the above mode is necessary to press the power-S1 and then apply power to the board. In the above modes include flashing yellow, and all other signals are turned off.
Keyboard timer №2 collected on the buttons S1 … S4. For the operation of the keyboard enabled terminal 2 (RZ.O) microcontroller DD1. Keys to turn traffic lights are made with transistors VT1 … VT5. These keys run:
— transistor VT1 — red signal direction 1 (CR1), included with 3 O microcontroller DD1; — On the transistor VT2 — green signal direction 1 (ZEL1) is included with the O 6 DD1;
— transistor VT3 — red signal direction 2 (CR2), the output is switched on 7 DD1;
— transistor VT4 — green signal direction 2 (ZEL2) is included with the O 8 DD1;
— transistor VT5 — yellow traffic lights direction 1 and 2 (VC), the output is switched on 9 DD1. Since yellow directional signals 1 and 2 are lit simultaneously for the two directions of only one key.
Host dynamic display assembled on a chip DD2, transistor VT6 … VT9 and digital dual 7-segment display HG1, HG2. The microcontroller DD1 with the output 11 via a resistor R26 includes a point h in indicators HG1.2, HG2.2.
Algorithm timer №2 in the next operating cycle (from the timer №1 its duty cycle). Immediately after the power supply is necessary to control the keyboard interface make the required operating parameters — the intervals №1 and №2. These parameters are displayed on the display (LEDs HG1 and HG2). The device goes into the duty cycle immediately after pressing the button S4 («Start / Stop»). The microcontroller with the sets ‘0’ at the terminals 3 and 8, and with a key on the VT1 and VT4. Included KR1 and ZEL2. Time Displayed on the display HG2 (interval №1), is decremented every second. And as soon as it becomes zero, microcontroller output 8 4 outputs a pulse with a period of 1 (signal ZEL2 flashes).
Next, the microcontroller determines (at 3) a «1» at terminal 8 and «O» on the output 9, which is ZEL2 off-Xia, VC is switched on and lights up 3. After 3 to the microcontroller sets «1» at the terminals 3 and 9, «0» at the terminals 6 and 7 (RP1 and VC are switched off, and ZEL1 CR2 included).
The display lights up again HG2 originally set value range №1. Next time, the indicator shown at the HG1 (interval №2), is decremented every second. Once it reaches zero, microcontroller 6 O 4 produces a pulse with a period of 1 (GRN 1 flashes). Next, the microcontroller determines (at 3) a «1» at terminal 6 and «0» on output 9, which is ZEL1 off, VC is switched on and lights up 3. After 3 to the microcontroller sets «1» at the terminals 7 and 9, «0» at the terminals 3 and 8 (CR2 and VC are switched off, and RP1 ZEL2 included). Indicator HG1 again indicates the original setpoint range №2. Duty cycle is completed. Such cycles are repeated periodically.
Software microcontroller DD1 ensures the implementation of the above algorithm works with a countdown intervals №1 and №2 with output set parameters on the dynamic display. Timer TF0 DD4 microcontroller generates an interrupt every 310 microseconds. This timer acts as a time base counter which generates the time intervals required to display digits in the dynamic display, the installation and assignment of time slots to enable traffic light signals in the operating cycle.
Then there is the initialization of the program, which set the parameters of the timer №2. When initialization on all Port pins RE DD1 set to «1». Next, a timer is started TF0 and enables the device according to the above algorithm. To use a dynamic display in the RAM of the microcontroller DD1 organized display buffer.
The duty cycle timer №2 after settings (intervals №1 and №2) by pressing the S4 key bit is set, allowing the program key management. №2 interval set previously and displayed on the display HG1. The current value of the time displayed on the display HG1, is stored in the cells EMIN (units of seconds) and DMIN (tens of seconds). When setting the parameters of the device after pressing the S3 time value corresponds respectively to the wells and EMINB DMINB. Interval №1 previously set and displayed on the display HG2.
The current value of the time shown at the HG2, is stored in the cells EMIN1 (units of seconds) and DMIN1 (tens of seconds). When setting the work after pressing the S3, these time values are overwritten respectively cell EMINB1 HDMINB1.
In the interrupt routine takes place with 1 count (counter organized on the registers R1 and R2), a survey keyboard, and only then to the port P1 output bytes of dynamic display. The Register RO recorded address of the cell from the buffer display. Each time a subroutine processing register R0 is incremented.
In the main program comes decrement specified intervals №1 and №2 and key management.
The light sources in traffic lights use incandescent or superbright (ultra) light-emitting diodes. To connect the channels №1 … №5 to the network type used triac blocks BS-440-63 / 40-H of the company «KontrAvt.»
Capacitors C1, C4-type K50-35, capacitors C2, NW — K10-17a.
The current consumption in the channel 5 — no more than 500 mA.