Showing posts with label NOR. Show all posts
Showing posts with label NOR. 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.

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.