• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

traffic light control: hardware driven

Thread starter #1
I would like to have the following setup in hardware, driven by one single digital input signal:
1. digital signal = low, then green LED is on
2. digital signal = high, then green LED is off, yellow LED is on for about 3 seconds then yellow LED is off and then red LED is on.

I was thinking about using either NAND gates with some RC timing, or 2 (?) 555 timers. Does anyone have some recommendation, and maybe a design proposal too?

Thanks, Erik
 

JonSea

Well-Known Member
#2
I would use a micro and a simple program but that's just me.

I did make a controller for a car-themed restaurant that has a traffic light. Unfortunately, the traffic light was purchased new, with LED elements. The green signal is blinding, which isn't surprising you can see a green traffic light for miles! If it had been an incandescent-based light, the bulbs could have been changed, but the LED elements are designed for constant brightness.
 
Thread starter #3
The reason I want it hardware driven is because I need to use an ATtiny85 where I have only output available per set of lights of 3 colours.
 
Thread starter #5
Hi Jonsea! I2C expander makes it too complex for this setup; and shift register: please enlighten me?

I would prefer to make it of discrete components like flip-flops and or logic gates..
 

JonSea

Well-Known Member
#6
I often use port expanders. They can be a bit of a pain to set up, but work very well.

A shift register actually uses 3 port pins so it may be out. 3 lines are used - a clock line, a data line and a load line. This link describes how they work better than I can.
 

rjenkinsgb

Active Member
#8
three pins needed: too much
Those three pins can give you any number of individual outputs and the circuit is far simpler than the two-timers-per-output one.
There is a good example here with a full explanation:
https://www.arduino.cc/en/Tutorial/ShiftOut

If you need more than eight outputs, just use another 595 and connect it's data in to the data out of the first one, then shift 16 bits before activating the strobe signal. [Or use three 595s and shift 24 bits, etc..]


For individual timers, the lowest component count is possibly to use a 4017 for each sequencer.

Connect the clock inputs of those to a suitable oscillator like a 555, or drive it from an MCU pin - just one source for all the 4017's you use.

Connect the control pins from the MCU to each 4017 reset, the green to output zero and use diodes to OR together some number of outputs from 1 up, to give the correct amber time in relation to the clock osc speed.
Connect the next output after those to the red and also clock inhibit on the same chip. That stops the sequence continuing or repeating, until reset is activated again.

4017 Data:
http://www.ti.com/lit/ds/symlink/cd4017b.pdf

If the "clock" is generated by the MCU and you only ever change state as that changes, you could use the cycle time of that to set the amber state time and just outputs 0, 1 and 2 for green, amber, red.

If it's a free-running or asynchronous clock, you cannot be sure how long after the MCU signal changes (and the reset is released), so the first state time can vary tremendously. Using several outputs ORd together ensures the time variation is minimal compared to the overall amber state time.,
 

Pommie

Well-Known Member
Most Helpful Member
#9
If you have to use the atTiny then you might consider serially driven RGB LEDs. These combine a 5050 (5x5mm) LED with a WS2812 chip so they can be put in a string and addressed with just one pin. You can string as many pixels as you like and there's examples on the web - see this page.

It could be a fun project.

Mike.
 

dr pepper

Well-Known Member
Most Helpful Member
#10
I think you could do that with 3 or 4 trannies and a 555, you might have to reverse your logic conditions.
 
Thread starter #13
Those three pins can give you any number of individual outputs and the circuit is far simpler than the two-timers-per-output one.
There is a good example here with a full explanation:
https://www.arduino.cc/en/Tutorial/ShiftOut

If you need more than eight outputs, just use another 595 and connect it's data in to the data out of the first one, then shift 16 bits before activating the strobe signal. [Or use three 595s and shift 24 bits, etc..]


For individual timers, the lowest component count is possibly to use a 4017 for each sequencer.

Connect the clock inputs of those to a suitable oscillator like a 555, or drive it from an MCU pin - just one source for all the 4017's you use.

Connect the control pins from the MCU to each 4017 reset, the green to output zero and use diodes to OR together some number of outputs from 1 up, to give the correct amber time in relation to the clock osc speed.
Connect the next output after those to the red and also clock inhibit on the same chip. That stops the sequence continuing or repeating, until reset is activated again.

4017 Data:
http://www.ti.com/lit/ds/symlink/cd4017b.pdf

If the "clock" is generated by the MCU and you only ever change state as that changes, you could use the cycle time of that to set the amber state time and just outputs 0, 1 and 2 for green, amber, red.

If it's a free-running or asynchronous clock, you cannot be sure how long after the MCU signal changes (and the reset is released), so the first state time can vary tremendously. Using several outputs ORd together ensures the time variation is minimal compared to the overall amber state time.,
Great post, thank you! Might well be -barring a hardware schematic using discrete components doing the cycling of the three lights- what I will be using.
 

KMoffett

Well-Known Member
#14
1. digital signal = low, then green LED is on
2. digital signal = high, then green LED is off, yellow LED is on for about 3 seconds then yellow LED is off and then red LED is on.


Is this a once-and-stop sequence? What do you want to do after the red light? Does the digital signal need to be manually set back to low?

Ken
 

rjenkinsgb

Active Member
#15
Just for info, if you need higher current outputs than the MCU or shift register can provide, for high-current LEDs, you can use darlington drivers to simply boost the power switching capability.

eg. A ULN2803 has eight driver stages, which can operate directly from a logic-level input and switch a moderate current at up to 50V.
A single output can handle half an amp, or if all are on at the same time about 100mA each.

Or, if you use the shift register expander idea, you can get MIC5841 or MIC5891 ICs which have the shift register and a set of high current drivers all in one IC.
The 5841 switches to 0V, the 5891 switches the positive power supply, anything up to 50V or so again.

Data:
http://www.j-omega.co.uk/Downloads/ULN2803.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/mic5841.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/20005638A.pdf
 
Thread starter #16
1. digital signal = low, then green LED is on
2. digital signal = high, then green LED is off, yellow LED is on for about 3 seconds then yellow LED is off and then red LED is on.


Is this a once-and-stop sequence? What do you want to do after the red light? Does the digital signal need to be manually set back to low?

Ken
My initial scope was to have one MCU output determine the state of the green light: when high, then green lights, transition to low shuts green and starts yellow, after x seconds yellow shuts and red lights up. When state transition of D/O MCU to low: reds shuts and green lights up.

This is the hardware approach (which I still prefer).

Alternative approach (using shift register proposed here): three outputs: clock, data and load.
 

dr pepper

Well-Known Member
Most Helpful Member
#18
I'm at work later, if I get time I'll scribble something & scan it.
 

dr pepper

Well-Known Member
Most Helpful Member
#19
I think this fulfills your explanation.
However your explanation may not be what your traffic lights want to do.
Here in the Uk this is not how ours work.
Anyway:
 

Attachments

Thread starter #20
I think this fulfills your explanation.
However your explanation may not be what your traffic lights want to do.
Here in the Uk this is not how ours work.
Anyway:
How does yours in the uk work?
I know in germany for example, before red turns back to green, yellow turns on as well again for a few seconds.
Here in Belgium it goes in straight sequences: green, then yellow a few seconds (short enough for people trying to get through orange to get caught by the thousands of traffic light camera's to get a fine) and then red.

Thanks a lot for the schematic!! Is there a reason why you use 2 digital inputs? Basically your design does exactly what is needed with both inputs tied together.
 

Latest threads

EE World Online Articles

Loading

 
Top