Author Topic: Digital Clock  (Read 1323 times)

0 Members and 1 Guest are viewing this topic.

Offline Sangharsh SharmaTopic starter

  • Contributor
  • Posts: 15
  • Country: np
Digital Clock
« on: June 02, 2019, 03:00:55 pm »
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.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3286
  • Country: ca
Re: Digital Clock
« Reply #1 on: June 02, 2019, 03:14:49 pm »
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.
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3464
  • Country: us
Re: Digital Clock
« Reply #2 on: June 02, 2019, 03:26:04 pm »
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).
 

Offline Dundarave

  • Regular Contributor
  • *
  • Posts: 160
  • Country: ca
Re: Digital Clock
« Reply #3 on: June 02, 2019, 04:29:49 pm »
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.
 

Offline jbeng

  • Regular Contributor
  • *
  • Posts: 53
  • Country: us
Re: Digital Clock
« Reply #4 on: June 02, 2019, 08:48:17 pm »
Do you have a schematic you can post?
If not, what is the part number of the counter chips you are using?
"It's such a fine line between stupid and clever" - David St. Hubbins
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 4033
  • Country: us
Re: Digital Clock
« Reply #5 on: June 02, 2019, 08:55:44 pm »
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).

This 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.
 
The following users thanked this post: tooki, TomS_

Offline D Straney

  • Frequent Contributor
  • **
  • Posts: 269
  • Country: us
Re: Digital Clock
« Reply #6 on: June 03, 2019, 06:40:29 pm »
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.

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)

Agree 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 on this page.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf