Transistor NAND Gate does not work correctly

Discussion in 'General Electronics Chat' started by atrumblood, Jun 29, 2012.

  1. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    Transistor NAND Gate does not completely work.?
    I have been trying out some logic gates using transistors and I am confused already. I have built a NAND gate using 3 2n3904 BJT's. The resistor values are aprox the values in the schematic. The Diodes are 1N4003.

    Vcc is 5v (~4.9v)

    The schematic can be found here http://www.instructables.com/id/Digital-Logic-Gates-Just-Using-Transistors/

    I have everything hooked up like the schematic shows. The issue I am having is that it is not working as I would expect a nand gate to work.

    The truth table shows that if A and B are both Low then C is High.
    If A is High and B is Low then C is High.
    If A and B are both High then C is Low

    Here is what really happens.

    A Low: B Low: C High
    A Low: B High : C High
    A High: B Low : C Low (but still ON just very very dim) <=Shouldn't this still be a High state?
    A High: B High: C Low

    Does any one have any ideas as to why it is behaving like this? I have rebuilt this circuit about a dozen times now making sure I have things correct. I am stumped.
     
  2. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    What node is Node C? The diagram doesn't specify an output node.

    The guy is apparently thinking in terms of the output being HI if the LED turns on and it is LO if the LED turns off. Some of his circuits produce an electrical HI on one side of the LED to turn it on and others produce an electrical LO on one side to turn it on.

    So what criteria are you using to say if the output is HI or LO?

    Have you analyzed the expected behavior of the circuit? To get a basic idea, make some simplifying assumptions, such as:

    Vf for the LED is 2V.
    Vd for the diodes and base-emitter junctions is 0.7V
    Vcesat for the transistors is 0.2V
    current gain of the transistors is very large (negligible base current).

    Under those assumptions, with Vcc=5V, the LED current would be:

    Iled = (5V - 0.7V - 2V - 0.7V)/(500Ω+220Ω) = 2.1mA

    Note that with Vcc=9V, this would become = 7.3mA

    With both inputs HI, the current from the battery (assuming the LED is off) would be:

    Ibatt = (5V-0.7V-0.2V-0.2V)/0.77kΩ = 5.5mA

    The key is that the voltage from the top rail to the bottom rail (to the right of the resistors) is only 1.1V, which is insufficient to support the 3.4V needed to turn on the LED.

    At first glance, the tendency is to say that if either A or B is LO, then one of the two NPN transistors in series is turned off and therefore it should be the same as when both are turned off.

    I think I would actually expect there to be a problem when B was HI (and A was LO). If B is HI, then it is trying to pull the emitter of the lower transistor toward 4.3V. Assuming no current in the LED, the base current would be 4.3V/(330Ω+220Ω)=7.8mA. This would place the emitter at 1.7V, leaving 3.3V available for the LED which is close to the 3.4V these simple assumptions say is needed to turn it on. So I would not be surprised at all if it were ON, OFF, or partially on.

    If Vcc were 9V, then the emitter current would be 8.3V/0.55kΩ = 15.1mA placing the emitter voltage at 3.3V making 5.7V available for the LED circuit. Because the LED current flows through the 220Ω resistor, it will raise the emitter voltage and reduce the base current. Taking this into account, I would expect the emitter voltage to settle at about 3.8V which would put about 3.6mA through the LED.

    Also, in general remember that an NPN with the collector and emitter swapped is still an NPN transistor, just a pretty poor one in most cases. The point here being that if the collector is taken below the base by more than a diode drop, that you will get conduction from base-collector and, if possible, some current from emitter to collector. However, I don't think that is at play here.

    So the bottom line is that I would expect the following:

    A B 5V 9V
    LO LO ON ON
    LO HI ?? ON
    HI LO ON ON
    HI HI OFF OFF


    Please check and make sure that the A and B aren't swapped in your table of results.

    Also, if you wouldn't mind, measure the node voltages (I think I count nine of them) under each of the input conditions and post them. I think they would be quite informative. You might also see if the circuit works as is if the Vcc is raised to 9V.

    BTW: I think this circuit, and most of his others, are really poorly designed, even leaving aside the fact that they aren't useful gates because they don't have a meaningful output that can drive other gate inputs, the electrically relevant output node is active HI in some circuits and active LO in others, and the basic concept behind the circuit functionality is all but chaotic. These really struck me as "happenings" instead of truly "designed" circuits.
     
    atrumblood likes this.
  3. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    I simulated the circuit on proteus and it doesnt work well too. The battery voltage I used is 9V. When the top transistor conducts the current in the LED is about 8mA but when the bottom transistor conducts, the current is only half of that. That's why it is dimmer.

    This is only a demo circuit, so the designer tries to make it as simple as possible. May be you can try to improve it as an exercise if you want to. After all the 7400 internal circuit is available in the datasheet and you can always refer to it.:D

    Allen
     
    Last edited: Jun 29, 2012
  4. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    Thanks WBahn,

    I did not think to take into account the Vf of the diodes and the amount of voltage I was using. I disconnected the 5v regulator and tied directly to the 12v power supply and I got the results I expected.

    Also, yes I am using the LED as Node C.
    Do you know of any other logic gate bread board exercises/schematics I can try?
     
  5. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    These results are quite close to my hand calculations. I figured that the current for both transistors OFF (or only the top transistor ON) would be 7.3mA and 3.6mA when only the bottom one is ON. That makes be feel pretty confident that I've done it correctly.
     
  6. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    That's good to know.

    I really would recommend that you estimate what the node voltages would be under each of the input conditions and then measure what they actually are. It may be a ****-poor circuit from a practical standpoint, but it is actually a pretty good circuit from an analysis exercise standpoint.
     
  7. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    LT Spice would be the right thing to get this working.

    Should not take more than 30 minutes.
     
  8. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    Took less than 10 minutes to do it by hand and determine that the circuit should be marginal at Vcc=5V and functional and Vcc=9V.

    I strongly recommend NOT running to a simulator and have it do all your thinking for you.

    Simulators are fine as a tool (the circuits I design HAVE to be simulated to get even close to how they behave!), but when you are trying to learn something, use a simulator as a much later step in the process (if at all) and try to use it to VERIFY your analysis, not perform it.
     
    atrumblood likes this.
  9. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    I agree with you on that point fully. I always get strange looks when I am running the numbers by hand, but it is the only way I can truly understand.
     
  10. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    Glad to hear this, too! ;)

    If you wouldn't mind, it would be nice if I could get you to put the Vcc back to 5V and measure the node voltages and post them. If nothing else, post the node voltages on the top and bottom rails to the right of the resistors connected to the supply. Also, please check which input (top or bottom transistor) is HI and which is LO for the troublesome case.

    Thanks!
     
  11. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    upto you how you get it working but LTSpice would be appreciate for me, since I have for instance built larger CMOS logic circuits 10 years ago.

    And we also had digital electronics in college, including all the way down memory lane doing this Karnaugh optimization stuff.

    I found LTSpice totally useful to learn about MOSFET behaviour, but this also included to build many circuits in physical form. Using LTSpice was mainly done to save time, so I would already have an idea about circuit behaviour, and I would already know the required voltage levels.

    So it only took me 2 months to become familiar with MOSFETs. In this time I also built a transistor tester for PNP/NPN, which works fine, never have drawn a schematic, but it works like I want it to.

    I must apologize if my way of doing circuits is maybe not the best for beginners.
     
  12. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    The Measurements on the Top and Bottom rails read as follows.

    A Low: B Low : Voltage 3.116V
    A Low: B High : Voltage 3.115V
    A High: B Low : Voltage 2.776V
    A High: B High : Voltage 0.634V

    Vf D1: 0.547V
    Vf D2: 0.537V
    ############################################
    (Measurements taken with top and bottom bjt in cut off mode)
    ############################################

    Vf Led: 1.813V
    Vd Top transistor: 0.652V
    Vd Bottom Transistor 0.659V

    LED Current: 2.71mA

    ############################################

    (5V - 1.813V - 0.547V - 0.537V - 0.652V - 0.659V) = 0.792V


    Lastly the top and bottom transistors.

    When the top is in cut off and the bottom saturated, the LED is Dimly Lit.
     
  13. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    I don't follow. Is this the voltage on the top rail, on the bottom rail, or the difference between them? I was hoping to get the two separate voltages (top rail and bottom rail).

    Okay, so we should assume something like 0.55V for Vf.

    So the LED Vf can be assumed to be 1.8V.

    What is Vd, the base-emitter voltage? If so, then these are not consistent with the transistors being cut off. Where the bases grounded, or floating? I'm guessing floating.

    How did you measure the LED current?

    That value is pretty consistent with the 2.1mA I came up with. Using the adjusted Vf for the diodes, the computation would become

    Iled = (5V - 0.65V - 1.8V - 0.55V)/(500Ω+220Ω) = 2.6mA

    Now, you might be wondering why I have that 0.65V there. The transistor above the LED is configured as a diode-connected transistor (for the most part - if it were truly diode-connected there wouldn't be a base transistor there, but this has limited affect and probably adds only 25mV or so). The collector-emitter voltage of a diode-connected silicon BJT is just the normal base-emitter voltage.

    What does this this represent? The 0.792V is supposed to be the voltage of what?


    Good. So the trouble state is the one I identified, namely the top transistor OFF and the bottom transistor ON.

    Don't bother taking any further measurements (such as the separate top and bottom rail voltages) unless you want to.
     
  14. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    Sorry maybe I misunderstood what you were asking. This is measuring the voltage of the entire circuit just to the right of the 500Ω and the 220Ω resistors. Could you be more specific as to where I would probe to get what you were asking for?

    This is taking into account all of the voltage drops for each diode in the circuit. The value is what is left over.

    I disconnected the cathode from the circuit and placed the ammeter in that spot.

    I assumed this meant Voltage Drop.


    I am sorry for my ignorance on much of this. I really appreciate you taking the time to go over everything with me. It helps me greatly.
     
    Last edited: Jun 30, 2012
  15. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Forrest Mims has published some simple transistor gates. Here's one example that worked for me. The AND, OR, and NOR use the same components, just rearranged slightly.

    [​IMG]
     
    atrumblood likes this.
  16. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    It sounds like you took the voltage "between" these two points (i.e., but the negative probe to the right of the 220Ω resistor and the positive lead to the right of the 500Ω resistor). What I wanted was the voltages "at" these two points relative to the voltage at the negative terminal of the battery. So you would put the negative probe at the negative side of the battery and then use the positive probe to the right of the 500Ω resistor, take a reading, then move the positive probe to the right of the 220Ω resistor and take a second reading.

    That's what I thought. The computation is meaningless because the diodes are not all in the same loop. Imagine I had a 9V battery with 20 parallel branches all containing one diode and a 10kΩ resistor. Each diode would have about 0.6V drop across it, so the equivalent computation would end up yielding -3.0V. But what would that tell me? Absolutely nothing.

    And, in doing so, introduced a resistor into the circuit that affected the behavior. Probably not enough to matter too much, but almost certainly enough to have made a noticeable difference. Notice that I'm not saying that there was necessarily a better way and what you did was fine. It just helps to know that the actual current without the meter was probably a bit higher.

    A good exercise for you would be to look up the "burden voltage" on your meter on the range you were using and, if possible, the actual resistance it places in series with the circuit.

    Another good exercise would be to see if you can figure out a way to measure the meter's resistance given a battery, two resistors, and just the one meter being measured.

    My question here was just trying to clarify what measurements produced these results. With both transistors cut off, did you take your voltmeter and actually measure these voltages between the base of the transistor (positive lead) and the emitter (negative lead)? Also, how were the bases connected at the time so as to put the transistors in cutoff? Where they tied to ground? Left floating? What?

    Not a problem. You are doing fine and as long as you are putting forward quality effort to learn, I am willing to put for (hopefully quality) effort to teach.
     
    atrumblood likes this.
  17. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    Here's some terminology that might be useful to you.

    When we talk about voltages, we use two different concepts (one is really a special case of the other). We talk about the voltage "between" two points. We would usually denote this as V_ab where 'a' is the "positive" node and 'b' is the "negative" node.

    But we also talk about the voltage "at" a point (or at a node). Well, voltages are ALWAYS differences in potentials, so we need a common reference point, which we usually call "ground". We would write the voltage at node 'a' as V_a, but what we really mean is V_ag, the voltage between 'a' and 'ground'. Now, the 'ground' node must be specificed, but when there is a single voltage source powering the circuit, the ground node is almost universally taken to be the negative terminal of the voltage source. If it is not specified, assume that to be the case until you have cause to believe otherwise.

    Note that, given V_a and V_b, we can find V_ab by taking V_a - V_b.

    Similarly, if we know the voltages at 'a' and 'b' relative to any other point, we can find V_ab. Mathematically, this would be:

    V_ab = V_ax + V_xb

    When you add voltages, the inner nodes in the subscipts cancel out if they are the same.

    Since V_ab = -V_ba, we can write this as:

    V_ab = V_ax - V_bx

    Now think of a circuit in which we identify a loop (complete circuit) containing, in order, nodes a, b, c, d, and e.

    We could write KVL as

    Vab + Vbc + Vcd + Vde + Vea = 0

    But our "subscript math" requires this since this reduces to

    Vaa = 0

    And we know that the voltage at any node minus the voltage at that same node is zero?

    So why do we see things like Vcc and Vss and Vdd all the time?

    Well, since each of these, taken literally as a voltage between the two nodes in question, is always zero, the convention arose a long, long time ago that we would use this special case to mean no a voltage difference, but rather a supply voltage attached so that node. Normally, if I were to say Vc = 3V, well perhaps it equals 3V right now, but it might be changing with time. But if I say Vcc=3V, I am saying that there is a 3V supply that is holding Vc at 3V at all times. Over time, the notion that Vcc was a supply voltage associated with node 'c' (or more specifically, that whatever node Vcc was tied to would be called node 'c') has been lost because it wasn't all that important and valuable to track it.

    The terms are historically relevent in that Vcc, Vee, and Vbb are the supplies associated with the collector, emitter, and base parts of a circuit using an NPN BJT while Vdd, Vss, and Vgg are the supplies associated with the drain, source, and gate parts of a circuit using an NFET. This caused some confusion for me when I first starting working with PNP circuits because I couldn't understand why the positive supply (the one associated with the emitter) was called Vcc. It IS a contradiction, but custom has long sense decided that the confusion associated with this contradiction is tolerable compared to the risk of serious mistakes if the supply voltages are reversed. Besides, how would you name the supplies in a circuit that contains both NPN and PNP transistors. So the convention developed that the supplies would be named consistent with the NPN/NFET terminals. What about a circuit that contains both NPN and NFET transistors? Take your pick and use either Vcc or Vdd, just pick the same set for all of them. There is very little chance of causing confusion and, in fact, many people always use the same set regardless of which type of transistors they are working with.
     
    atrumblood likes this.
  18. atrumblood

    Thread Starter Member

    May 13, 2012
    59
    2
    Ok, so this time I believe I have measured the voltage correctly.

    With the negative lead of the meter connected to the common ground rail. I measured the voltage with the positive lead to the right of the 500Ω resistor and to the right of the 220Ω resistor.

    3.699V (right of 500Ω)
    0.586V (right of 220Ω)

    Top and Bottom bjt were tied to ground. (not floating)

    I measured them again with both bjt tied to VCC
    3.658V (right of 500Ω)
    2.982V (right of 220Ω)

    Burden Voltage: I tried to read through the manual for the meter I have but I could not locate the information regarding that. I have the link to the PDF here.

    (http://www.radioshack.com/graphics/uc/rsk/Support/ProductManuals/2200813_PM_EN.pdf).


    As for how I measured the two BJT. I re-measured them with both base leads connected to the ground rail. Positive lead of the meter connected to base, Negative lead of meter connected to Emitter.

    Top: -1.755V
    Bottom: -0.588V


    Also Thank you for the information on the terminology. It seems a little difficult to understand but somehow I may be over thinking it.

    Again I appreciate the time you are taking to help me understand.
     
    Last edited: Jul 1, 2012
  19. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    You're right, the burden voltage info doesn't seem to be there nor is any equivalent info there from which to get the series resistance.

    However, you can measure it yourself by putting the meter on one of the current ranges (you will need to make a separate measurement for each range). Then do the following:

    Take a voltage source, suitable for the current range to be measured and pick a resistor (preferably a 1% or better resistor) that that should result in near full-scale current. Put the resistor across the source and measure the voltage across it with the meter (as a voltmeter). Then put the meter (as an ammeter) in series and see what the current is. If you are willing to assume that the voltage and resistor and current measurements are accurate, you can calculate the unknown resistance of the meter. To get a better number, use another resistor to bring the current down to about 50% of full-scale and do it again.

    Thanks for retaking the data. At first glance it looks reasonable. I'll look at it a bit closer later.
     
  20. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,173
    397
    Are you still interested in other RTL & DTL , gates & astable, bistable & monostable multivibrators? Another OP wanted to build basic circuits but never came back- gave him a one-shot. Most of these oldies used Germanium transistors, like 2N404, 2N1305 PNPs & 2N1306 NPN.
     
Loading...