Arduino Forum

Using Arduino => General Electronics => Topic started by: p1ne on Jan 19, 2017, 06:14 pm

Title: Understanding NAND
Post by: p1ne on Jan 19, 2017, 06:14 pm
Regarding transistor circuits, I can see how the output of AND circuit works, but I'm not seeing how/why closing both switches turns the NAND circuit off (output above series transistors). Please lend some insight. Thanks.

(http://www.electronicshub.org/wp-content/uploads/2015/07/TRANSISTOR-NAND-GATE.jpg)
Title: Re: Understanding NAND
Post by: CrossRoads on Jan 19, 2017, 06:22 pm
Output only goes LOW if both inputs are HIGH. Both transistors need to be turned on.
INs     AND    NAND
0  0     0        1
0  1     0        1
1  0     0        1
1  1     1        0
Title: Re: Understanding NAND
Post by: CrossRoads on Jan 19, 2017, 06:23 pm
Depending on the Vce of the transistors, that LOW could be as much as 1 to 1.4V. Have to be careful about mixing technology types.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 19, 2017, 06:47 pm
Quote
but I'm not seeing how/why closing both switches turns the NAND circuit off
If both transistors are turned on, the the output is effectively connected to ground so the output is low or a logic zero. I would not call that off but you could make a case for calling it that. In my mind the output is actively sinking current.

If one of both transistors are off the output is connected to 5V ( through R3 ).
Title: Re: Understanding NAND
Post by: MarkT on Jan 19, 2017, 07:15 pm
Logic signals are 1/0 true/false, high/low, active/inactive.  On and off is perhaps confusing in this context,
unless its some output device like an LED.  On/off usually applies to current flowing, most logic families
are voltage-level defined.
Title: Re: Understanding NAND
Post by: p1ne on Jan 20, 2017, 01:39 am
If both transistors are turned on, the the output is effectively connected to ground so the output is low or a logic zero.
Please explain how if both transistors are turned on, the output goes to ground. That's the part I'm not understanding. Thanks.
Title: Re: Understanding NAND
Post by: septillion on Jan 20, 2017, 01:44 am
And if you think of it as one transistor?

If the transistor is turned on (aka, on A or B there is a voltage) then there is a path through the transistor which leads to GND.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 20, 2017, 07:35 am
A transistor can be thought of as a switch. When a little current flows through the base a lot of current can flow between the collector and emitter. So the emitter and collector can be thought as being connected together like a switch. So when a transistor is on the collector is connected to the emitter and the emitter is connected to ground. So anything connected to the emitter is also connected to ground.
Title: Re: Understanding NAND
Post by: MarkT on Jan 20, 2017, 12:24 pm
The transistors are either in cutoff or saturation when used as a switch, neither is much to do
with normal transistor action as used in amplifying a signal, which happens in the active region.
Think of it as a mechnical switch controlled by the base current being present or absent.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 20, 2017, 12:34 pm
This is the equivalent circuit with switches. The switches are closed when current is applied to them.
The flashlight bulb only light up when both switches are closed.

(http://forum.arduino.cc/index.php?action=dlattach;topic=449527.0;attach=195432)
Title: Re: Understanding NAND
Post by: p1ne on Jan 20, 2017, 03:10 pm
Thanks for replies and good to be reminded transistors can work as switches. Grumpy Like, following that example with both switches closed = light on, in 2 transistor example, why does all voltage run to ground and not power led when circuit is closed? In my thinking the voltage should hit the light even before it gets to transistors, unless closing 2 switches blocks ground, which does not seem to be the case.

The light being ahead of the transistors seems to be a key factor here that I'm not getting. Thanks for more explanation.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 20, 2017, 03:23 pm
Quote
The light being ahead of the transistors seems to be a key factor here that I'm not getting.
If you are thinking that the order of the components matter in a series circuit then you are not getting to grips with how electricity works.

A circuit has to be considered as a whole electricity does not hit anything first.

Quote
why does all voltage run to ground and not power led when circuit is closed?
What circuit are we talking about here, that last one of mine or your original one.
For mine
The circuit is from the battery positive, through the flash lamp thus lighting it up, through one switch, through the other switch and then to the battery negative.

For the original one there is no LED in it and I don't know where you have it connected, but with both transistors on the current goes to ground and the voltage on the collector of the top transistor is at ground. So an LED connected from the top transistor's collector to ground will have no voltage across it and so will not light up.
However if the LED were connected to the collector of the top transistor and to 5V then when that collector was connected to ground the LED would light up.

There are two ways to control an LED the first is called sourcing current and the second is called sinking current
Note all LEDs must also have a series resistor. That is why I draw a flashlight bulb to make things simple.

Note to everyone except the OP. I am simplifying this by assuming that Vsat is zero, it isn't but that fact doesn't matter at this stage in the argument.
Title: Re: Understanding NAND
Post by: p1ne on Jan 20, 2017, 04:19 pm
Why is the output above the transistors in a NAND circuit, and below the transistors in AND circuit?
Title: Re: Understanding NAND
Post by: CrossRoads on Jan 20, 2017, 05:05 pm
Does this help?
(http://forum.arduino.cc/index.php?action=dlattach;topic=449527.0;attach=195469)
Title: Re: Understanding NAND
Post by: MarkT on Jan 20, 2017, 06:52 pm
Why is the output above the transistors in a NAND circuit, and below the transistors in AND circuit?
I think its time to try this out on paper, figuring out what combinations of inputs causes the output
to be high or low.  Worth looking add wired-and and wired-or diode-resistor circuits too.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 20, 2017, 08:20 pm
Quote
and below the transistors in AND circuit?
It's not.
Title: Re: Understanding NAND
Post by: p1ne on Jan 20, 2017, 08:48 pm
Check Crossroads diagrams. NAND output is above transistors and AND output is below. More examples attached.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 21, 2017, 12:04 am
Quote
Check Crossroads diagrams.
OK.

No special reason it is just the way it is implemented. It is the simplest implementation using the fewest transistors but there is nothing significant about the positioning.
Title: Re: Understanding NAND
Post by: westfw on Jan 21, 2017, 10:29 am
Understand that the circuits you are showing are simplified, not-very-good, logic gates.  In order to understand them, you should assume that the transistors are perfect switches: an NPN transistor is turned on by a positive voltage (logic 1, usually), and a PNP is turned on by a GND voltage (logic 0)
Um.  That means I have doubts that the PNP circuit you showed actually implements an AND gate.  Looks to me like the output will only be 1 if both inputs are 0 (which makes it a NOR gate.)  Similar circuits (http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/and.html (http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/and.html)) make an AND gate with similar topology and NPN transistors...  (As in your second link)

Title: Re: Understanding NAND
Post by: p1ne on Jan 22, 2017, 05:29 pm
Thanks to all for weighing in. A key point to my understanding has come about with learning that electrons in a closed circuit flow opposite the arrow symbol on the transistor.

So wiith NAND 2 NPN transistor circuit with LED and 2 normally open switches, cathode is to ground with anode connected to collector/voltage in (via resistor). So the circuit is already closed, and the LED is on. The open switches have no bearing, nor does 1 closed switch.

However, when both switches are closed, a flood of electrons goes to the LED anode, essentially creating 2 grounds on the LED and the light goes off.

My previous confusion about why the output LED was "above" or "below" the transistors had to do with not understanding the difference of connecting the output to the collector vs. the emitter: unlike the NAND circuit where voltage is already being supplied to the output/LED, when the output is connected to emitter, no voltage is flowing through the transistor when both bases are open.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 22, 2017, 05:49 pm
Just a few points to get your thinking a bit better:-
Quote
no voltage is flowing
Voltage doesn't flow. Current flows and voltage pushes it.

Quote
A key point to my understanding has come about with learning that electrons in a closed circuit flow opposite the arrow symbol on the transistor.
If you consider the direction of current flow matters you are misunderstanding something. We consider that current flows from the positive to the negative, this is called "conventional current". There is no need to consider electron flow. In a particular materiel the conduction mechanism will be dominated either by electron flow or hole flow, the two flow in opposite directions.   

Quote
However, when both switches are closed, a flood of electrons goes to the LED anode, essentially creating 2 grounds on the LED and the light goes off.
No that is not right, there are not two grounds in any respect.

Quote
My previous confusion about why the output LED was "above" or "below" the transistors .....
Yes that is right.
Title: Re: Understanding NAND
Post by: Jiggy-Ninja on Jan 23, 2017, 02:42 pm
Just a few points to get your thinking a bit better:-Voltage doesn't flow. Current flows and voltage pushes it.
If you consider the direction of current flow matters you are misunderstanding something. We consider that current flows from the positive to the negative, this is called "conventional current". There is no need to consider electron flow. In a particular materiel the conduction mechanism will be dominated either by electron flow or hole flow, the two flow in opposite directions.   
No that is not right, there are not two grounds in any respect.
Yes that is right.
Actually (https://xkcd.com/1318/), it's electrons moving in both cases. The distinction you're trying to make is between free electrons in N regions, and holes in P regions, but both of those are caused by electrons. Holes can't actually move since they aren't an actual thing, they are an absence of a thing.

But your larger point is correct. With respect to electrical and magnetic effects, there is no difference at all between positive charges flowing in one direction, and negative charges flowing in the other. The distinction is completely arbitrary.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 23, 2017, 07:05 pm
Quote
Holes can't actually move since they aren't an actual thing, they are an absence of a thing.
Of of course holes can move. They even have a positive mass.

So how can the absence of something have a positive mass?
Because the things that are absent have a negative mass. That means that they are repelled by a gravitational filed. But that is quantum mechanics for you.
Title: Re: Understanding NAND
Post by: Jiggy-Ninja on Jan 23, 2017, 07:41 pm
So I go to the electron hole (https://en.wikipedia.org/wiki/Electron_hole) page on Wikipedia and see this subheading: Detailed picture: A hole is the absence of a negative-mass electron.

I will say nothing more about the subject. Mother Nature is certifiably insane.
Title: Re: Understanding NAND
Post by: Grumpy_Mike on Jan 23, 2017, 09:32 pm
"Sometimes the appropriate response to reality is to go insane." (Philip K. Dick)
Title: Re: Understanding NAND
Post by: MarkT on Jan 24, 2017, 02:01 pm
Of of course holes can move. They even have a positive mass.

So how can the absence of something have a positive mass?
Because the things that are absent have a negative mass. That means that they are repelled by a gravitational filed. But that is quantum mechanics for you.
Actually the effective mass of a hole depends on the actual semiconductor material involved
and can be either sign even IIRC.

For analysing circuits (as opposed to understanding semiconductor device operation), forget electrons
and holes, treat positive charge as the thing that flows, then all your signs come out right and you
won't confuse people - conventional current is a flow of positive charge, that's the abstraction level
you want at the circuit level.

Whether the actual charge carriers are +ve or -ve doesn't matter, until you are designing actual devices!
Title: Re: Understanding NAND
Post by: Jiggy-Ninja on Jan 24, 2017, 05:45 pm
Whether the actual charge carriers are +ve or -ve doesn't matter, until you are designing actual devices!
Or doing chemistry, like electrolysis, electroplating, or anodizing.
Title: Re: Understanding NAND
Post by: MarkT on Jan 24, 2017, 08:19 pm
Quote
Or doing chemistry, like electrolysis, electroplating, or anodizing.
Most circuits don't involve that, unless you spill acid on a PCB/breadboard by mistake of course! :)