The D flip-flop in part 10 takes a step only at a rising edge of its clock. With a push button as the clock, the circuit moves only when you press. Most digital circuits need something that ticks by itself, steadily, so that every flip-flop in the circuit takes its next step at the same moment: a , a signal that goes high and low, over and over, as a square wave.
If you built the final projects of Resistors, Capacitors and Transistors, you have already made one. The blinking pair of LEDs was an astable multivibrator: two transistors switching each other on and off, with two capacitors setting the pace. Its two collectors were a clock, a slightly ragged one. The chip in this part does the same job in one package, with a cleaner output and a timing you can calculate.
The was designed in 1971 by Hans Camenzind, working under contract to the American company Signetics, which began selling it in 1972. It is probably the most popular chip ever made: by one estimate from 2017, more than a billion are produced every year. Its name is often said to come from three 5 kΩ resistors inside it, but Camenzind said the number was chosen arbitrarily.
Inside, a 555 has two comparators that watch the voltage on a capacitor, a latch like the one in part 10, and a transistor that can empty the capacitor. Used as a clock, in what is called astable mode, it works like this:
- The capacitor charges through R1 and R2 in a row. While it charges, the output (pin 3) is high.
- When the capacitor reaches two-thirds of the supply, the latch flips. The output goes low, and the discharge pin (pin 7) connects to ground inside the chip.
- The capacitor empties through R2 alone into pin 7.
- When it falls to one-third of the supply, the latch flips back. The output goes high, pin 7 lets go, and charging starts again.
The capacitor swings between a third and two-thirds of the supply for ever, and the output follows it as a square wave. The time constants from The Capacitor set the pace:
high for 0.693 × (R1 + R2) × C
low for 0.693 × R2 × C
With R1 = 10 kΩ, R2 = 68 kΩ and C = 10 µF, the output is high for 0.54 seconds and low for 0.47 seconds: almost exactly one tick a second. The high part is always a little longer than the low part, because charging goes through both resistors. The share of each cycle spent high is the , here 54 %.
A clock you can tune
Choose R1, R2 and the capacitor. The orange curve is the capacitor's voltage, bouncing between the two dashed thresholds; the black line is the output on pin 3. The LED blinks at the real rate, and the shaded half of the middle cycle is the one happening now.
High for 0.693 × (10 kΩ + 68 kΩ) × 10 µF = 541 ms; low for 0.693 × 68 kΩ × 10 µF = 471 ms.
An ideal 555 on 5 V: the thresholds are exactly one-third and two-thirds of the supply. Real capacitors are often 20 % off their marked value, so expect your clock to be a little fast or slow.
Bigger resistors or a bigger capacitor slow it down; a smaller capacitor speeds it up. Try 1 µF for a clock ten times faster, about ten ticks a second, which is useful in part 12. Speed it up far enough and the LED seems to glow steadily, because the eye can no longer follow the blinks.
There are two kinds of 555. The original, sold as NE555, is built from bipolar transistors and needs at least 4.5 volts. CMOS versions, such as the TLC555, LMC555 and ICM7555, use the same pins, work from 2 volts and draw a small fraction of the current. Either works on 5 volts; on three AA cells, choose a CMOS one.
- Put the 555 across the channel, notch to the left, pin 1 in f14. It is an 8-pin chip, so pins 1 to 4 run along the bottom row and pins 5 to 8 back along the top.
- Power: pin 8 (a14) to the + rail and pin 1 (j14) to the − rail, with the 100 nF capacitor across the top rails beside pin 8. Tie pin 4, reset, to + (j17 to the bottom + rail).
- R1 from the top + rail to a15, pin 7’s strip. R2 from d15 to d19, and a yellow wire from b19 to b16, pin 6’s strip.
- Join pin 2 to pin 6: a yellow wire from i15 to a16.
- The 10 µF capacitor from j15 to the bottom − rail, with its striped leg in the rail. The 10 nF from pin 5 (a17) to the top − rail.
- The LED on pin 3: a wire from h16 to h22, 330 Ω from g22 to g25, the LED from i25 to i26, and j26 to −.
The LED blinks about once a second, on slightly longer than off. Count the blinks for a minute: anywhere from 50 to 70 is normal, given the tolerance of the capacitor. With a multimeter on pin 6, the reading swings slowly between about 1.7 and 3.3 volts.
A divide-by-two
Now give the clock something to do. Take a 74HC74 and wire one flip-flop so that it toggles: connect its output (pin 6) back to its own D input (pin 2). At every rising edge, Q copies D, which is the opposite of Q, so Q flips. Feed the 555’s output into the flip-flop’s clock, pin 3, with the usual ties on and , and put an LED on Q.
Put an LED on the 555’s output as well, and compare the two. The flip-flop’s LED changes once for every two blinks of the clock: on for a whole tick, off for a whole tick. It has divided the frequency by two, with a duty cycle of exactly 50 %, whatever the clock’s own duty cycle. That is the first step of a binary counter, and part 12 adds the second.
Now try the same toggling flip-flop with a push button as its clock instead of the 555, wired with its pull-down exactly like the CLK button in part 10. Each press should change the LED once. Press a few times. Sometimes it changes; sometimes it seems to ignore you; sometimes, if you watch closely, it flickers.
The flip-flop is working perfectly. The button is not. Inside a push button, a springy metal contact snaps against another, and like a dropped ball it bounces, opening and closing several times before it settles. The whole burst typically lasts a few thousandths of a second; one widely reproduced oscilloscope trace shows a switch bouncing many times in 2.6 milliseconds. To a person that is one press. To a 74HC flip-flop, which can respond in a few billionths of a second, it is a burst of separate presses, and it counts every one. An odd number of bounces looks right; an even number looks as if nothing happened.
That is , and it is why part 10’s warning mattered only now. A D flip-flop with a steady D does not care how many edges it sees: each one copies the same value. A toggling flip-flop, or a counter, counts all of them.
Catch the bounce
Press the button a few times with nothing between it and the toggling flip-flop, and watch the contact trace for the extra edges. Then switch to the RC filter and Schmitt trigger and press again.
Press the button a few times and watch whether the LED changes every time.
The bounces are randomised, lasting up to a few milliseconds. The cured circuit uses 10 kΩ and 1 µF, about 10 ms; the Schmitt trigger is modelled with thresholds of 2.9 and 1.9 V. Real 74HC14s vary from chip to chip, so check the datasheet for yours.
There are three classic cures, and each is something you have already met.
An RC filter and a Schmitt trigger. A resistor and a capacitor, as in What Capacitors Are For, smooth the bounces into a slow curve: the capacitor charges while the contacts touch and barely empties during the brief gaps. But a slow curve is a problem of its own, because a normal gate input lingers in the forbidden middle band from part 3 and may switch several times on the way through. The answer is a , an input with two thresholds: it switches high only when the voltage rises past the upper one, and low only when it falls past the lower one. Noise and wobbles between the two do nothing. The 74HC14 has six Schmitt-trigger inverters; use two in a row so the output is the right way up. Otto Schmitt invented the circuit in 1934, as a graduate student studying the nerves of squid.
A latch. The SR latch from part 10 cannot bounce. Once Set has pulled Q high, further bounces on Set only set it again, which changes nothing. Use a changeover switch, whose common contact moves between and , or two buttons, one for on and one for off: the latch’s output is perfectly clean.
A 555. In its other mode, monostable, a 555 gives one pulse of a fixed length when triggered, and ignores further triggers until the pulse is over. Set the pulse longer than the bounce and every press gives exactly one edge. Microcontrollers usually do the same thing in software, reading a button several times over a few milliseconds and acting only once it has stopped changing.
You now have every ingredient: inputs you can trust, gates, algebra, memory and a clock. The last part puts them together in two finished projects that count and add, and show their answers in lights.
Sources for this part
The 555 timer
Bounce and its cures