The circuit keep track of time, in 12 hour format, using an external 1 Hz source. The 1 Hz source comes from a 4 pin header, and allows to be changed out in the future.
How it works:DisplayLEDs:
For the display LEDs, I am using common anode 7 segment displays. This variant is 0.56" tall and has a red illumination color. There are 2 sets of LEDs as use the "colons" in a typical clock display.
Seconds Counter:
The second counter comprises of 4 ICs: 74LS47 (2x),74HC393N (1x), and 74HC08N (1x)
The 74LS47 is an active low 7 segment LCD driver. The 74HC393N is a dual 4 bit binary counter that used to count both the ONES and TENS section of the seconds part of the clock. One half of the IC counts the ONES and the other half of the TENS.
When the ONES counter reaches "1010" in binary, the AND gate resets the counter. The reason it's using binary "1010" is because it is an active high reset. If "1001" was used, it would reset as soon as it hits 9, never actually seeing it. When it resets, it also increments the TENS counter.
When the TENS counter reaches "0110" in binary, the AND gate resets the counter. The reason it's using binary "0110" is because it is an active high reset. If "0101" was used, it would reset as soon as it hits 5, never actually seeing it.
Since seconds and minutes both count from 0 to 59, this circuitry can be repeated for counting minutes as well.
Minute Counter:
As you can see, the minutes counter and seconds counter follow the same approach since they both count from 0 to 59. When the TENS portion for the second counter resets, it increments the ONES portion of the minute counter.
Hour Counter:
The hour counter was a bit tricky to figure out because I wanted to keep track of time in a 12 hour format. The requirements for counting hours in a 12 hour format (1, 2, 3,...11, 12, 1...):
Count from 1, 2, 3...down to 12.
- Count from 1, 2, 3...down to 12.
Once 12 is about to reset, it should go back to 1.
- Once 12 is about to reset, it should go back to 1.
The ONES counter should count from 0 to 9 and then 0 to 2. Once both the TENS is at "1", ones is at "2", the minute is at 59
- The ONES counter should count from 0 to 9 and then 0 to 2. Once both the TENS is at "1", ones is at "2", the minute is at 59
This requires a pre-settable counter that can load in a fixed starting point. The 74LS190 was a perfect fit for this. It has the option to load in a fixed starting point. This IC is a bit hard to find and can only be bought from 3rd party vendors. I am working on a 2nd version that does not require the 74LS190.
The TENS counter of the hour is controlled by a D flip flop since it only has to count 0 to 1 and back to 0. The ONES counter of the hour is preset to 1. The RC (ripple count) of the ONES counter is the clock pulse for the TENS counter. When the ONES counter is 3 AND the TENS counter is 1, both counters are loaded with the preset settings. This makes sure the hour count goes from 1 to 12 and then back to 1. Two NAND gates were used to make an AND gate to avoid using a separate IC for the AND gate.
Setting the Time:
No clock would be complete with out the ability to set the time. To set the time, 2 OR gates were used. One OR gate to select between the actual clock signal or an external push button. This is applied to both the minute and hour time set.
Clock Source:
There is a 4 pin header (0.1" spacing) that allows plugging in different 1Hz clock source. For this one, I used the clock source I built in one of my other post. Link here: https://www.hackster.io/harit-shah/not-your-typical-1hz-source-5ee441
Layout:
All through hole components are used and all the routing is done on 2 layers. I am really happy with how the layout turned out. It was almost symmetrical, if it wasn't for the IC in the lower left corner.
Building/Testing:Here is what the bare PCB looks like, approximately 4"x4"
This whole clock uses +5V as the voltage source.
At the start of the article, I mention that I use red 7 segment LED displays. Turned out I had white 7 segment LED displays laying around so decided to use that. However, I miscalculated the current limiting resistor (I was mistakenly looking at the datasheet for the wrong part). Which is why it appears to be really bright. By the time I realized, it was too late to turn back.
The 7 segment LED display will have the required voltage drop to light it up. Using ohms law (V=I*R), the current limiting resistor can be determined. If you build it using the display on the parts list, the forward voltage (Vf) is 2V. This means you need to drop 3V across the resistor.
Vf = 2V
If = 25 mA
V = I * R
(5.0 - 2.0) = (0.025 * R)
3.0 = 0.025 * R
R = 120 ohms
Seconds counter:
Minute Counter:
Hour Counter:
To show the effect of the clock transitioning between 12 am/pm to 1 am/pm, I connected the 1Hz clock source to the minute set button. You'll notice that the minute goes from 1 to 3. This is result of the minute counter incrementing by the 1Hz clock source and then the "manual mode".
The "clock dot" LEDs are blinking at the same rate as the clock source since they are connected to that said source.
Clock Source:
This is the clock source from my other post. If you decide to build the clock, you'll also need to build this. You can also bring attach your own source as well. Make sure you get the IO correct.
I did run into a problem with the hour counter, that was easily fixable. Here is the section:
The ripple counter from the ONES part of the hour counter is tied to the D and C pin (input, clock) of the TENS part of the hour counter. Below is the truth table for the flip flop:
The SET (nSD) pin is set to H. The RESET (nRD) pin gets toggled from H to L when the hour counter goes from 12 back to 1. Otherwise it stays at H. So when the flip flop sees the rising edge of the clock, the D pin is also a rising edge. This essentially results in the output not toggling.
This was resolved by cutting the D pin from the C pin and connecting the D pin to VCC.
So just 1 cut and 1 jumper and the clock worked as designed. The attached git to the KiCad design files has this fix already in there.
Summary:The goal of this project was to make a clock for my home office but with a challenge of no programming required. It definitely was a challenge, especially with the added twist of making it a 12 hour format clock.
I have the schematic, PCB, and gerber files from KiCad attached if you wish to build one for yourself. I am also planning on making a kit for anyone that would want to purchase and build one along with a pre-built option.
That should do it! If you have any questions, run into an issue, or see where this can be improved/optimized, please leave a comment below. Thanks for reading!
Comments