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:

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.
Here's the schematic (I omitted the 7805, etc., to reduce clutter):

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.