So far in our investigation of digital logic, we’ve used what is called small scale integration, or SSI for short. Now it is time to ramp it up a bit and use some medium scale integration (MSI) devices. Wouldn’t it be nice to be able to push a button and have a digital device remember your settings? Sort of like the push-button memory on some high-end transceivers? There is a device that will do that, and its tongue-twisting name is bistable multivibrator. Most of the world knows it by its common name, flip-flop.
The most common and easy to obtain (they used to have them at The Shack) D(ata)-type flip-flop is the CMOS 4013 (See Figure 1). They come two inside of a 14-pin DIP (dual inline package) for 50 each package and they work like this:
There are four inputs and two outputs. The four inputs are set, reset, data and clock (S, R, D, C). The two outputs are Q and /Q (not-Q).
Let’s forget about S and R for a moment. When you input a logic 1 to the clock, whatever is on the D line at that exact moment gets transferred to the Q output. The /Q output is the inverse of the Q output: If Q is high, /Q is low and vice versa (with one notable exception noted below).
Tricks and Treats
One of the first tricks you learn to do with the 4013 is to transform it from a D-flop to a T(oggle)-flop. See Figure 2. Now when the clock goes high, Q and /Q change state. That is, if Q is high, on the start of the clock going high, Q goes low. If it is low, it goes high. Back and forth with each push of the clock push button. See why they called it a flip-flop?
Now for the R and the S inputs. No matter what the clock has done or the state(s) of the Q outputs, if you put a high on the R input, Q goes low and /Q goes high. Similarly, a high on the S input forces Q high and /Q low. Here is the first gotcha of the day. If both R and S are simultaneously high, both Q and /Q are set high.
One neat trick that you can do with R (or S, depending on what you are trying to achieve) is to hook a small capacitor up to the R input, with a relatively high-value resistor to ground. That way when you throw the master switch, the 4013 comes up in a predictable state. Let me try that again. If you use the R input, at the instant the power comes on, a pulse goes to the R input through the capacitor and sets Q high and /Q low. After the capacitor discharges, the flip-flop will act just as described above. This is called a boot-up or power-on reset circuit.
However, if you are not using the R and S inputs, you must tie them low. Just as with all unused CMOS (complementary metal oxide semiconductor) inputs, they have to go somewhere, either high or low. If you let them float by leaving them unconnected, they will give you strange results.
Now you have the ability to have one tiny, cheap push-button switch be the on-off for any of your airplane circuitry as a T-type flop clock input. Well, almost.
Second gotcha of the day. As mentioned, the clock input is concerned only with what happens when the input goes high. Once it gets there, it can stay there forever without making any change in the output, and there is no change in the output when the clock goes low. The gotcha is that the clock input has to be relatively fast, and a cheap push-button switch has a tendency to bounce. Hit an anvil with a hammer and you’ll see what I mean. For a single blow, the hammer will hit the anvil, bounce up a bit, come back down, bounce up a bit more, and finally after four or five bounces the hammer will settle down onto the surface of the anvil.
Likewise the switch. Push the button and it will send half a dozen pulses to the clock input. Try and smooth out the pulses with a capacitor, and you have a very slow rising input. Solution? How about the Schmitt trigger buffer we found out about in the April 2009 issue? Connect the push button to the RC filter on the Schmitt input and use the Schmitt output as the clock output. That will do two things simultaneously. One, it will debounce the switch; two, it will provide a nice, fast clock input.
How They’re Used
I have spent a fair amount of time on the operation of the flip-flop as it forms the basis of a whole bunch of useful CMOS parts. Here are a few of them with descriptions:
The 4017 is a decade counter. That is, it has three inputs and 10 outputs in a 16-pin DIP package. For each Clock rising edge going from low to high, the count advances one output. It counts zero, one, two, three and so on until it gets to 9 and then it resets itself to zero. Neat. You want to have one of 10 functions come on one at a time? Just push the clock push button, and you can select which of #1 to #9 circuits you want to energize. Lots of flip-flops inside the package, one counter to a package, 50 a package. It’s the same problem with the clock, and the same Schmitt trigger solution.
The 4024 is a neat device for those of you who want a lot of different alarm tones from a single tone generator. Say you start out with a 10-kHz tone generator, and you apply it to the clock input of a 4024. Out of the #1 output you get a 5-kHz tone; out of the #2 output you get a 2.5-kHz tone; #3 gives 1.25 kHz, #4 gives 625 Hz, #5 gives 312 Hz, #6 gives 156 Hz and #7 gives 78 Hz. While the last one or two may not be useful, the other five certainly are.
The 4020 and 4040 are divided by 2 to 16,384 or 4096 respectively. What do you do with them? Well, next month Im going to wind up this series of articles with a few gee-whiz circuits, one of which is a crystal-controlled accurate timebase using a wristwatch crystal. The crystal oscillates at 32,768 Hz, so if I feed that signal into the clock of a 4020, Ill get out a precise 2-Hz signal. 2 Hz? What does that sound like? Tick-tock, tick-tock. We now have the ability to make our own little timers for whatever use we wish. Fuel tank timing? Light the light after 2 hours? Or 45 minutes? Or whatever time you want. How long a timer? Hook the 2-Hz output of one 4020 into the clock of a second 4020, and you will get out one high after most any time you choose up to 3100 days.
For the serious experimenter, I refer you to the combination of a 4510 binary coded decimal (BCD) counter, driving a 4511 LED digit decoder that drives a small seven-segment digit. Press the clock button once, and the display shows a 1, two presses and the display goes to a 2, and so on through 9, when it will reset itself to zero and start over. You can also cascade these devices so that you have counts up to as many digits as your wallet can afford.
Do not think for a moment that I have shown you all that the CMOS can do. Ive given you half a dozen examples out of several hundred available chips. A quick Google of CMOS will give you a taste of all the things that you can do with digital logic. Happy experimenting.