Understanding logic gate NOT

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tuom larsen
 
Posts: 8
Joined: Wed Aug 18, 2010 7:47 pm

Understanding logic gate NOT

Post by tuom larsen »

Hello,
I'm totally new into EE and I'm tryinh to understand how logic gates really work, with the help of trying to visualize transistors as ordinary switches. AND becomes a wire connected to +5V and two switches in series, OR two switches in parallel, like:

Code: Select all

              /      /
AND:  +5V ---o o----o o----

                   /
             +----o o----+
OR: +5V   ---+     /     +-----
             +----o o----+

But I'm having hard time to come up with an analogy to NOT gate. Please, could someone help me here? Perhaps this is not the best way how to picture the things in the first place...

User avatar
westfw
 
Posts: 2010
Joined: Fri Apr 27, 2007 1:01 pm

Re: Understanding logic gate NOT

Post by westfw »

By analogy with your current diagrams, simply think of a "not" gate as a "normally closed" switch that connects to +5V when "off" and disconnects when "on."

It all gets more complicated when you consider that in the "0" state, you normally want to be "connected" to 0V, which is not the same things as just "disconnected."

User avatar
tuom larsen
 
Posts: 8
Joined: Wed Aug 18, 2010 7:47 pm

Re: Understanding logic gate NOT

Post by tuom larsen »

Thanks for the reply!

However, I was kind of thinking it could be somehow done with "regular" switches, i.e. on means on, and vice versa.

Would this work? Why isn't half of the +5V leaking even if the switch is on?

Code: Select all



NOT:  +5V  ----+---- Output
               |
               o
                \
               o
               |
             -----  (or just "-" ("minus")?)
              ---
               -


pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm

Re: Understanding logic gate NOT

Post by pstemari »

To do this with switches and true=+5v/false=high impedance, you'd either need to use an NC relay or just reverse the label on the switch.

User avatar
westfw
 
Posts: 2010
Joined: Fri Apr 27, 2007 1:01 pm

Re: Understanding logic gate NOT

Post by westfw »

Your second circuit would short out the power supply when the switch was closed, possibly leading to "excitement." However, if you were to use a "pull up" resistor to +5V to limit the current when the switch is close, then it would work (and incidentally be very similar to Arduino "button" examples that use a pullup resistor - the pin will indeed read "0" when the button is pressed.)
But a resistor is an "advanced" electronic component compared to switches; if you have only switches, you need the NC switch or reversed labels.

User avatar
tuom larsen
 
Posts: 8
Joined: Wed Aug 18, 2010 7:47 pm

Re: Understanding logic gate NOT

Post by tuom larsen »

Ok. But if I add that "pull up" resistor in the schematic above:

Code: Select all

NOT:  +5V  ----+---- Output
               |
               o
                \
               o
               |
              +++
              | |
              | |
              +++
               |
             -----  (or just "-" ("minus")?)
              ---
               -

the output wouldn't be +5V while switch being closed ("on"), right? And also it would consume some additional power, due to the resistor, right? Is there a way to make it again either +5V or ... 0V (what exactly? ground?)?

To put in in different way, I understand the option of changing the labels, it just seems to me that while AND and OR gates could be conceptually modeled via switches in pretty straight forward way, the NOT gate with changed label is something a bit different because it does not create +5V out of nothing ("on").

pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm

Re: Understanding logic gate NOT

Post by pstemari »

There just not a good way to show it with toggle switches. Try this with pushbuttons:

Code: Select all

NOT:

                      |
          +5V  ----o  |  o---- Output
                   ---+---


NOT NOT:

                      |
                      |
                   ---+---

          +5V  ----o     o---- Output

User avatar
westfw
 
Posts: 2010
Joined: Fri Apr 27, 2007 1:01 pm

Re: Understanding logic gate NOT

Post by westfw »

your pullup picture is wrong. It should be:

Code: Select all

        +-----+
+5V ---o+  R  +o---+--- Out: Not "x"
        +-----+    |
                   o
                    \ "x"
                   o 
                   |
                  GND
When the switch is open, the resistor provides 5V to the output. When the switch is closed, it forces the output to GND, since the switch resistance is zero. (There are certain "not practical" aspects of this, of course. Which is why it is difficult to design complicated circuits using switch-based logic (ie Relays.) This is essentially the function of transistors, especially in some of the older logic families like RTL and DTL. They amplify the non-ideal signals back to "close to ideal" (at some expense in other areas.)

User avatar
stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Understanding logic gate NOT

Post by stinkbutt »

This is a transistor version of a NOT gate:

Image

Does that clear things up? When the input's low the transistor's off, so it gets pulled high. Input goes high, transistor turns on & pulls it low. This is pretty much the same thing the other gents are posting to explain it, only I don't imagine ASCII art is the clearest way to explain things.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”