This experiment is deceptively straightforward. The only issue I had was a bad chip.
First, I mentioned in the last experiment that the slide switch was not breadboard friendly. The pins are not long enough and with only one row of pins it's not stable. I tried taking it apart with the intention of making a breakout board, but that proved to be harder than it should be (I should have left it together). So, I went to Radio Shack and found this. The advantage is that it's a DPDT and has 2 rows of pins, making it more stable.
So with a better switch, I tackled the experiment. Both circuits do the same thing. Debouncing means ignoring errant button pushes. Since latching logic gates set in the first impulse, anything further is ignored. We latch by feeding the outputs of each gate to one of the inputs to the other. The second input is connected to a pull-down (NOR) or pull-up (NAND) resistor and to one side of the switch. The pole of the switch (we only use one) is connected to Vcc (NOR) or GND (NAND).
Each output also powers a low current LED when it's HIGH.
NOR output is LOW unless both inputs are LOW. When the switch is towards a gate's input, that input goes H, making the output L. That gate's LED is off, and one input to the second gate is L. Since the switch is away from the second gate, that input is also L, making the output H, turning on the LED and making one input back to the other gate H, keeping it's output L and it's LED off. Switch to the other gate and one input goes H, making output L and both inputs to the other gate L and it's output H and LED on. It can only be in one state or the other. Debounced.
NAND works similarly. NAND output is H unless both inputs are H. The switch is connected to GND and each gate has 1 input connected to a side of the switch and a pull-up resistor. So, one input is H unless the switch is closed to that side, in which case it's output goes H,turning on the LED and feeding H to one input of the other gate. Since the switch is open to that side, it's pull-up resistor makes the other input H, making the output L, turning off it's LED and feeding L back to the non-switch input of the other gate, keeping it's output H until the switch is moved (or power to the circuit is cut).
Fun and interesting. Here's the video.
Showing posts with label latching. Show all posts
Showing posts with label latching. Show all posts
Saturday, March 21, 2015
Sunday, March 15, 2015
@MAKE Electronics Experiment 20: Keypad Security System Epilogue Part II: Making it Work
Getting past the fact that the 555 won't supply enough voltage, ever, the next question is how can we amplify it. The answer is with a transistor. It took me way longer than it should have to get it to work, because of wiring problems and cooked transistors.
First the wiring: instead of taking 555 Output Pin 3 to the + side of the relay coil, I connected it to the base pin of a 2N2222A transistor (NPN BJT). I then connected + side the relay coil to the 5V rail, and the - side of the coil to the collector pin of the transistor. The emitter pin goes to GND. Initially, I left the LED in the circuit, but since that's connected to GND, the circuit was always completed. I'm sure there's a place I can put it, but it works without it.
After few wrong connections, I still could not get it to work. I was absolutely sure that it was wired correctly. During this process I must have cooked a transistor or two, In desperation, I replaced the transistor again, and it worked.
So, that's the answer: insert a transistor, properly wired, and the voltage that was too low to trip the relay is enough to activate the transistor, allowing 5V to flow from the 5V rail through the relay to the collector, and when the 555 is triggered, the output pin will supply enough voltage to the base pin of the transistor to allow current to flow through to the emitter, completing the circuit.
Here's the video
I'm glad I got this to work. I hate to leave something incomplete..
First the wiring: instead of taking 555 Output Pin 3 to the + side of the relay coil, I connected it to the base pin of a 2N2222A transistor (NPN BJT). I then connected + side the relay coil to the 5V rail, and the - side of the coil to the collector pin of the transistor. The emitter pin goes to GND. Initially, I left the LED in the circuit, but since that's connected to GND, the circuit was always completed. I'm sure there's a place I can put it, but it works without it.
After few wrong connections, I still could not get it to work. I was absolutely sure that it was wired correctly. During this process I must have cooked a transistor or two, In desperation, I replaced the transistor again, and it worked.
So, that's the answer: insert a transistor, properly wired, and the voltage that was too low to trip the relay is enough to activate the transistor, allowing 5V to flow from the 5V rail through the relay to the collector, and when the 555 is triggered, the output pin will supply enough voltage to the base pin of the transistor to allow current to flow through to the emitter, completing the circuit.
Here's the video
I'm glad I got this to work. I hate to leave something incomplete..
Labels:
+charlesplatt,
555,
74HC04,
74HC08,
AND,
diy,
electronics,
Inverter,
latching,
logic chip,
MAKE
Friday, March 13, 2015
@MAKE Electronics Experiment 20: Keypad Security System (Part III--still not working)
This has taken a while. Snow, family visiting, setting up my new generator, an fuel oil spill in my basement, and other events have dominated my attention.
When last we left this, I was convinced that the keypad was sucking current from the circuit. I used this one. The only videos I've seen of people getting this to work use momentary buttons instead of the keypad, I tried to substitute buttons--that didn't help. Testing various locations with my meter, I see that's not the problem
I checked the voltage coming into the first part of the circuit, and then then through the operation. I put a meter set to continuity connected to the relay. If the upper coil on the relay gets 5V, there should be continuity, and 5V to the lower coil should reset it. As you can see in the video, holding the '*' key and entering the code causes the indicator light to turn on for ~1s as designed, but the relay does not flop. The voltage meter shows <4V coming out of the 555--not enough for the relay. If I hit the relay with a jumper wire connected to the 5V rail, the relay flops and there is continuity until I press the '#' key or hit the lower coil with 5V,
Testing various locations with my meter, I see that's not the problem. Here's the video.
The 555 has 4.86V going in on pin 8 and only ~3.7 going out on pin 3. That's the problem, and I don't know what to do about it. I fussed with capacitor and resistor values with no change. For the video, I wound up with ad 1000uf capacitor and a 10K resistor, so pin 3 would have output for longer and I could see it on the meter. I tried various combinations of 2.2, 10, 100, and 1000uf capacitors and 1K, 10K, and 100K resistors--the output stayed under 4V.
Researching, I found this web page, which says that the output on pin 3 will be ~1.7V less than the input on pin 8. Charles' Encyclopedia of Electronic Components Volume 2 says the same thing. I'm going to move on.
When last we left this, I was convinced that the keypad was sucking current from the circuit. I used this one. The only videos I've seen of people getting this to work use momentary buttons instead of the keypad, I tried to substitute buttons--that didn't help. Testing various locations with my meter, I see that's not the problem
I checked the voltage coming into the first part of the circuit, and then then through the operation. I put a meter set to continuity connected to the relay. If the upper coil on the relay gets 5V, there should be continuity, and 5V to the lower coil should reset it. As you can see in the video, holding the '*' key and entering the code causes the indicator light to turn on for ~1s as designed, but the relay does not flop. The voltage meter shows <4V coming out of the 555--not enough for the relay. If I hit the relay with a jumper wire connected to the 5V rail, the relay flops and there is continuity until I press the '#' key or hit the lower coil with 5V,
Testing various locations with my meter, I see that's not the problem. Here's the video.
The 555 has 4.86V going in on pin 8 and only ~3.7 going out on pin 3. That's the problem, and I don't know what to do about it. I fussed with capacitor and resistor values with no change. For the video, I wound up with ad 1000uf capacitor and a 10K resistor, so pin 3 would have output for longer and I could see it on the meter. I tried various combinations of 2.2, 10, 100, and 1000uf capacitors and 1K, 10K, and 100K resistors--the output stayed under 4V.
Researching, I found this web page, which says that the output on pin 3 will be ~1.7V less than the input on pin 8. Charles' Encyclopedia of Electronic Components Volume 2 says the same thing. I'm going to move on.
Labels:
555,
74HC04,
74HC08,
AND,
electronics,
Inverter,
latching,
logic chip,
MAKE
Friday, February 6, 2015
@MAKE Electronics Experiment 19 - logic chips (Part V)-Finally got my AND chips--more latching
My first post on this experiment said that there isn't much too it. I was wrong. Because, to paraphrase Donald Rumsfield, I had to experiment with the ICs I had not the ICs I wanted, I wound up learning a whole lot. Of course, that is Charles' intent and this book is great. My 74HC08 AND chips arrived, so in this post I will recap what the chapter showed and add a little more about latching,
There is a lot more detail in the chapter on various logic chips and their associated truth tables, and that's very useful.
First step was to do some schematics. I did one for the last exercise in the chapter--latching with an single AND:
The right side is the power supply, as described in Part I (Vcc is regulated 5V). The left side is a self-latching AND gate:
I never would have thought to try any of this if my eBay supplier had delivered the AND chips sooner. I am a lucky man.
See the video.
There is a lot more detail in the chapter on various logic chips and their associated truth tables, and that's very useful.
First step was to do some schematics. I did one for the last exercise in the chapter--latching with an single AND:
![]() |
My Eagle Cad Rendition of Charles Figure 4-79, p. 196 |
The right side is the power supply, as described in Part I (Vcc is regulated 5V). The left side is a self-latching AND gate:
- Input 1 is connected to Vcc, so it is always H
- Input 2 is connected to S1. When we press S1, Pin 2 is H. H/H ANDs to H, so the LED lights.
- Without the other connections, the LED would only stay lit as long as the button is pushed. When we let go the pin goes back to L, L/H ANDs to L, and the LED turns off.
- By connecting the output on pin 3 back to the input on pin 2, we keep pin 2 H. The diode blocks any current from S1 from going to the output.
Once we push the button the light stays on, forever--or at least until we disconnect the power. We might want to include another button to turn it off. We could do that by putting a toggle, or perhaps a normally closed pusbutton between Vcc and pin 1. That way, when the toggle is off or the button is pushed, pin 1 would go L, making the output L, and the latch would keep it there (or that's my theory). The toggle is not a great option, because when it's open essentially pin 1 would be floating. Charles says that's not a good idea. I've seen examples where pins are left floating, but I trust Charles. It's kind of like coding an IF construct in any programming language: if you don't deal with all options you may get intermittent strange results. I cover a couple of options to accomplish this in the accompanying video.
Given what I just learned about latching, how about if we add a NAND gate and make one of it's inputs the output on pin3? If we connect the other NAND input to S2, than that input would be L unless the button id pushed. Since only H/H NANDs to L, the NAND output would be H until both the LED is lit (AND output on pin 3 H) and the S2 is pushed. So, we could make the output of the NAND gate input 1 to the AND gate.
- The AND part of the circuit works as before. The only difference is that pin 1 is connected to NAND output instead of to Vcc. Pin 1 is H unless we make it L.
- NAND output is H on power up (S2 open), so AND pin 1 is H.
- We push S1, pin 2 goes H, the output is H, the LED lights and stays lit.
- When we push S2, NAND input 2 is H, making NAND output L (H/H-->L), making AND pin 1 L, making AND output L, turning LED1 off and keeping it that way, but LED2 stays off only momentarily.
I never would have thought to try any of this if my eBay supplier had delivered the AND chips sooner. I am a lucky man.
See the video.
Labels:
74HC00,
74HC08,
AND,
electronics,
latching,
logic chip,
MAKE,
NAND
Sunday, February 1, 2015
@MAKE Electronics Experiment 19 - logic chips (Part IV)-Latching with a NAND
Moving on with logic chips, I figured out that I could also latch my gates with the NAND chip, using the "Active-low circuit: Both inputs are normally HIGH, and the latch is triggered by a momentary LOW signal on either input" (same Electronics for Dummies reference as yesterday).
Since I wanted to use set and reset buttons, I needed to provide normally high inputs to the latching circuit. I did that with the other two gates on the 74HC00 chip. Since NAND output is L only when both inputs are H, I was able to provide one H input from each Gates C & D by connecting one input to Vcc and the other to a momentary pushbutton. Each pushbuton is connected to Vcc on one side and the input to C or D as well as a 10K resistor and GND on the other side.Therefore, the outputs of C & D are H unless the corresponding button is pushed, in which case that input is H, paired with other H input, so the output is L.
On the other side of the chip, I moved the LED circuit to gate B. The output of gate B goes to the LED and on to a 1K resistor and GND. That output also goes to input 1 of gate A. Input 1 of gate B is output of C and input B2 is the output of A. Input A1 is the output of B as just described and input A2 is the output of Gate D. Here's the schematic:
On power up, this LED is lit, I did not expect that, but here's what I think is happening:
And so on. Here's the video.
Since I wanted to use set and reset buttons, I needed to provide normally high inputs to the latching circuit. I did that with the other two gates on the 74HC00 chip. Since NAND output is L only when both inputs are H, I was able to provide one H input from each Gates C & D by connecting one input to Vcc and the other to a momentary pushbutton. Each pushbuton is connected to Vcc on one side and the input to C or D as well as a 10K resistor and GND on the other side.Therefore, the outputs of C & D are H unless the corresponding button is pushed, in which case that input is H, paired with other H input, so the output is L.
On the other side of the chip, I moved the LED circuit to gate B. The output of gate B goes to the LED and on to a 1K resistor and GND. That output also goes to input 1 of gate A. Input 1 of gate B is output of C and input B2 is the output of A. Input A1 is the output of B as just described and input A2 is the output of Gate D. Here's the schematic:
![]() |
Make:Electronics Experiment 19 Part IV - Latching with NAND |
On power up, this LED is lit, I did not expect that, but here's what I think is happening:
- Pin 8 is H (see above), so Pin 4 is H. There is not enough current in the circuit to make pin 5 H, so pint 6 NANDs to H, lighting the LED and making pin 2 H, Pins 2 and 3 (H for the same reason as pin 4), NAND to L, so pin 5 is L and the LED stays lit.
- Press S2 and pins 11 and 1 go L. Pin 2 is still H, so 1&2 NAND to H, making 5 H, which NANDs with pin 4 (H), to make pin 6 L, turning the LED off and latching pin 2 to L to keep it off.
- Press S1, Pins 8&4 go L, and since 5 is H they NAND to H on pin 6, turning the LED on and latching pin 2 to H to keep it on.
And so on. Here's the video.
Labels:
74HC00,
electronics,
latching,
logic chip,
MAKE,
NAND
Subscribe to:
Posts (Atom)