How do Digital and Analog Clocks Work?
Branch Education
0:00 Inside almost every piece of technology is a tiny clock
0:03 that ticks at a rate of over a billion times a second,
0:07 generating a digital heartbeat that is
0:10 critical to regulating the execution of code,
0:13 the movement of data in the processor and memory,
0:16 the generation of wireless signals for transmitting data and much more.
0:20 So then, how do we generate a clock
0:24 that precisely pulses at less than half a nanosecond?
0:28 It might seem counter-intuitive,
0:30 but this billions-of-times-a-second heartbeat, or gigahertz clock signal,
0:35 is incredibly similar to how a ten-dollar
0:39 analog wall clock ticks through the seconds, minutes, and hours of the day.
0:44 In order to explore how a gigahertz technological heartbeat is generated,
0:49 let’s open a wall clock, see how it works,
0:52 and then see how the same technology is
0:54 used to produce your desktop computer’s gigahertz clock signal.
1:03 So, let’s jump right in.
1:10 Inside this ten-dollar wall clock are 5 unique systems that enable it to work.
1:16 The most recognizable is the gear train made from 8 gears.
1:20 At the beginning of the gear train, a driver gear is rotated by an electromagnet
1:26 which provides the force to rotate the clock hands.
1:30 This electromagnet is composed of a coil of wire,
1:33 which uses electrical current to generate a magnetic field,
1:37 and a strip of iron to channel that magnetic field to the drive gear.
1:43 Every second the electromagnet switches directions,
1:46 thus causing the magnet inside the driver gear to rotate 180 degrees
1:51 in order to align its permanent magnet
1:54 with the fields produced by the electromagnet.
1:58 Therefore, the driver gear rotates fully around once every two seconds.
2:03 Most of the gears in the gear train are composed of compound gears,
2:08 each of which has two different gears, one on top of the other.
2:12 To move the second hand, which is mounted on a shaft through the clock center,
2:17 we go through a 12 to 48 gear reduction and then an 8 to 60 gear reduction,
2:24 thereby reducing one revolution every 2 seconds down to one every 60 seconds.
2:30 The minute hand is also mounted on a shaft through the center
2:35 and is driven through an 8 to 64 gear reduction to the idler,
2:39 followed by 8 to 60 to the minute hand.
2:42 And finally, the hour hand is driven via a 15 to 45 reduction to the idler
2:49 and a 10 to 40 gear reduction to produce one rotation every 12 hours.
2:55 As a result, we have 3 shafts rotating
2:58 to which the hands of the clock are mounted, each rotating at different speeds.
3:04 The last gear is used to set the time,
3:08 and interestingly this gear has 13 teeth on it,
3:12 and rotates once every 69 minutes.
3:15 As in the name, the time-setting gear
3:18 directly rotates the minute and hour hands, however,
3:22 the gear with the second hand doesn’t move
3:24 because the two parts of this compound gear slip
3:27 from the high torque required to rotate the second
3:31 hand 52 times per rotation of the time-setting gear.
3:35 Now that we’ve covered the gear train,
3:38 let’s dive into the quartz crystal oscillator and see what makes
3:42 this clock nearly identical to the digital clock in your computer.
3:46 Inside this metal cylinder is a quartz
3:49 crystal tuning fork with wires printed onto
3:52 the side which travel along the legs to the outside of the metal canister.
3:57 Let’s focus on a single side with wires printed on the left and right.
4:03 Inside the quartz is a crystal lattice of one silicon
4:07 for every two oxygen atoms which forms a network of covalent bonds,
4:12 with electrons being more attracted
4:14 to the oxygen due to their electronegativity.
4:16 When you cut a slice of quartz in a particular direction,
4:20 you can see repeating sections of a crystal
4:23 lattice with a hexagonal organization of oxygen and silicon.
4:27 When a negative charge is applied to the printed wires,
4:32 an electric field is directed to the crystal lattice
4:35 and the negatively charged oxygen atoms are pushed away,
4:39 whereas the positively charged silicon is pulled towards the wire.
4:44 The combined movement of all the oxygen moving away and the silicon
4:48 moving towards the wire results in a lengthening of the crystal lattice.
4:53 Conversely, when a positive charge is applied,
4:56 oxygen moves towards the positive charge and the silicon away,
5:01 and as a result, the crystal lattice shrinks in length.
5:05 This lengthening and shrinking along the length of the crystal lattice,
5:09 called the piezoelectric effect,
5:11 causes the leg of this tuning fork to move back and forth.
5:14 Let’s move back to view the tuning fork
5:16 crystal with wires printed on each of the sides.
5:17 As mentioned before, when a voltage is applied,
5:19 the tuning fork lengthens and bends outwards and when the voltage is turned off,
5:24 the quartz bounces backward.
5:26 The crystal bounces back and forth creating positive
5:29 and negative voltages with the frequency of oscillation being dependent
5:33 on the orientation of the crystal lattice as well
5:37 as the shape and dimension of the cut crystal.
5:40 The purpose of having two legs is to create a vibrational mode
5:44 wherein the prongs vibrate and resonate together while the base doesn’t move.
5:49 Frequently manufacturers add small amounts of metal to the ends
5:54 of the crystal to tune it to the desired frequency.
5:58 However, to get a crystal to continuously oscillate,
6:01 a changing voltage needs to be repeatedly applied to the wires on the legs.
6:06 Specifically, this voltage needs to match the movement
6:10 of the crystal such that the peak
6:13 positive voltage is aligned with the movement of the crystal in one direction,
6:17 and the opposite when the crystal moves in the other direction,
6:21 kind of like pushing a kid on a swing set when it’s at its low point,
6:26 but in both directions.
6:27 To do that we use an integrated circuit with an inverter to form a feedback loop
6:33 and two capacitors to assist in the timing
6:35 of the voltage from the inverter and feedback loop,
6:39 thus producing a resonant movement in the crystal.
6:42 This is a rather complicated circuit to fully explain,
6:45 but here’s one way of thinking about it.
6:48 An inverter on its own flips the input from a 1
6:53 to an output of a 0 and vice versa.
6:57 However, if we loop an inverter back in on itself,
7:00 depending on the physical design of the inverter,
7:03 the output will continuously flip between one and zero,
7:07 a few picoseconds per cycle.
7:09 And, if we add the crystal tuning fork
7:13 and capacitors in the path of the feedback loop,
7:16 then the flipping between 1 and 0 and back
7:20 is regulated by the geometry and movement of the prongs
7:23 of the crystal oscillator tuning fork and the filling
7:27 and emptying of the charges in both of the capacitors.
7:30 For this wall clock, the time it takes is 30.52 microseconds
7:36 per cycle resulting in 32,768 cycles per second.
7:42 The signal is then fed to another section
7:45 in the integrated circuit where a binary counter counts each cycle,
7:49 and after 32,768 cycles, which takes one second,
7:54 a signal is sent to the electromagnet controller
7:58 telling it to flip the direction of the electromagnet,
8:02 thereby rotating the driver gear around 180 degrees and moving
8:06 the hands of the clock forward by one second.
8:10 One thing to note is that if your clock is either fast or slow,
8:15 it’s most likely because the crystal
8:17 oscillator doesn’t oscillate exactly at 32.768
8:20 kilohertz due to the geometry and incorrect resonant frequency of tines.
8:26 These crystals typically have 20 parts per million accuracies,
8:31 meaning it can gain or lose at most 1.7 seconds a day,
8:37 or 10 and a half minutes a year.
8:40 As mentioned earlier, this wall clock is composed of a set of systems
8:45 with each falling under a different domain of science and engineering.
8:50 These topics are rather complex and typically covered by college courses,
8:55 but instead of paying thousands of dollars there’s a free
8:59 and easy way to learn and that’s with this video’s sponsor, Brilliant.org.
9:06 Brilliant reimagines how courses are taught.
9:09 Instead of boring hour-long lectures or textbooks that put you to sleep,
9:14 Brilliant uses fun and interactive modules,
9:17 with thousands of lessons from basics to advanced
9:21 topics– and new lessons added every month.
9:25 For example, in a single afternoon, you can learn about gear trains,
9:30 then dive into oscillations and classical mechanics followed
9:34 by chemistry and understanding how batteries store energy,
9:38 and finally, you can finish it up
9:41 with an exploration of logic circuits and how computers work.
9:45 Whatever your skill level, Brilliant customizes its content to fit your needs
9:50 and for you to learn at your own pace.
9:54 For the fans of Branch Education,
9:57 we recommend you check out their course on How Technology Works
10:01 with lessons such as How GPS Works or How Computer Memory Works.
10:07 We can’t emphasize enough how important it is to be a life-long learner,
10:12 so for the viewers of this channel, Brilliant is offering a free 30-day trial
10:18 with access to all their thousands of lessons.
10:22 Additionally, Brilliant is offering 20% off an annual
10:26 subscription to the first 200 people who sign up.
10:31 Just go to brilliant.org/brancheducation.
10:33 The link is in the description below.
10:38 Let’s move on and see how smartphones and computers
10:42 generate a clock between 1 to 5 gigahertz
10:45 which is 30 to 150 thousand times faster than
10:49 a single oscillation of this quartz crystal tuning fork.
10:53 Let’s look again at this inverter looped back upon
10:56 itself and add two more inverters into the loop,
11:00 thus creating a ring oscillator.
11:02 Due to the odd number of inverters,
11:05 the output rapidly oscillates between a 1 and a 0.
11:09 These inverters can operate incredibly quickly and can
11:13 easily reach the gigahertz frequency range and higher.
11:18 However, the issue is that this ring oscillator’s frequency is highly
11:22 dependent on temperature as well as the physical geometry and electrical
11:27 properties of the transistors and thus has a frequency range
11:31 of plus or minus 50 percent or more from the desired frequency.
11:37 Therefore, to stabilize the output frequency of a ring oscillator to less than
11:41 a few parts per million accuracy we use a circuit called a phase-locked loop.
11:46 This is a complicated circuit, but here’s the general idea of how it works.
11:52 On the right, we have the ring oscillator,
11:54 and when we add some additional circuitry, depending on the input voltage,
12:00 the output frequency changes,
12:02 and the ring oscillator is now called a voltage-controlled oscillator or VCO.
12:07 On the left we have a 16-megahertz crystal
12:10 oscillator similar to the tuning fork crystal oscillator,
12:14 but by changing the crystals’ geometry
12:16 and placing electrodes on the top and bottom,
12:19 we get a crystal with a faster resonant frequency.
12:22 And again, this crystal is placed in a feedback
12:26 loop of its own to produce a stable resonant frequency.
12:30 In the middle is a frequency and phase comparator that outputs
12:34 a signal equal to the difference
12:37 between the crystal and the voltage-controlled oscillator.
12:39 Next, an integrator takes the output from the phase comparator and turns it
12:45 into a steady voltage and uses
12:48 it to drive the voltage-controlled ring oscillator.
12:51 Finally, this frequency is fed back into the frequency
12:55 and phase comparator, and as it is,
12:58 the feedback loop will drive the ring oscillator to match
13:01 and be identical to the output from the 16-megahertz crystal oscillator loop.
13:06 However, since we want to get, for example, a 2.4 gigahertz signal,
13:12 which is 150 times that of the 16-megahertz crystal oscillator,
13:18 we add a frequency divider into the feedback loop.
13:21 This frequency divider is just like the one in the wall clock
13:26 that took 32,768 cycles per second and turned it into a 1 hertz signal,
13:32 rather now, we’re dividing by 150.
13:35 Next, the signal is sent to the frequency and phase
13:39 comparator which wants the two signals to be identical.
13:44 However, by having them different,
13:46 it outputs a signal which goes through the integrator,
13:49 turning it into a steady voltage,
13:52 and driving the voltage-controlled oscillator up to a higher frequency,
13:56 which will be exactly 150 times that of the 16-megahertz crystal,
14:02 which is 2.4 gigahertz.
14:04 Using this phase-locked loop we have
14:07 an incredibly fast frequency generator producing a signal
14:11 that is exactly 150 times
14:14 that of a reliably manufactured and temperature-stable quartz crystal.
14:18 Additionally, if we want to change the desired frequency,
14:22 we have the binary counter divide by a different number,
14:26 thus changing the amount the 16 megahertz crystal is multiplied by.
14:30 And in fact, all smartphones do this when not actively in use
14:36 in order to the reduce clock frequency
14:39 of their processor and conserve battery life.
14:42 That’s pretty much it for clocks and crystal oscillators.
14:45 One thing to note is that sometimes MEMS oscillators are
14:49 used in smartphones to save space instead of crystal oscillators,
14:54 and we’ll dive into MEMS in a future episode.
14:57 We believe the future will require
14:59 a strong emphasis on engineering education and we’re
15:03 thankful to all our Patreon and YouTube
15:06 Membership Sponsors for supporting this dream.
15:08 If you want to support us on YouTube Memberships,
15:12 or Patreon, you can find the links in the description.
15:16 This is Branch Education, and we create 3D animations that dive deeply
15:21 into the technology that drives our modern world.
15:24 Watch another Branch video by clicking one
15:28 of these cards or click here to subscribe.
15:32 Thanks for watching to the end!