Showing posts with label 74HC00. Show all posts
Showing posts with label 74HC00. Show all posts

Saturday, March 21, 2015

@MAKE Electronics Experiment 22: DeBouncing and Flip-Flop

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.

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.





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:
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.

Saturday, January 31, 2015

@MAKE Electronics Experiment 19 - logic chips (Part III)-Latching with a NOR

At the end of the chapter, Charles shows how to latch an AND gate to HIGH by putting a diode between the output and input 2, which goes to a 10K resistor and GND, as well as to a switch. Input 1 goes to power. So, at power up, on input 1 is H and input 2 is L, AND ing to L, so the LED does not light.  When the switch in pushed, input 2 goes H, ANDing to H, and the LED lights.  By feeding the output to input 2, when it goes H, the circuit stays H.

As I mentioned, I do not have my 74HC08 AND chips yet. I got a shipment from China today, but it was my 555s, not my 74HC08s.  I wracked my brains trying to figure out how to replicate this latching with the chips I have.  I found a useful example here That got me thinking.  However, I think I really need a gate that is H when both inputs are H. The only other one that might work is XNOR, but I don't have that either. I may be wrong--but I can't figure that out.

Then I figured that what I really need is a latch, and should focus on that.  A google for "latch a logic ic to low" yielded this.  I followed the directions for an "Active-high circuit: Both inputs are normally tied to ground (LOW), and the latch is triggered by a momentary HIGH signal on either of the inputs" (same web site).  That's what I have on the NOR Gate.  Both inputs are L, and are taken H the corresponding button is pushed.  

So, I used the gate on the opposite side of the chip. I added 10K resistors to GND on the inputs. Input 1 was tied to the output of the other gate.  Input 2 was tied to switch 2, so it goes H when the switch is pushed.  The output goes to Input 2 of the other gate.  Input 1 of that gate is still connected to the switch, and output to the NAND gate as before, in addition to input 1 of the other gate.

As before, on power up the both inputs to NOR gate 1 are L, so it's output is H, causing the NAND gate to output L in response to it's 2 H inputs, and the LED is dark.  Also as before, when we press switch 1 the output of NOR gate 1 NORs to L and the NAND gate goes H and the LED lights. HOWEVER, when we let go of the button, the LED stays lit because the output also goes to the other NOR gate which now goes H and feeds that back to input 1 of the other gate. The light stays on until it's reset, which happens when the other button is pressed, causing input 2 of gate 2 to go H and the output to go L, causing input 2 of gate 1 to go low, causing the output of gate 1 to go H as at power on.

Not as complicated as it sounds. See the reference for diagrams and further explanation.

Here's the video.


Friday, January 30, 2015

@MAKE Electronics Experiment 19 - logic chips (Part II)

I still do not have the 74HC08 AND chips, so I moved ahead and used what I have.  I took out the 00 and replaced it with a 74HC02 NOR chip. NOR is not or. OR logic yields a HIGH result (or TRUE, or ON, or 1) when either input is HIGH, and LOW if both are LOW (or FALSE, or LOW, or 0). NOR is the opposite--only HIGH if both inputs are LOW.

I was reminded that NOR chips are the only ones with different pinouts, so I had to do some minor rewiring, but that's OK.  Once I got the chip in, I pushed the buttons like yesterday.  On power up the LED is on, just like yesterday. However, if either or both buttons are pushed, it turns off.

Next I wired up the NAND chip again, moving the LED and 1K resistor down to its output, connecting one input to power (so it's always HIGH), and the other input to the output of the NOR chip. Now the light will turn off if the output of the NOR is HIGH.  We know how to do that: as in the previous paragraph, if neither button is pushed, it sends a HIGH signal to the NAND chip, making both inputs HIGH and turning off the LED.  If I push either button, the signal is LOW, and NAND turns on the LED.  Very cool.

Here's the video.

Thursday, January 29, 2015

@MAKE Electronics Experiment 19 - logic chips (Part I)

There is not much to Experiment 19, but it's still really neat.

This is the first use of logic chips, and Charles is just introducing the concept. In this experiment, we use a 74HC00 quad 2-input NAND chip and a 74HC08 quad 2-input AND chip.  My 08s have not arrived from China yet, so Part I deals with the 00.

Logic chips use Boolean logic, taking False as 0 and True as 1.  Since there are two inputs, the Boolean operation yield an off or on (logic LOW or logic HIGH) condition.

The 00 applies a NAND, or negative and, operation on the two inputs.  This means that it's the opposite of an AND operation, in which both inputs must be true (or on or HIGH) to yield a true (or on or HIGH) output.  The negative of that means that NAND yields a true (or on or HIGH) result unless bioth inputs are true (or on or HIGH).

Here's a truth table (T=true or on or HIGH, F=false or off or LOW):

input1     input2   AND  NAND
  F             F            F          T
  F             T            F          T
  T             F            F          T
  T             T            T          F

In the experiment, we first have to supply 5V, regulated, to the chip.  We take the 9V input (in my case from a Compact Switching Power Supply - Selectable Output 3-12VDC from Adafruit), through a 7805 voltage regulator and 2 capacitors to smooth it out. The output of the 7805 (4.95V by my meter) supplied the chip. Charles calls for a 33uF capacitor, but I only have 22s and 47s, so I used a 47.

The circuit only used one of the 4 gates. 74HC00 is a 14-pin chip.  Pins 1, 4, 9, and 12 are input1. Pints 2, 5, 10, and 13 are input2.  3, 6, 8, and 11 are the outputs from the corresponding inputs. 14 is power and 7 is GND. Gate 1 is pins 1 and 2 with output on pin 3.  All other input pins are tied to GND (LOW), and the other 3 outputs are floating.

The inputs 1 and 2 (pins 1 and 2) are connected to power through a normally open momentary switch., with 10K pull-down resistors connected to GND. Output (pin 3) is connected to a low-current LED, which is connected to a 1K resistor to GND. Each input is LOW unless the button it is connected to is pushed, closing the connection to power and taking it HIGH.

Here's the schematic and breadboard layout:

Figure 4-46
Figure 4-47




















Both figures are from Charles Platt, Make: Electronics, First Edition, Maker Media, Inc., 2009, p. 182.

Both inputs are LOW on power up. Pressing a button takes its input HIGH. Referring to the truth table above, we expect the LED will light unless both inputs are HIGH. This is in fact what happens: when the power is connected, the LED is on and stays on unless both buttons are pushed. See the video here.