Showing posts with label logic chip. Show all posts
Showing posts with label logic chip. Show all posts

Monday, March 30, 2015

@MAKE Electronics Experiment 23: Nice Dice

This is an interesting and challenging experiment. Challenging because I sometimes have problems getting from schematics to breadboards, and I always have in the back of my mind that I may have cooked a chip.  No cooking this time, just stupid wiring tricks.  But, I got it to work.

We started with a 555 timer to send pulses to the a 74LS92 counter chip and 3 LEDs to count from 0-5 in binary, Note that the LSs are TTL chips as opposed to the HC CMOS chips we've been using.

Since the idea is to emulate dice, we need 7 LEDs, one for each dot on a die. We did that by adding a 74LS27 quad-gate triple input NOR chip, along with 4 diodes too protect inputs from flowing back into outputs.  In this version we had low-current LEDs tied to GND through 4.7KOhm resistors. This LEDs were not too bright (like me). By connecting the middle dot, to one output. each of the to diagonal pairs to 2 more outputs, and the two middle side LEDs to another, we were able to produce 7 combinations from the 4 outputs by connecting thim. The middle lights on 1, 3, and 5.  The middle sides light on 6 only.  One diagonal lights on 2, 3. 4, 5, and 6, and the other lights on 4, 5, and 6.

Next step was to add an inverter.  In the previous set up, the NOR chip needed to power the LEDs, What we want is for it to sink power, but to do that we needed to reverse the logic.  We used normal LEDs connected to power through 100Ohm resistors, and connected the inverter outputs to the negative side if the LEDs.  This was much better, because the LEDs are much brighter. 

Making the right connections from the NOR to the inverter to the LEDs turned out to be a challenge, but I stuck with it.

Finally, I replaced the 10uf capacitor between pins 7 and 8 of the timer with a .01uf, making the lights flash 1000 times faster and the change not visible (to me, at least).

So, you hold down the pushbutton and all LEDs appear to be lit. Release the button, and you have a roll of the die. Nice dice


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.

Tuesday, March 17, 2015

@MAKE Electronics Experiment 21: Game Show Button Controller

After the last experiment this one is pretty straightforward. One 74HC32 quad OR chip, 2 timers, one SPDT switch, 2 tactile buttons, 2 LEDs, 3 10K resistors, 2 330 Ohm resistors. The wiring's the thing.

I couldn't get it to work at first, but it was just a loose connection. That, and my "breadboard-friendly" SPDT slide switch wasn't so breadboard friendly. I had to bend up the tabs on the side to get it to fit the breadboard at all, and the legs still weren't long enough. But it works.

Anyway, the switch is for Art Fleming to activate and deactivate the contestants buttons.  The buttons are tied to Vcc through a pull-up resistor. A jumper from one side of the switch to the side of button 1 1 not connected to Vcc and then a second jumper from there to the corresponding button on button 2. The other side of B1 goes to OR Gate1, input 1. The same for B2, the corresponding side goes to OR Gate 2, input1.  Both input2s are connected to Gate3 output. Gate3 inputs are connected to the output pins of the 555s.

So, in order for the output of either 555 to go H, the input on trigger pin 2 must be L. The trigger pins are tied to the outputs of OR Gates 1 and 2.  OR output is H if either input is H.  One input is tied to 555 output, which is L until triggered by it's corresponding OR Gate. Button outputs are H if no action is taken, so the 555s are not triggered. When a button is pushed, the voltage from the button goes negative, making both inputs L, and the corresponding output L, thus triggering the corresponding 555 output. Both 555 outputs are connected to LEDs, so the LED lights and stays on until reset.  Once one 555 output is H, Gate 3 output is H, and neither button has any effect because the corresponding outputs will be H.

When Art Fleming activates the contestants buttons and asks a question, the first contestant to press the button lights his/her LED and locks the other contestant out.  The other side of the slide switch is connected to the 555 reset pins (4), so when Art slides back the LED turns off.  When he's ready for the next question, he flips the switch back and the cycle repeats.

Here's the video.

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

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.


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.