Learn & build · Electronics · Chapter 9

Oscillators and timers

Every computer, radio, watch and blinking LED needs something that ticks. An oscillator is a circuit that turns steady DC into a repeating signal all by itself. This chapter builds the most famous one, the 555 timer, works out its timing from a charging capacitor, and then looks at the crystals that keep clocks accurate to seconds a month.

In plain words: an oscillator is a circuit that keeps changing its mind. Something fills up (a capacitor charges); when it gets full enough, a switch flips and it starts emptying; when it's empty enough, the switch flips back. The fill-and-empty time sets the rhythm.

1. Why feedback can ring forever

Chapter 7's op-amps used negative feedback to settle down. Flip the sign and a circuit amplifies its own output, round and round. If a signal comes back around the loop with the same timing (a full 360° of phase) and at least as strong as it left, it sustains itself, like a microphone too close to its speaker. That's the Barkhausen criterion: loop gain ≥ 1 and loop phase = 360°. Every oscillator is a way of making that true at exactly one frequency.

A microphone near a speaker howls at one particular pitch, not all pitches. Why that one?

The delay from speaker to mic is a whole number of periods at that pitch, so each trip adds to the last. Move the mic, change the delay, and the howl jumps to another pitch.

2. The 555 timer, astable

Inside a 555 are three equal resistors that make two reference voltages, ⅓ and ⅔ of the supply, two comparators that watch the capacitor against them, and a flip-flop that remembers which way it's going. The capacitor charges through R1 + R2 until it reaches ⅔, the output drops and the discharge pin empties it through R2 down to ⅓, the output rises again, and so on. Change the parts and watch.

🎯 Challenge: make it blink at about 1 Hz (between 0.9 and 1.1) with a duty cycle under 60%.

The math, step by step

From chapter 2, a capacitor charging toward \(V_s\) through \(R\) gets from \(V_a\) to \(V_b\) in

\[ t = RC \,\ln\frac{V_s - V_a}{V_s - V_b} \]

Charging from ⅓ to ⅔ of \(V_s\) through \(R_1 + R_2\): \(t = (R_1 + R_2) C \ln\frac{2/3}{1/3} = (R_1 + R_2)C \ln 2\). Discharging toward 0 from ⅔ to ⅓ through \(R_2\): \(R_2 C \ln 2\). So

\[ t_{high} = 0.693\,(R_1 + R_2)\,C, \quad t_{low} = 0.693\,R_2 C, \quad f = \frac{1}{t_{high} + t_{low}} = \frac{1.44}{(R_1 + 2R_2)\,C} \]

Notice the supply voltage cancels out: the thresholds are fractions of the same supply the capacitor charges toward. A 555 blinks at the same rate on 5 V or 15 V. And the duty cycle \(t_{high}/(t_{high}+t_{low})\) is always above 50%, since charging goes through both resistors.

R1 = 1 kΩ, R2 = 47 kΩ, C = 10 µF (the lab's "555 LED blinker"). What frequency?

\(1.44 / ((1 + 94)\text{ kΩ} \times 10\,\mu F) = 1.44 / 0.95 = 1.52\) Hz.

You change the supply from 5 V to 12 V. What happens to the blink rate?

Both the target the capacitor charges toward and the thresholds are proportional to \(V_s\); only their ratio enters the logarithm.

An oscillator is feedback that comes back in step and at least as strong as it left. In a 555 that loop is a capacitor charging between ⅓ and ⅔ of the supply, so R and C alone set the rhythm.

3. The 555 as a one-shot

Wired differently (monostable), the 555 waits. A short low pulse on the trigger pin starts it: the output goes high, the capacitor charges through R from 0 to ⅔, and then the output drops and stays low until the next trigger. It turns a quick button press into a clean pulse of a set length.

A one-shot with R = 100 kΩ and C = 10 µF. How long is the pulse? (It charges from 0 to ⅔: \(t = RC \ln 3\).)

\(\ln 3 = 1.0986\), so \(t \approx 1.1\,RC = 1.1 \times 100\text{k} \times 10\,\mu F = 1.1\) s.

4. Crystals: keeping time

RC timing is only as good as the parts: 5% resistors and 20% capacitors make a 555 that's off by a lot, and it drifts with temperature. For clocks, a sliver of quartz does the timing. Quartz is piezoelectric: squeeze it and it makes a voltage, put a voltage on it and it flexes. Cut to size, it rings mechanically at one frequency with a Q of 10,000 to 100,000 (a tuned circuit from chapter 3 manages about 100), and an amplifier keeps it ringing.

The math

Accuracy is quoted in parts per million: ±20 ppm means the frequency may be off by 20 millionths. Over a time \(T\), the clock gains or loses \(T \times \text{ppm} \times 10^{-6}\): a month is 2.6 million seconds, so 20 ppm is up to 52 s per month. A cheap 555 at 5% would be off by 36 hours a month.

Why 32,768 Hz? It's \(2^{15}\). Fifteen flip-flops in a row, each halving the frequency (chapter 12), turn it into exactly 1 Hz, one tick per second. That's what's inside every quartz watch and every computer's real-time clock.

How many divide-by-two stages turn 32,768 Hz into 1 Hz?

\(32{,}768 = 2^{15}\), so 15 halvings.

A 10 ppm crystal, over 30 days (2,592,000 s). Up to how many seconds off?

\(2{,}592{,}000 \times 10 \times 10^{-6} \approx 26\) s.

5. LC oscillators: radio frequencies

For megahertz, a coil and capacitor (chapter 3) set the frequency and a transistor, amplifying (chapter 4, section 5), tops up the energy lost each cycle: the Colpitts and Hartley oscillators, the heart of every old radio's tuning. Your RTL-SDR dongle uses a 28.8 MHz crystal and a phase-locked loop to make any frequency from it, which the radio course takes apart.

Try the 555 LED blinker in the circuit lab: change R2 and C and measure the frequency on its scope. Next: power supplies.

Previous: Filters · All chapters: Learn & build.

Last updated