Converting a traffic light into a timer

tracecom

Joined Apr 16, 2010
3,944
I strongly suggest that you print out a copy of the schematic, and as you place components and make the connections, you highlight the corresponding components and wires. Make notes of the wire colors on the schematics. This is a fairly complicated project, and will be very difficult to troubleshoot if you don't keep good records.

You can temporarily substitute another color LED for the blue.

I don't know exactly what pushbuttons you have, but often the small momentary pushbuttons don't fit well into a solderless breadboard. That's the reason I put mine on a separate "button board" in the prototype I built.

The buzzer isn't critical...just one that will operate on your supply voltage and be loud enough for your purpose.

X1 is the clock crystal; its frequency needs to be 32.768 MHz.

The .01 μF caps are supposed to be connected from ground to power; they provide a discharge path for AC noise while blocking DC.

elec_mech will be along shortly with more specific answers about components.

Keep going, and good luck.
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
Holy crap I did something right! :D

Everything is connected and the countdown and buttons are working!!

But...

The lights do not seem to be working properly. I have not been able to get the green light to appear (going as high as 60 minutes). The yellow only appears when flashing less than a minute. Red does not appear either. Perhaps this is because I am missing a light? (red is currently by the timer)

Also, it seems like the seconds are rather slow.

Still, a positive step forward. Here's my rainbow of a breadboard with the the first success!

http://i.imgur.com/A1GTMem.jpg
 

tracecom

Joined Apr 16, 2010
3,944
Check the polarity on the LEDs; the flat side is the cathode and always goes toward ground. On the LED next to the DS1307, I don't see a current limiting resistor; if the LED is connected with the proper polarity, it's probably shot due to the missing resistor. Once you get that working, you can check the accuracy of the clock chip by counting LED pulses...one per second.

Congratulations on having so much right. I am impressed.
 
Very impressive progress!! Congratulations!!!

Adding to tracecom’s comments, the crystal on the DS1307 has ultra-thin wires and usually will not make good contact with the breadboard – causing the 1307 to run slow, or fast, or not at all! I usually tack on some old resistor cutoff’s, small lengths of leftover component leads when populating PCB’s. You can solder on some short lengths of jumper wires to accomplish the same thing. Watch the soldering heat, the crystal doesn’t like getting too warm! “Be quick, but don’t hurry!” (Baseball phrase.)

You might want to write and run some “test code” which will sequence the three traffic light LED’s (red, yellow green) followed with some different “test code” to sequence through each of the 7-segment display segments ( :) ) and finally some “test code” to ensure the switches are functioning correctly. Once all the “test code” programs run correctly, put elec_mech’s code back on.

Where is the traffic-light red LED? (My eyes are old and tired.) (grin)

:) joe
 
Last edited:

Thread Starter

Transitory

Joined Jan 2, 2013
64
Check the polarity on the LEDs; the flat side is the cathode and always goes toward ground. On the LED next to the DS1307, I don't see a current limiting resistor; if the LED is connected with the proper polarity, it's probably shot due to the missing resistor. Once you get that working, you can check the accuracy of the clock chip by counting LED pulses...one per second.

Congratulations on having so much right. I am impressed.
I have double checked the LEDs polarity, they are right. I have also tested the LEDs by putting all of them in the yellow slot and they all light up there.

The red LED by the timer does have a resistor and it does function properly (the resistor is hidden under the red jumper).

Very impressive progress!! Congratulations!!!

Adding to tracecom’s comments, the crystal on the DS1307 has ultra-thin wires and usually will not make good contact with the breadboard – causing the 1307 to run slow, or fast, or not at all! I usually tack on some old resistor cutoff’s, small lengths of leftover component leads when populating PCB’s. You can solder on some short lengths of jumper wires to accomplish the same thing. Watch the soldering heat, the crystal doesn’t like getting too warm! “Be quick, but don’t hurry!” (Baseball phrase.)

You might want to write and run some “test code” which will sequence the three traffic light LED’s (red, yellow green) followed with some different “test code” to sequence through each of the 7-segment display segments ( :) ) and finally some “test code” to ensure the switches are functioning correctly. Once all the “test code” programs run correctly, put elec_mech’s code back on.

Where is the traffic-light red LED? (My eyes are old and tired.) (grin)

:) joe
The traffic-light red is missing because I neglected to order a blue one for the timer, so the red light is substituting there just for now.

I will check out the connection on the crystal - you are right, they are very tiny wires!

Also, the test code is a good idea. It will give me a chance to practice some basic programming. I'll probably have questions regarding that, though.

Thanks always for your help! It's been fun so far. I've learned a ton about circuits (what resistors do, what diodes are, what components need the right polarity, which ones are polarity neutral, how to solder, etc.), how to read symbols and interpret a schematic, and I'm sure more to come! I really haven't seen a schematic since high school physics so it has been literally starting from GND (haha, get it? starting from 0!! ahahaha bad circuit jokes....:D).

I am headed to a wedding in LA this weekend, so I won't be back to work on the circuit till tomorrow. Hopefully in that giant sprawling megalopolis I can find a cheap electronics store and pick up the missing LED.
 

elec_mech

Joined Nov 12, 2008
1,500
Sorry, work's been crazy busy and I haven't been able to check AAC as often as I'd like.

Can you point to some buttons on Digikey (since that's where the blue LED has to come from) that would fit the bill?
I like to use these switches for breadboarding. Here are some others:

This is similar to the one above but in orange and requires more force to push.

This is similar to one above but in blue and requires a even more force to push.

This one has a short white button and costs less.

Long button, also cheaper.

I forgot to order the blue LED so can't do that yet.
As tracecom mentioned, you can use another color. I hope you didn't only exactly enough parts with no spares. :eek: Usually costs less to order extra parts than to buy just enough and pay shipping twice if you find you need more. This isn't a criticism, just letting you know how the rest of us generally end up with so many parts to play with over time. :)

I never ordered a buzzer! Not essential, but still something I overlooked. What are the requirements for it? (i.e. is there a special type which will work with the picaxe, any from digikey?)
Unfortunately, most buzzers will require more voltage, but you may get away with something like this. This doesn't appear to require much in the way of current, so you should be okay connecting the positive terminal to the PICAXE (pin 15 - in place of the blue LED) and the negative pin to GND. Not sure how loud this will be at 5V. The alternative is to bring in a higher voltage like 12VDC and use a transistor to act as a switch between the PICAXE and the buzzer. More parts, more work, but then you can get a buzzer that will really wake and perhaps scare the pants off anyone in the same room.

There are two places in the circuit where it appears that ground is directly linked to +5V via the 0.1uF Ceramic Capacitor, 50VDC. This occurs off of pin 4 on the Ds1307 and off of pin 4/9 on the MAX7721. Is this right? Should the capacitor be between the +5V and GND connection? After the previous debacle toasting the PICAXE I want to be sure.
Actually, there are three: C2, C3, C4. These are 0.1uF capacitors that should be placed as physically close to the input power pins of each of the ICs. Digital ICs can emit electrical noise when their pins change state (high-to-low, etc.) and they are sensitive to this noise as well. The caps are used to help filter this noise so the ICs don't see false signals and act on something they shouldn't.

The traffic-light red is missing because I neglected to order a blue one for the timer, so the red light is substituting there just for now.
You don't need the LED for the timer - it is there as a visual indicator only. You can look at this LED and determine if it is really flashing once a second or not to help determine if the clock is correct. Once that is done, you can remove the LED and use it elsewhere.

The lights do not seem to be working properly
As tracecom suggested, print the schematic and use a highlighter to double-check all your connections. The green LED should be connected to pin 16 on the PICAXE. I see a red wire going from the green LED to somewhere on the PICAXE and I see a green wire going from pin 16 to a resistor next to the yellow LED resistor that doesn't appear to be connected to anything (presumably this will go to the red LED?). I *think* you have the red and green LEDs connected in reserve to the PICAXE, but it's hard to say for sure. Just double-check your wiring and let us know.
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
So I am headed to a large electronic store in LA today, any suggestions for some things that might be useful to get for making permanent set up easier? (Or anything else besides some switches, leds, and a buzzer?)
 

elec_mech

Joined Nov 12, 2008
1,500
Off the cuff, I'd suggest the following:

5+ Logic Level MOSFETs rated 20V+ and 1A+. These will allow you to connect the PICAXE to a more powerful buzzer if needed and big LED lights in place of the incandescent bulbs if you so choose. For the latter, you might look for large super bright LEDs (red, yellow, green). Double check the current requirement and get a MOSFET for each with a higher current rating (double if possible).

You might consider picking up a few BJT transistors to play with, something like a PN2222 or 2N3904.

If you end up buying a buzzer that requires more than 5VDC, pick up a cheap wall wart with the same voltage rating as the buzzer.

If you opt to stick with incandescent bulbs, see if they have a logic level controlled relay board with 3-4 outputs such as this.

I don't recall if it was on the original BOM or not, but if you don't already have one, look at some suitable proto boards (pre-designed PCBs) that you can build your final circuit on.

Good luck!
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
Well, I am 95% of the way there with the first prototype. All lights and functions are working properly, including a little buzzer. The only problem now is the timing circuit is too slow. It counts about 6 seconds in 10 real seconds.

Also, for what it is worth there is an error in the schematic. Pin 16 according to the code goes to green, the schematic lists that as to red. Easy enough to fix, though.
 

elec_mech

Joined Nov 12, 2008
1,500
Also, for what it is worth there is an error in the schematic. Pin 16 according to the code goes to green, the schematic lists that as to red. Easy enough to fix, though.
Oops. I'll post a correction when time allows.

The only problem now is the timing circuit is too slow. It counts about 6 seconds in 10 real seconds.
With the LED on the DS1307, count the number of times the LED flashes and see if it corresponds to the number of seconds that pass. Example, 10 flashes should take 10 seconds. We need to determine if the problem is with the DS1307, the interrupt function of the PICAXE, or something else.
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
Oops. I'll post a correction when time allows.



With the LED on the DS1307, count the number of times the LED flashes and see if it corresponds to the number of seconds that pass. Example, 10 flashes should take 10 seconds. We need to determine if the problem is with the DS1307, the interrupt function of the PICAXE, or something else.
The LED flashes 1:1 with the displayed time (i.e. both take longer to elapse than they should).
 

elec_mech

Joined Nov 12, 2008
1,500
The LED flashes 1:1 with the displayed time (i.e. both take longer to elapse than they should).
Then the problem appears to be in the DS1307. Could you post a good clear picture of the breadboard showing how the DS1307 is connected?

Do you have a spare crystal you can try to swap with the existing one?
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
I'll still bet it's the tiny wires from the crystal not making good contact with the breadboard. How confident are you trying to solder tack the crystal directly to the DS1307? Just a wee bit of solder applied to the DS1307 legs (while it's still in the breadboard,) slightly and quickly tin the crystal leads then gently tack the crystal leads to the IC pins.

It's not as bad as I make it sound.

:) joe
 
Last edited:

Thread Starter

Transitory

Joined Jan 2, 2013
64
I'll still bet it's the tiny wires from the crystal not making good contact with the breadboard. How confident are you trying to solder tack the crystal directly to the DS1307? Just a wee bit of solder applied to the DS1307 legs (while it's still in the breadboard,) slightly and quickly tin the crystal leads then gently tack the crystal leads to the IC pins.

It's not as bad as I make it sound.

:) joe
Not too confident if we feel the crystal is at fault. What I did instead is solder two jumpers to the wires of the crystal and get a better connection that way. However, this yielded the same result - a slow count.
 

tracecom

Joined Apr 16, 2010
3,944
Those crystals can be fragile; it may be defunct. Just for giggles, remove the crystal from the circuit and see if the clock still runs at the same rate. If so, then the crystal is probably bad.
 

Thread Starter

Transitory

Joined Jan 2, 2013
64
Those crystals can be fragile; it may be defunct. Just for giggles, remove the crystal from the circuit and see if the clock still runs at the same rate. If so, then the crystal is probably bad.
I did, but without the crystal nothing happens when start/pause is pressed.

I looked to order a few spares and now they are out of stock! Should have ordered some extras!
 
Those crystals can be fragile; it may be defunct. Just for giggles, remove the crystal from the circuit and see if the clock still runs at the same rate. If so, then the crystal is probably bad.
You taught me something! I didn't know the DS1307 did anything without its crystal. (I feel better about my day now, learned something new!!!)

:) joe
 

tracecom

Joined Apr 16, 2010
3,944
You taught me something! I didn't know the DS1307 did anything without its crystal. (I feel better about my day now, learned something new!!!)

:) joe
No, I was just making a guess, which was apparently wrong. My next guess is that the crystal is the wrong frequency. It should be 32.768 kHz; is that what it is, transitory?
 
Top