Digital Clock - Page 1
Forum section: electronics / projects

author: Sangharsh Sharma
author_rank: Contributor
timestamp: June 02, 2019, 03:00:55 pm
content: I've been trying to build a 12 hour format digital clock. As far as I think, I've done everything correctly. But the problem is as soon as I connect the power supply, the count just starts from random as if the circuit isn't working. What do I do so that the count starts from 00:00:00 in a correct manner? I've attached an image below. The simulation works correctly but it isn't the same here.

author: NorthGuy
author_rank: Super Contributor
timestamp: June 02, 2019, 03:14:49 pm
content: You need a reset signal which puts all the flip-flops into a known state.To keep the reset asserted at the beginning you can use a simple capacitor curcuit. When you power up, the capacitor charges slowly and the reset gets de-asserted only when the capacitor is charged.

author: edavid
author_rank: Super Contributor
timestamp: June 02, 2019, 03:26:04 pm
content: There is no need to have a reset circuit, since you need to set the clock anyway (unless you plan to set it by turning it on at midnight).

author: Dundarave
author_rank: Regular Contributor
timestamp: June 02, 2019, 04:29:49 pm
content: Just wire in two small push-buttons to manually advance the “hours” counter and “minutes” counter. (Seconds too, if you want to be anal about it, lol)Each time you power up, just click the buttons to advance the values to match the correct time.

author: jbeng
author_rank: Regular Contributor
timestamp: June 02, 2019, 08:48:17 pm
content: Do you have a schematic you can post?If not, what is the part number of the counter chips you are using?

author: ejeffrey
author_rank: Super Contributor
timestamp: June 02, 2019, 08:55:44 pm
content: Quote from: edavid on June 02, 2019, 03:26:04 pmThis is correct but misses the point. The only practical reason to build a discrete logic clock circuit is educational and learning to design a circuit that starts up in a well defined state is one of the most important aspects of digital logic.

author: D Straney
author_rank: Frequent Contributor
timestamp: June 03, 2019, 06:40:29 pm
content: Agreed about the power-on reset. The power-up state of a flip-flop, unless it has an internal reset circuit, will essentially be random as it depends on which of two logic gates can affect the other one, before being affected by the other one:You can use a "microprocessor reset" IC to generate a short "logic low" pulse at power-on to reset your flip-flops, but for learning purposes here's how you can build a simple one yourself:This uses an RC circuit to pull the /RESET signal low for a while when the circuit is first turned on. R2 makes sure that when the power is off, C1 is fully discharged. When power (VCC) is turned on, R1 will slowly charge up C1. Until the C1 voltage reaches about 2.1V (~0.7V Q1 Vbe + ~0.7V D1 Vf + ~0.7V D2 Vf), Q1 will be off and so Q2 will be on, producing a low output which resets the clock. After the C1 voltage is above the ~2.1V threshold, Q1 will turn on and Q2 will turn off, producing a high output and the clock will work normally. Q2 and R5 are basically just a logic inverter, so if you have a spare inverter in your circuit you can use that instead.Quote from: Dundarave on June 02, 2019, 04:29:49 pmAgree with this too, although you'll want to debounce your pushbuttons. Normal digital logic can react to Mhz-range signals, and the contact bounce that switches produce can appear as multiple pulses to your circuit (for example, you press the "hours" button once, but it increments the hours 5 times instead of 1). You can de-bounce your switches slowing down the response time, by adding an RC circuit + Schmitt trigger comparator/logic gate to filter out the bouncing (start with ~100 ms RC time constant; the Schmitt trigger input is important because many logic gates are not happy with a slowly-changing input voltage from the RC circuit). You can also de-bounce your buttons in a bulletproof but more complicated way that doesn't rely on timing by using an SPDT switch like method #1 onthis page.