Book Read Free

Make: Electronics

Page 25

by Charles Platt


  How to arrange this? I think we need a flip-flop. When the flip-flop gets a signal, it starts the counter running—and keeps it running. When the flip-flop gets another signal (from the user pressing a button), it stops the counter running, and keeps it stopped.

  How do we build this flip-flop? Believe it or not, we can use yet another 555 timer, in a new manner known as bistable mode.

  Fundamentals

  The bistable 555 timer

  Figure 4-39 shows the internal layout of a 555 timer, as before, but the external components on the righthand side have been eliminated. Instead, I’m applying a constant negative voltage to pin 6. Can you see the consequences? Suppose you apply a negative pulse to the trigger (pin 2). Normally when you do this and the 555 starts running, it generates a positive output while charging a capacitor attached to pin 6. When the capacitor reaches 2/3 of the full supply voltage, this tells the 555 to ends its positive output, and it flips back to negative.

  Well, if there’s no capacitor, there’s nothing to stop the timer. Its positive output will just continue indefinitely. However, pin 4 (the reset) can still override everything, so if you apply negative voltage to pin 4, it flips the output to negative. After that, the output will stay negative indefinitely, as it usually does, until you trigger the timer by dropping the voltage to pin 2 again. This will flip the timer back to generating its positive output.

  Here’s a quick summary of the bistable configuration:

  A negative pulse to pin 2 turns the output positive.

  A negative pulse to pin 4 turns the output negative.

  The timer is stable in each of these states. Its run-time has become infinite.

  It’s OK to leave pins 5 and 7 of the timer unconnected, because we’re pushing it into extreme states where any random signals from those pins will be ignored.

  Figure 4-39. In the bistable configuration, pin 6 of a 555 timer is perpetually negative, so the timer cycle never ends, unless you force it to do so by applying a negative pulse to pin 4 (the reset).

  In bistable mode, the 555 has turned into one big flip-flop. To avoid any uncertainty, we keep pins 2 and 4 normally positive via pull-up resistors, but negative pulses on those pins can overwhelm them when we want to flip the 555 into its opposite state. The schematic for running a 555 timer in bistable mode, controlled by two pushbuttons, is shown in Figure 4-40. You can add this above your existing circuit. Because you’re going to attach the output from IC6 to pin 2 of IC1, the topmost counter, you can disconnect S1 and R1 from that pin. See Figure 4-41.

  Now, power up the circuit again. You should find that it counts in the same way as before, but when you press S4, it freezes. This is because your bistable 555 timer is sending its positive output to the “clock disable” pin on the counter. The counter is still receiving a stream of pulses from the astable 555 timer, but as long as pin 2 is positive on the counter, the counter simply ignores the pulses.

  Now press S5, which flips your bistable 555 back to delivering a negative output, at which point the count resumes.

  We’re getting close to a final working circuit here. We can reset the count to zero (with S3), start the count (with S5), and wait for the user to stop the count (with S4). The only thing missing is a way to start the count unexpectedly.

  Figure 4-40. Adding a bistable 555 timer to the reflex tester will stop the counter with a touch of a button, and keep it stopped.

  R9, R10: 1K

  IC6: 555 timer

  The Delay

  Suppose we set up yet another 555 in monostable mode. Trigger its pin 2 with a negative pulse, and the timer delivers a positive output that lasts for, say, 4 seconds. At the end of that time, its output goes back to being negative. Maybe we can hook that positive-to-negative transition to pin 4 of IC6. We can use this instead of switch S5, which you were pressing previously to start the count.

  Check the new schematic in Figure 4-41 which adds another 555 timer, IC7 above IC6. When the output from IC7 goes from positive to negative, it will trigger the reset of IC6, flipping its output negative, which allows the count to begin. So IC7 has taken the place of the start switch, S4. You can get rid of S4, but keep the pull-up resistor, R9, so that the reset of IC6 remains positive the rest of the time.

  Figure 4-41. The completed control section of the circuit, to be added above these timers.

  R7, R9, R10, R12: 1K

  R8: 2K2

  R11: 330K

  C1: 100 µF

  C2: 68 µF

  C3, C4, C6: 0.1 µF

  C5: 10 µF

  S1, S2, S3: tactile switches

  IC5, IC6, IC7: 555 timers

  This arrangement works because I have used a capacitor, C4, to connect the output of IC7 to the reset of IC6. The capacitor communicates the sudden change from positive to negative, but the rest of the time it blocks the steady voltage from IC7 so that it won’t interfere with IC6.

  The final schematic in Figure 4-41 shows the three 555 timers all linked together, as you should insert them above the topmost counter, IC1. I also added an LED to signal the user. Figure 4-42 is a photograph of my working model of the circuit.

  Figure 4-42. The complete reaction-timer circuit barely fits on a 63-row breadboard.

  Because this circuit is complicated, I’ll summarize the sequence of events when it’s working. Refer to Figure 4-41 while following these steps:

  1. User presses Start Delay button S4, which triggers IC7.

  2. IC7 output goes high for a few seconds while C5 charges.

  3. IC7 output drops back low.

  4. IC7 communicates a pulse of low voltage through C4 to IC6, pin 4.

  5. IC 6 output flips to low and flops there.

  6. Low output from IC6 sinks current through LED and lights it.

  7. Low output from IC6 also goes to pin 2 of IC1.

  8. Low voltage on pin 2 of IC1 allows IC1 to start counting.

  9. User presses S3, the “stop” button.

  10. S3 connects pin 2 of IC6 to ground.

  11. IC6 output flips to high and flops there.

  12. High output from IC6 turns off the LED.

  13. High output from IC6 also goes to pin 2 of IC1.

  14. High voltage on pin 2 of IC1 stops it from counting.

  15. After assessing the result, user presses S2.

  16. S2 applies positive voltage to pin 15 of IC1, IC2, IC3.

  17. Positive voltage resets counters to zero.

  18. The user can now try again.

  19. Meanwhile, IC5 is running continuously throughout.

  In case you find a block diagram easier to understand, I’ve included that, too, in Figure 4-43.

  Figure 4-43. The functions of the reflex tester, summarized as a block diagram.

  Using the Reflex Tester

  At this point, you should be able to test the circuit fully. When you first switch it on, it will start counting, which is slightly annoying, but easily fixed. Press S3 to stop the count. Press S2 to reset to zero.

  Now press S4. Nothing seems to happen—but that’s the whole idea. The delay cycle has begun in stealth mode. After a few seconds, the delay cycle ends, and the LED lights up. Simultaneously, the count begins. As quickly as possible, the user presses S3 to stop the count. The numerals freeze, showing how much time elapsed.

  There’s only one problem—the system has not yet been calibrated. It is still running in slow-motion mode. You need to change the resistor and capacitor attached to IC5 to make it generate 1,000 pulses per second instead of just three or four.

  Substitute a 10K trimmer potentiometer for R8 and a 1 µF capacitor for C2. This combination will generate about 690 pulses per second when the trimmer is presenting maximum resistance. When you turn the trimmer down to decrease its resistance, somewhere arou
nd its halfway mark the timer will be running at 1,000 pulses per second.

  How will you know exactly where this point is? Ideally, you would attach an oscilloscope probe to the output from IC5. But, most likely, you don’t have an oscilloscope, so here are a couple other suggestions.

  First remove the 1 µF capacitor at C2 and substitute a 10 µF capacitor. Because you are multiplying the capacitance by 10, you will reduce the speed by 10. The leftmost digit in your display should now count in seconds, reaching 9 and rolling over to 0 every 10 seconds. You can adjust your trimmer potentiometer while timing the display with a stopwatch. When you have it right, remove the 10 µF capacitor and replace the 1 µF capacitor at C2.

  The only problem is, the values of capacitors may be off by as much as 10%. If you want to fine-tune your reflex timer, you can proceed as follows.

  Disconnect the wire from pin 5 of IC3, and substitute an LED with a 1K series resistor between pin 5 and ground. Pin 5 is the “carry” pin, which will emit a positive pulse whenever IC3 counts up to 9 and rolls over to start at 0 again. Because IC3 is counting tenths of a second, you want its carry output to occur once per second.

  Now run the circuit for a full minute, using your stopwatch to see if the flashing LED drifts gradually faster or slower than once per second. If you have a camcorder that has a time display in its viewfinder, you can use that to observe the LED.

  If the LED flashes too briefly to be easily visible, you can run a wire from pin 5 to another 555 timer that is set up in monostable mode to create an output lasting for around 1/10 of a second. The output from that timer can drive an LED.

  Enhancements

  It goes without saying that anytime you finish a project, you see some opportunities to improve it. Here are some suggestions:

  1. No counting at power-up. It would be nice if the circuit begins in its “ready” state, rather than already counting. To achieve this you need to send a negative pulse to pin 2 of IC6, and maybe a positive pulse to pin 15 of IC1. Maybe an extra 555 timer could do this. I’m going to leave you to experiment with it.

  2. Audible feedback when pressing the Start button. Currently, there’s no confirmation that the Start button has done anything. All you need to do is buy a piezoelectric beeper and wire it between the righthand side of the Start button and the positive side of the power supply.

  3. A random delay interval before the count begins. Making electronic components behave randomly is very difficult, but one way to do it would be to require the user to hold his finger on a couple of metal contacts. The skin resistance of the finger would substitute for R11. Because the finger pressure would not be exactly the same each time, the delay would vary. You’d have to adjust the value of C5.

  Summing Up

  This project demonstrated how a counter chip can be controlled, how counter chips can be chained together, and three different functions for 555 timers. It also showed you how chips can communicate with each other, and introduced you to the business of calibrating a circuit after you’ve finished building it.

  Naturally, if you want to get some practical use from the circuit, you should build it into an enclosure with heavier-duty pushbuttons—especially the button that stops the count. You’ll find that when people’s reflexes are being tested, they are liable to hit the stop button quite hard.

  Because this was a major project, I’ll follow it up here with some quicker, easier ones as we move into the fascinating world of another kind of integrated circuit: logic chips.

  Experiment 19: Learning Logic

  You will need:

  Assorted resistors and capacitors.

  74HC00 quad 2-input NAND chip, 74HC08 quad 2-input AND chip, and LM7805 voltage regulator. Quantity: 1 of each.

  Signal diode, 1N4148 or similar. Quantity: 1.

  Low-current LED. Quantity: 1.

  SPST tactile switches. Quantity: 2.

  You’re going to be entering the realm of pure digital electronics, using “logic gates” that are fundamental in every electronic computing device. When you deal with them individually, they’re extremely easy to understand. When you start chaining them together, they can seem intimidatingly complex. So let’s start with them one at a time.

  Logic gates are much fussier than the 555 timer or the 4026 counter that you used previously. They demand an absolutely precise 5 volts DC, with no fluctuations or “spikes” in the flow of current. Fortunately, this is easy to achieve: just set up your breadboard with an LM7805 voltage regulator, as shown in the schematic in Figure 4-44 and the photograph in Figure 4-45. The regulator receives 9 volts from your usual voltage supply, and reduces it to 5 volts, with the help of a couple of capacitors. You apply the 9 volts to the regulator, and distribute the 5 volts down the sides of your breadboard instead of the unregulated voltage that you used previously. Use your meter to verify the voltage, and make sure you have the polarity clearly marked.

  Figure 4-44. This simple circuit is essential to provide a regulated 5V DC supply for logic chips.

  Figure 4-45. The voltage regulator and its two capacitors can fit snugly at the top of a breadboard. Remember to apply the 9V input voltage at the left pin of the regulator, and distribute the 5V output down the sides of the breadboard.

  After installing your regulator, take a couple of tactile switches, two 10K resistors, a low-current LED, and a 1K resistor, and set them around a 74HC00 logic chip as shown in Figure 4-46. You may notice that many of the pins of the chip are shorted together and connected to the negative side of the power supply. I’ll explain that in a moment.

  Figure 4-46. By observing the LED when you press either, both, or neither of the buttons, you can easily figure out the logical function of the NAND gate.

  Fundamentals

  Voltage regulators

  The simplest versions of these little semiconductors accept a higher DC voltage on one pin and deliver a lower DC voltage on another pin, with a third pin (usually in the middle) serving as a common negative, or ground. You should also attach a couple of capacitors to smooth the current, as shown in Figure 4-46.

  Typically you can put a 7.5-volt or 9-volt supply on the “input” side of a 5-volt regulator, and draw a precise 5 volts from the “output” side. If you’re wondering where the extra voltage goes, the answer is, the regulator turns the electricity into heat. For this reason, small regulators (such as the one in Figure 4-8) often have a metal back with a hole in the top. Its purpose is to radiate heat, which it will do more effectively if you bolt it to a piece of aluminum, since aluminum conducts heat very effectively. The aluminum is known as a heat sink, and you can buy fancy ones that have multiple cooling fins.

  For our purposes, we won’t be drawing enough current to require a heat sink.

  When you connect power, the LED should light up. Press one of the tactile switches, and the LED remains illuminated. Press the other tactile switch, and again the LED stays on. Now press both switches, and the light should go out.

  Pins 1 and 2 are logic inputs for the 74HC00 chip. Initially they were held at negative voltage, being connected to the negative side of the power supply through 10K resistors. But each pushbutton overrides its pull-down resistor and forces the input pin to go positive.

  The logic output from the chip, as you saw, is normally positive—but not if the first input and the second input are positive. Because the chip does a “Not AND” operation, it’s known as a NAND logic gate. You can see the breadboard layout in Figure 4-47. Figure 4-48 is a simplified version of the circuit. The U-shaped thing with a circle at the bottom is the logic symbol for a NAND gate. No power supply is shown for it, but in fact all logic chips require a power supply, which enables them to put out more current than they take in. Anytime you see a symbol for a logic chip, try to remember that it has to have power to function.

  Figure 4-47. This bread
board layout is exactly equivalent to the schematic in Figure 4-46.

  Figure 4-48. The structure and function of the NAND gate is easier to visualize with this simplified schematic that omits the power supply for the chip and doesn’t attempt to place the wires to fit a breadboard layout.

  The 74HC00 actually contains four NAND gates, each with two logical inputs and one output. They are arrayed as shown in Figure 4-49. Because only one gate was needed for the simple test, the input pins of the unused gates were shorted to the negative side of the power supply.

  Pin 14 supplies positive power for the chip; pin 7 is its ground pin. Almost all the 7400 family of logic chips use the same pins for positive and negative power, so you can swap them easily.

  In fact, let’s do that right now. First, disconnect the power. Carefully pull out the 74HC00 and put it away with its legs embedded in conductive foam. Substitute a 74HC08 chip, which is an AND chip. Make sure you have it the right way up, with its notch at the top. Reconnect the power and use the pushbuttons as you did before. This time, you should find that the LED comes on if the first input AND the second input are both positive, but it remains dark otherwise. Thus, the AND chip functions exactly opposite to the NAND chip. Its pinouts are shown in Figure 4-50.

  You may be wondering why these things are useful. Soon you’ll see that we can put logic gates together to do things such as create an electronic combination lock, or a pair of electronic dice, or a computerized version of a TV quiz show where users compete to answer a question. And if you were really insanely ambitious, you could build an entire computer out of logic gates.

  Figure 4-49. The pinouts of the logic gates in a 74HC00chip.

 

‹ Prev