Beginner Electronics - Beginner Electronics – 26 – Logic Gates and Floating Inputs (and short channel update)

Electronics, Howto & Style

Beginner Electronics

29 Lessons

Beginner Electronics – 26 – Logic Gates and Floating Inputs (and short channel update)

what is going on everyone my name is Cody Martin welcome back to electronics episode 26 now before I begin today I just want to say that I'm really sorry

for my lack of videos I know it's been months since I've released videos and I apologize for any promises that I've broken to people out there I do feel really bad about that but I think that I

finally came to the realization that I just simply don't have enough time to make these videos on a regular basis so I do really really apologize for that I am gonna still try my best to complete

these series that I have going if not fast at least slowly that way for people watching these videos in the future at least my content will be complete for them but for those of you who are

sticking with me I really do appreciate it and again I apologize to anyone who I've broken a promise on so episode 26 of electronics we are going to be talking all about digital logic gates

now this is probably one of the most important topics in this series you must absolutely understand logic gates in order to continue along with building an 8-bit computer as well as to be able to

understand the rest of this series and in fact logic gates are actually really simple in fact they're one of the most simple components used in every single computer for the most part now I'm gonna

be showing you six of the most common logic gates that we will be using and in order to explain this I'm just going to begin with the first one we are going to start off by describing the not gate now

a logic gate basically takes one or more inputs and it gives you one or more output values and it does something to the inputs to get you your output so if we were to draw the not gate as a

schematic symbol we would have our input coming into this triangle with a little circle on top and then our output leaving it we would have some digital value again digital meaning a zero or a

one zero meaning no voltage one meaning voltage and it'll give us some output value which will also be a zero or a one low or high so if we send a low value in for the input of our not gate so if we

send in a zero what the not gate will do is it'll give us the opposite of that value so it'll actually spit out a 1 and if we send it in a if we send in high voltage then it will

spit out a zero it'll give us a low value instead and we can represent this with something called a truth table which I have here basically it lists all of the possible inputs in the case of a

not gate it only has a single input which I've labeled a so if I pass a value of zero a low value into my not date I will get out a 1 and if I pass in a 1 as the input I will get out a 0 and

that's it that is what a not digital logic gate does and not gates are used almost everywhere in electronics and there'll be plenty of examples of it throughout this series so let's move on

to a slightly more complicated logic gate next up is the or gate now if we were to draw this as a schematic diagram first of all it has two inputs in fact an or gate can have as many inputs as

you want just as long as you have at least two but most commonly you'll see a two input or gate and then the symbol kind of looks like this it's like a curve and then it goes up into a point

and then we have a single output value so let's call this input a we'll call this input B and then this is our output now an or gate will output a 1 it'll output a high value if either A or B or

both of them are a 1 if they're high so let's say we pass in a 0 for a in a 0 for B low and low well the or gate is just going to give us a 0 nothing is really gonna change here however let's

say we send in a 0 for input a and a 1 for input B since B is 1 at least one of our inputs is a 1 then the output will always be a 1 the same thing in the opposite direction if we send in a 1 for

a in a 0 for B then we will have a 1 for the output because at least one of our inputs was a 1 and if both of our inputs are a 1 well that's really easy they're both 1

so the output must be 1 and that is all in or gate does the only time the output of the or gate is a 0 is if all of the inputs of the or gate is also a 0 anything else will give you a 1 now

let's move on to the and gate so the and gate I'm gonna try not to go too too slowly because there are plenty of resources on this stuff and really it's just looking

at a table and kind of remembering what each one of them does so the and gate schematic symbol again we're gonna have two inputs this time and we have this sort of flat end that goes up into a

weird curve and we have a single output value so we have input a input B and then an output now the and gate it will only produce a one a high output if input a and input B and all the other

inputs are also ones so if we send in a 0 and a 0 so 0 for a 0 for B we're gonna get out 0 if we send in a 0 for a and a 1 for B well we're still gonna get a 0 because both input a and input B were

not 1 same thing for the next case if input a is 1 and input B is 0 well they're both not 1 so we're gonna get a 0 out finally if we send in a 1 for both a and B well a and B are both 1 so we're

going to get a 1 for our output and that's all there is to a NAND gate next we have one of my favorite gates and that is the X or gate otherwise known as the exclusive or gate I'm just gonna

write that here in case you might see this wording for this gate exclusive or and as you might have guessed it is quite similar to a normal or gate and the symbol actually looks very similar

so if we draw the normal or gate symbol which is kind of this curvy piece here all we do is add another line at the back and we have an exclusive or gate let me begin by writing down the truth

table for a normal or gate remember in Oregon Li a1 for an output if at least one of the inputs was also a 1 so here we have a 0 1 1 and then in a normal or gate we would also have a one

but an exclusive or actually makes it so that it's strictly one or the other and not both so if we have both inputs as 1 then we're also going to get a 0 here so exclusive or means it must be input a or

input B and not both of them at this time alright great so let's move on the next two gates I'm going to show you I'm not going to use very much if at all in this series but I figured that I would

show them to you just in case you see them along your journey so we are going to cover the NAND gate next and if we remember the schematic symbol for the end gate we had two inputs and then we

have this weird curvy thing and then we had our output well the only difference for the nand schematic symbol is that we have a little circle on the top here now you will recognize this circle from our

not gate remember the not gate was a triangle with a circle on top so the way I think of this is not and it's the opposite of end and well that's exactly what it is

so in a normal and gate if we passed in a zero and a zero we would get a zero out as well but a NAND gate reverses that so instead of getting a zero we're gonna get a one out same for

the next two cases in a normal and gate 0 and 1 or a 1 and a 0 we'll also get you a zero but a NAND gate reverses that so you'll get a 1 for both of these cases and as you might have guessed a

normal and gate would give us a 1 when we passed in 1/1 but of course a NAND gate inverses that and we get a 0 instead so you can actually think of this NAND gate as basically a NAND gate

as we have here going into a not gate remember the first gate that I showed you it simply reverses the output of an and gate alright let's move on to the very final logic gate finally we will

have the nor gate and I'm gonna go through this one really really fast because I'm sure that you can guess kind of what this one is going to be if we draw our normal or schematic symbol

which is kind of this thing again well the only difference is we have this little circle on top in that circle almost always means inverse your normal output essentially put the output of an

or gate through and not eight almost I think of this as a naught or gate so if we have 0 and 0 sent in an or gate would usually give us a 0 but instead an or gate will give us a one and real

quickly these other two cases if we have a zero and a one an or gate would usually give us a one button or will give us a zero same exact thing for this case as you might have noticed the order

of the inputs does not matter for any of these logic gates so input 0 1 is the same thing as input 1 0 it doesn't matter the order that you put the inputs in anyways the pattern will continue a

normal or gate would give us a 1 here so we're gonna put a 0 as the output for a nor gate and that's it those are the 6 logic gates that I'm gonna show you today again you only need to know the

first 4 for this series really well now I'm gonna drop a really quick schematic using an exclusive or gate and this schematic is actually gonna have a problem in it and it's gonna be a very

important problem that we're gonna be avoiding for the rest of this series so even if you don't want to watch this part because you already know about logic gates I want you to kind of watch

through and see if you can pick out the problem in this circuit and I will explain it at the end so first let's start off with our power supply here we're gonna have the positive end of our

power and let's take this positive power and let's feed it to two single pole single throw switches just normal switches if they're off they're not connected to anything if they're on they

get connected to this positive power so those will be our two manual inputs by that switch and we are going to run these through to an exclusive or gate so let me draw this very poor depiction of

an exclusive or gate symbol and we will take our output and I'm gonna lead this into a resistor because I'm gonna go straight in to one of my LEDs and this LED will represent the output if it's on

it means the output is a 1 or high and if the LED is off then the output was a 0 or low and then of course this end of the LED is going to connect on down to the ground

source so a very very simple circuit we have two inputs here that are just going to be simple switches that lead into a single exclusive or gate and the out will lead to an LED so that we can

actually see the output now let's go ahead and build this and see if we can see a problem with this circuit and the problem might not be very obvious now there are many different manufacturers

for exclusive or gates in fact there's many manufacturers for any type of integrated circuit really but I'm gonna be using the hd7 4 LS 8 6 exclusive or chip and you'll notice if we take a look

at the schematic diagram of it there's actually four individual exclusive or gates inside of this chip but I'm only gonna be using the very first exclusive or gate and you will notice that this

chip has a ground and a VCC a positive voltage source input and that is because this chip actually has to be powered in order for any of these exclusive or gates to work and oftentimes when you

see schematics like the one that we drew we didn't show the exclusive or gate being powered but in practice when we use a chip like this the chip actually has to be powered separate from the

inputs and the outputs of the exclusive or gates that we're using inside of the chip anyways looking more at this data sheet for my chip you'll see that even lists

the function table and this looks exactly like our truth table that we have so it's saying if we have a low input for both a and B then the output will also be low if one of the other is

high then the output will also be high but if both of the inputs are high then our output will be low so it actually shows the truth table about what each of those individual exclusive or gates does

and finally we can go down a little bit more and we'll see the recommended operating conditions so I'll see that my supply voltage should be 5 volts so I'm gonna power my breadboard I'm gonna

power my circuit using a 5 volt power supply this way I don't damage the chip even though it does say up here that maximum 7 volts should still be okay for the chip but you kind of want to avoid

the maximums so let's go build this circuit so as you can see I've already put my exclusive or chip into my breadboard here again this chip has 4 exclusive or gates in it but I'm only

going to use one for this experiment so I know that pin 1 is gonna be one of my inputs pin 2 is going to be the other input and pin 3 is the output of that first exclusive or gate so I'm going to

connect my resistor to pin number three if I can do this below the camera my setup is not the greatest and I'm going to plug that right over here to an empty slot on my

breadboard so from the output of my exclusive or gate is my resistor and then that is going to lead to the longer leg of my LED so I'm gonna put my LED there and then the shorter leg is going

to go to this little blue wire that I already have set up to ground and I should have mentioned but I already connected my exclusive-or chip to power the pin number seven to my ground in pin

number fourteen to my positive five volts now I know that I drew two simple switches in my schematic diagram but I'm just gonna use two wires and I'm gonna plug and unplug from the power rails as

my inputs this way we can demonstrate the problem that a single switch would have so I just have my two wires going into my inputs and I'm gonna connect them both to the ground rail for now

like so and now I'm gonna connect I'm gonna turn on my power that way things will start to operate all right so my breadboard now has power going to it and as you can see the light is off because

I'm sending in both inputs as zeros it might be a little hard to see they're both on to the ground rail there so exclusive-or says our output should be zero and that is true now if I move one

of the inputs to become a 1 if I connect one of these inputs to positive power positive 5 volts we get a 1 on our output because the exclusive or gate says that one zero means an output of 1

and if I do the opposite meaning if I plug this one back in again zero zero means we get a zero for the output and I plug the other one to +5 volts we get still and on signal a one signal and if

both of them are plugged into the +5 bolt if both of them are plugged into the +5 volts if we have a 1 1 for the input our output is zero and that is true our LED is off now you'll notice

something kind of special here when I disconnect one of these wires especially if one of them is connected to ground rather so if I disconnected this wire this is completely not connected and the

output is still saying it's a 1 and this is where we have to be really careful when we're designing a circuit because if this was happening in our 8-bit computer we would get some really

strange results especially with more complicated integrated circuits and not just logic gates basically the chip doesn't really know if this is a 0 or a 1 and therefore it just kind of has to

guess in this case make guessed a 1 and if I connect this to positive power well of course it stays a 1 and I disconnect this one then it turns off this time so now when one of them is disconnected I

get a 0 on the output so we can modify our circuit schematic that we drew up to use a single-pole double-throw switch meaning that the off position of the switch is actually connected to ground

instead of nothing and the on position is actually connected to +5 volts instead of nothing so firstly I'm going to sort of erase the switch portion of this because I'm gonna change things

around a little bit so I'm just gonna draw my switches a little bit differently that way I can actually fit them in the schematic a little bit better I'm gonna draw my switch for my

first input here up and if this is the off position that I'm actually gonna have that switch connect directly to my ground source this way when the switch is off it is actually sending a ground

signal as zero signal to the exclusive or gate and then of course when it turns on it'll flip on to this little piece of wire and connect to positive voltage and my second switch would be the exact same

thing I'm just gonna draw it differently again that way it's easier for my schematic to see that'll connect to ground when it's off and if not it'll connect to this wire here which will

lead to positive voltage this way we're never or at least for a very very short amount of time we are never not connected to ground or positive 5 volts we're always going to

be connected to one or the other that way we have a predictable state of our exclusive or chip so that's it for today's tutorial everyone thank you all so much for watching if you have any

questions at all please ask it down below in the comments because this is an extremely important topic that you have to understand to be able to follow along with the rest of the series

I'll do my best to start looking at the comments on my videos again especially these newer ones but if I don't get the chance to answer your question hopefully someone in our community here can help

you out and answer that question for you and there's also plenty of resources online that you can look up for these logic dates thank you all so much for watching and I'll see you all in the

next video

In this episode, we learn about the NOT, OR, AND, XOR, NAND, and NOR digital logic gates. We also explore an issue with “floating inputs” in circuits, that can cause problems. I also include a short channel update!

Need source code? See my website: https://codenmore.github.io/
Follow me on Twitter – @CodeNMore – http://www.twitter.com/CodeNMore
Comment, PM, or Tweet me for help!

Teaching to understand all subjects to the fullest extent!

    2's complement 555 555 timer 8-bit addition advanced alu amazing and and gate arduino arduino uno arithmetic astable attiny attiny85 awesome base 10 base 2 battery Battery (Invention) beginner binary bipolar junction transistor bistable bjt breadboard build building button capacitance capacitor charge circuit circuits components computer Computer Science (Field Of Study) computers decimal development digital logic diode easy education electricity electronics Electronics (Field Of Study) Engineer (Profession) engineering Engineering (Industry) episode 1 episode 10 episode 11 episode 12 episode 13 episode 14 episode 15 episode 16 episode 17 episode 18 episode 19 episode 20 episode 21 episode 22 episode 23 episode 24 episode 9 Experiment explained first floating inputs full adder half adder hard hardware Help how how-to ic integrated citcuit intermediate Invention (Literature Subject) invert gate inverter learn LED Light-emitting Diode (Invention) logic gate logic gates Math measure Mechanics microcontroller monostable multimeter non latching relay not gat npn transistor ohm ohms law Open-circuit Voltage oscillator parallel part 1 part 10 part 11 part 12 part 13 part 14 part 15 part 16 part 17 part 18 part 19 part 20 part 21 part 23 part 24 plans pnp transistor potentiometer Power programming relay relays resistance resistor Robot Robots schematic schematics scratch series software speaker subtraction switch switching symbol Technology Tips transistor Tricks tutorial two's complement variable resistor Watt Wattage xor xor gate