Make: Electronics

Home > Other > Make: Electronics > Page 28
Make: Electronics Page 28

by Charles Platt


  Note that the “wrong” numbers on the keypad are all shorted together. This will create some inconvenience if you want to change the combination in the future. I’ll suggest a different option in the “enhancements” section that follows. For now, ideally, you should run a wire from every contact on your keypad, down to your circuit on its breadboard, and short the “wrong” keypad numbers together with jumper wires on the breadboard.

  Also note that if you use a meter to test the inputs to the AND gates, and you touch your finger against the meter probe while doing so, this can be sufficient to trigger the sensitive CMOS inputs and give a false positive.

  Figure 4-84. The combination lock schematic redrawn to show how the components can be laid out on a breadboard.

  One Little Detail: The Computer Interface

  Old computers used to have a big switch at the back, attached to the heavy metal box inside the computer, that transformed house current to regulated voltages that the computer needs. Most modern computers are not designed this way; you leave the computer plugged in, and you touch a little button on the box (if it’s a Windows machine) or the keyboard (if it’s a Mac), which sends a low-voltage pulse to the motherboard.

  This is ideal from our point of view, because we don’t have to mess with high voltages. Don’t even think of opening that metal box with the fan mounted in it, containing the computer power supply. Just look for the wire (usually containing two conductors, on a Windows machine) that runs from the “power up” button to the motherboard.

  To check that you found the right one, make sure that your computer is unplugged, ground yourself (because computers contain CMOS chips that are sensitive to static electricity) and very carefully snip just one of the two conductors in the wire. Now plug in your computer and try to use the “power up” button. If nothing happens, you’ve probably cut the right wire. Even if you cut the wrong wire, it still prevented your computer from booting, which is what you want, so you can use it anyway. Remember, we are not going to introduce any voltage to this wire. We’re just going to use the relay as a switch to reconnect the conductor that you cut. You should have no problem if you maintain a cool and calm demeanor, and look for that single wire that starts everything. Check online for the maintenance manual for your computer if you’re really concerned about making an error.

  After you find the wire and cut just one of its conductors, unplug your computer again, and keep it unplugged during the next steps.

  Find where the wire attaches to the motherboard. Usually there’s a small unpluggable connector. First, mark it so that you know how to plug it back in the right way around, and then disconnect it while you follow the next couple of steps.

  Strip insulation from the two ends of the wire that you cut, and solder an additional piece of two-conductor wire, as shown in Figure 4-85, with heat-shrink tube to protect the solder joints. (This is very important!)

  Run your new piece of wire to the latching relay, making sure you attach it to the pair of contacts which close, inside the relay, when it is energized by the unlocking operation. You don’t want to make the mistake of unlocking your computer when you think you’re locking it, and vice versa.

  Reconnect the connector that you disconnected from your motherboard, plug in your computer, and try to power it up. If nothing happens, this is probably good! Now enter the secret combination on your keypad (while holding down the asterisk button to provide battery power) and listen for the click as the relay latches. Now try the “power up” button again, and everything should work.

  Figure 4-85. The combination lock project can be interfaced with a typical desktop computer by cutting one conductor in the wire from the “power up” pushbutton, soldering an extension, and covering the joints with heat-shrink tube.

  Enhancements

  At the end of any project, there’s always more you can do.

  To make this setup more secure, you could remove the usual screws that secure the case of the computer, and replace them with tamper-proof screws. Check any online source for “tamper-proof screws,” such as http://www.mcmaster.com. Naturally, you will also need the special tool that fits the screws, so that you can install them (or remove them, if your security system malfunctions for any reason).

  Another enhancement could be an additional 555 timer that is activated by the asterisk button, and delivers power to the other chips for, say, a limited period of 30 seconds, allowing you that much time to unlock the system. This would eliminate the need to hold down the asterisk button while you enter the unlocking code. A 555 timer can supply power to all the other chips, because they don’t use very much. I omitted this feature for the sake of simplicity.

  Yet another enhancement, if you are security-crazed, is to go for a four-button code. After all, the 74HC08 chip still has one unused AND gate. You could insert that into the chain of the existing AND gates and wire it to another keypad button of your choice.

  Still another enhancement would be a way to change the code without unsoldering and resoldering wires. You can use the miniature sockets that I suggested in the heartbeat flasher project. These should enable you to swap around the ends of your wires from the keypad.

  And for those who are absolutely, positively, totally paranoid, you could fix things so that entering a wrong code flips a second high-amperage relay which supplies a massive power overload, melting your CPU and sending a big pulse through a magnetic coil clamped to your hard drive, instantly turning the data to garbage (Figure 4-86). Really, if you want to protect information, messing up the hardware has major advantages compared with trying to erase data using software. It’s faster, difficult to stop, and tends to be permanent. So, when the Record Industry Association of America comes to your home and asks to switch on your computer so that they can search for illegal file sharing, just accidentally give them an incorrect unlocking code, sit back, and wait for the pungent smell of melting insulation.

  If you pursue this option, I definitely take no responsibility for the consequences.

  Figure 4-86. For those who are absolutely, positively, totally paranoid: a meltdown/self-destruct system controlled by a secret key combination provides enhanced protection against data theft or intrusions by RIAA investigators asking annoying questions about file sharing.

  On a more realistic level, no system is totally secure. The value of a hardware locking device is that if someone does defeat it (for instance, by figuring out how to unscrew your tamper-proof screws, or simply ripping your keypad out of the computer case with metal shears), at least you’ll know that something happened—especially if you put little dabs of paint over the screws to reveal whether they’ve been messed with. By comparison, if you use password-protection software and someone defeats it, you may never know that your system has been compromised.

  Experiment 21: Race to Place

  The next project is going to get us deeper into the concept of feedback, where the output is piped back to affect the input—in this case, blocking it. It’s a small project, but quite subtle, and the concepts will be useful to you in the future.

  You will need:

  74HC32 chip containing four OR gates. Quantity: 1.

  555 timers. Quantity: 2.

  SPDT switch. Quantity: 1.

  SPST tactile switches. Quantity: 2.

  Various resistors.

  5V supply using power regulator as before.

  The Goal

  On quiz shows such as Jeopardy, contestants race to answer each question. The first person who hits his answer button automatically locks out the other contestants, so that their buttons become inactive. How can we make a circuit that will do the same thing?

  If you search online, you’ll find several hobby sites where other people have suggested circuits to work this way, but they lack some features that I think are necessary. The approach I’m going to use here is both
simpler and more elaborate. It’s simpler because it has a very low chip count, but it’s more elaborate in that it incorporates “quizmaster control” to make a more realistic game.

  I’ll suggest some initial ideas for a two-player version. After I develop that idea, I’ll show how it could be expanded to four or even more players.

  A Conceptual Experiment

  I want to show how this kind of project grows from an idea to the finished version. By going through the steps of developing a circuit, I’m hoping I may inspire you to develop ideas of your own in the future, which is much more valuable than just replicating someone else’s work. So join me in a conceptual experiment, thinking our way from a problem to a solution.

  First consider the basic concept: two people have two buttons, and whoever goes first locks out the other person. I always find it helps me to visualize this kind of thing if I draw a sketch, so that’s where I’ll begin. In Figure 4-87, the signal from each button passes through a component that I’ll call a “button blocker,” activated by the other person’s button. I’m not exactly sure what the button blocker will be or how it will work, yet.

  Figure 4-87. The basic concept of the quiz project is that the output from one button should feed back to intercept the output of another button. At this point, the way in which the “button blocker” circuit works has not been figured out.

  Now that I’m looking at it, I see a problem here. If I want to expand this to three players, it will get complicated, because each player must activate the “button blockers” of two opponents. Figure 4-88 shows this. And if I have four players, it’s going to get even more complicated.

  Anytime I see this kind of complexity, I think there has to be a better way.

  Also, there’s another problem. After a player lets his finger off the button, the other players’ buttons will be unblocked again. I need a latch to hold the signal from the first player’s button and continue to block the other players.

  Figure 4-88. The quiz concept becomes more complicated when an additional pushbutton is added. Now each button must block two other buttons. If a fourth button is added, the circuit will become unmanageably complex. There has to be a better way.

  This now sounds even more complicated. But wait a minute, if I have a latch which allows the winning player to take his finger off his button, I don’t care if any of the buttons are being pressed anymore—including the button of the winning player. As soon as his signal is latched, all the buttons can be blocked. This makes things much simpler. I can summarize it as a sequence of events:

  1. First player presses his button.

  2. The signal is latched.

  3. The latched signal feeds back and blocks all the buttons.

  The new sketch in Figure 4-89 shows this. Now the configuration is modular, and can be expanded to almost any number of players, just by adding more modules.

  There’s something important missing, though: a reset switch, to put the system back to its starting mode after the players have had time to press their buttons and see who won. Also, I need a way to prevent players from pressing their buttons too soon, before the quizmaster has finished asking the question. Maybe I can combine this function in just one switch, which will be under the quizmaster’s control. In its Reset position, the switch can reset the system and remove power to the buttons. In its Play position, the switch stops holding the system in reset mode, and provides power to the buttons. Figure 4-90 shows this. I’ve gone back to showing just two players, to minimize the clutter of lines and boxes, but the concept is still easily expandable.

  Figure 4-89. If a latch is added below each button, it can retain one input and then block all inputs from all buttons. This simplifies the concept.

  Figure 4-90. A quizmaster switch will be needed to activate the buttons initially and then reset the circuit after a winning input has been recorded.

  Now I have to deal with a logic problem in the diagram. The way I’ve drawn it, after the output from the lefthand latch goes up to the “button blockers,” it can also run down the wire to the other half of the circuit (against the direction to the arrows), because everything is joined together. In other words, if the lefthand LED lights up, the righthand LED will light up, too. How can I stop this from happening?

  Well, I could put diodes in the “up” wires to block current from running down them. But I have a more elegant idea: I’ll add an OR gate, because the inputs to an OR gate are separated from each other electrically. Figure 4-91 shows this.

  Figure 4-91. To prevent the output from one latch feeding back around the circuit to the output from another latch, the outputs can be combined in an OR gate.

  Usually an OR gate has only two logical inputs. Will this prevent me from adding more players? No, because you can actually buy an OR that has eight inputs. If any one of them is high, the output is high. For fewer than eight players, I can short the unused inputs to ground, and ignore them.

  Looking again at Figure 4-91, I’m getting a clearer idea of what the thing I’ve called a “button blocker” should actually be. I think it should be another logic gate. It should say, “If there’s only one input, from a button, I’ll let it through. But if there is a second input from the OR gate, I won’t let it through.”

  That sounds like a NAND gate, but before I start choosing chips, I have to decide what the latch will be. I can buy an off-the-shelf flip-flop, which flips “on” if it gets one signal and “off” if it gets another, but the trouble is, chips containing flip-flops tend to have more features than I need for a simple circuit like this. Therefore I’m going to use 555 timers again, in flip-flop mode. They require very few connections, work very simply, and can deliver a good amount of current. The only problem with them is that they require a negative input at the trigger pin to create a positive output. But I think I can work with that.

  So now, finally, here’s a simplified schematic, in Figure 4-92. I like to show the pins of the 555 timers in their correct positions, so I had to move the components around a little to minimize wire crossovers, but you can see that logically, it’s the same basic idea.

  Figure 4-92. Now that the basic concept of the quiz circuit has been roughed out, specific components can be inserted, with compatible inputs and outputs.

  Before you try to build it, just run through the theory of it, because that’s the final step, to make sure there are no mistakes. The important thing to bear in mind is that because the 555 needs a negative input on its trigger pin to create its output, when any of the players presses a button, the button has to create a negative “flow” through the circuit. This is a bit counterintuitive, so I’m including a three-step visualization in Figure 4-93, showing how it will work.

  In Step 1, the quizmaster has asked a question and flipped his switch to the right, to supply (negative) power to the players’ buttons. So long as no one presses a button, the pull-up resistors supply positive voltage to OR2 and OR3. An OR gate has a positive output if it has any positive input, so OR2 and OR3 keep the trigger inputs of the 555 timers positive. Their outputs remain low, and nothing is happening yet.

  In Step 2, the lefthand player has pressed his button. Now OR2 has two negative inputs, so its output has gone low. But IC1 hasn’t reacted yet.

  In Step 3, just a microsecond later, IC1 has sensed the low voltage on its trigger, so its output from pin 3 has gone high, lighting the LED. Remember, this 555 timer is in flip-flop mode, so it locks itself into this state immediately. Meanwhile its high output also feeds back to OR1. Because OR1 is an OR gate, just one high input is enough to make a high output, so it feeds this back to OR2 and OR3. And now that they have high inputs, their outputs also go high, and will stay high, regardless of any future button-presses.

  Figure 4-93. These three schematics show the prevalence of higher and lower voltages (red and blue lines) through the quiz circuit when a pushbutton is
pressed.

  Because OR2 and OR3 now have high inputs and outputs, IC1 and IC2 cannot be triggered. But IC1 is still locked into its “on” state, keeping the LED illuminated.

  The only way to change IC1 is if the quizmaster flips his switch back to the left. That applies negative power to the reset pins of both the timers. Consequently their outputs go low, the LED goes out, and the circuit goes back into the same state as where it started. Having reset it, the quizmaster can ask another question, but the players’ buttons are not activated until the quizmaster flips the switch back to the right again.

  There’s only one situation that I haven’t addressed: what if both players press their buttons absolutely simultaneously? In the world of digital electronics, this is highly unlikely. Even a difference of a microsecond should be enough time for the circuit to react and block the second button. But if somehow both buttons are pressed at the same instant, both of the timers should react, and both of the LEDs will light up, showing that there has been a tie.

  In case you feel a little uncertain about the way in which a two-player circuit can be upgraded to handle extra players, I’ve included a simplified three-player schematic in Figure 4-94.

  Figure 4-94. The two-player schematic in can be easily upgraded to a three-player version, as shown here, provided the first OR gate can handle three inputs.

  Breadboarding It

  Now it’s time to create a schematic that’s as close to the breadboard layout as possible, so that you can build this thing easily. The schematic is shown in Figure 4-95 and the actual components on a breadboard are in Figure 4-96. Because the only logic gates that I’ve used are OR gates, and there are only three of them, I just need one logic chip: the 74HC32, which contains four 2-input OR gates. (I’ve grounded the inputs to the fourth). The two OR gates on the left side of the chip have the same functions as OR2 and OR3 in my simplified schematic, and the OR gate at the bottom-right side of the chip works as OR1, receiving input from pin 3 of each 555 timer. If you have all the components, you should be able to put this together and test it quite quickly.

 

‹ Prev