AND gate not giving correct output

Hello!
I have a SN74HC08N IC and i’ve been trying to get it to work properly but i can’t get it to work properly.
The pulldown resistors are there, each on one input. When i connect input A to positive it gives a positive output, even if the B input has nothing but the pull down resistor. When i connect only the B input, it gives a negative output. What am i doing wrong?

The truth table that i’m getting:
A B Y
0 0 0
0 1 0
1 0 1
1 1 1

Thank you!

, even if the B input has nothing but the pull down resistor.

Do you have meter to check the voltage with just the pull-down resistor? The datasheet says it should be less than 1.35V to guarantee a logic-low.)

It's probably because you're trying to drive an LED at around 24 to 30mA, from an output that can only drive up to 4mA! Change that 100Ω resistor to around 620Ω or even 1k (hard to say, for sure, 'cuz I don't know what kind of LED you are playing with, but, if it's one that came with an Arduino "kit", then it's probably the dim kind). Also, if that LED is the dim kind, and not of the Super Bright class, it may, at that low a current, be too dim to see. Maybe drive the LED with a transistor (Google it).

You gotta check out the datasheet ;D

I would go with the “pull down resistor on A has a bad connection” theory.

Also drop the pull down resistors to 470R or there abouts.

BTW I see no decoupling capacitor - while this might be OK at DC or for slow applications in a stateless chip like an AND gate array, you should be instinctively adding 100nF ceramic decoupling caps to each and every logic chip as a matter of course.

Its good practice to connect all the unused inputs from the other gates and connecting to ground or 5V. For experimentation noone bothers, but if you build a permanent circuit don't forget this. Floating inputs cause various odd behaviours you probably don't want.

Also not a bad idea to add a 10uF (or more) tantalum capacitor (at least 16V!) to each power bus (on your breadboard). Make sure to get the polarity right or you'll get a rude awakening! This helps to overcome voltage loss due to contact resistance, and the resistance in the wires leading to the breadboard's bus lines. voltage loss, due to current surges.

Electrolytic capacitors can be used, too (6.3V or above). They don't react as quickly (because of internal inductance), but they'll do.

But, this is a minor detail, so don't sweat it, if don't have an "tants" or electrolitics lying around. ;)

Right! I'll follow the suggestions here and i'll post the outcomes.

Besides that, i got it to work like this: instead of leaving the inputs connected only to the pull downs, i connected the inputs directly to ground in addition to the pull downs. That got rid of the weird behavior, and produces the correct truth table.

Thank you very much so far!

i connected the inputs directly to ground in addition to the pull downs.

That shorts out the pull downs dosn't it?

As I said 10K is way too high.

For some reason my second reply wasn't posted. I measured the current between the input and the resistor and it was slightly above 1.5v. I replaced the resistor for a 1k resistor and everything works well now. I thought that a higher resistor would limit the current much more than a lower resistor, but i probably didn't take into consideration the "direction" of the current. Thankfully it's been solved.

Thank you very much, everyone. I learned a lot!

Glad you got it working.

I measured the current between the input and the resistor and it was slightly above 1.5v.

If the result you got was in volts the quantity you measured was not current.

thought that a higher resistor would limit the current much more than a lower resistor,

Yes it does. What you are trying to do with that sort of logic is to suck current out of the input to get a logic low. With the higher resistance you were not sucking enough current to make the input voltage drop below the threshold for a logic zero.

jorgeguberte: I measured the current between the input and the resistor and it was slightly above 1.5v.

Current is measured in Amps A. "1.5v" would be a voltage measurement.

jorgeguberte: I replaced the resistor for a 1k resistor and everything works well now. I thought that a higher resistor would limit the current much more than a lower resistor, but i probably didn't take into consideration the "direction" of the current. Thankfully it's been solved.

I hate to say it, but there is so much wrong with this statement that it would pretty much take a course in basic electronics to correct.

But, let me say this: The datasheet, for the SN74HC08N states a worst case current demand on any one if this IC's inputs, as 1µA. At that level of input current, the difference between 10k and 1k is miniscule. It should work just fine with a 10k pulldown resistor [you're sure it's an SN74HC08N, and not, perhaps an SN74H08N?]. Which brings me back to that 100Ω resistor in series with the LED on the output. If this truly is a SN74HC08N, then 100Ω really is too low. It should be more like 680Ω to 1k.

The fact that it's "working" is probably a fluke. In fact, come to think of it...if you are shorting across the resistor to achieve a "low" on an input of the SN74HC08N, then you are shorting out the Arduino supply, so, of course the LED goes out, thus mimicking an AND behavior. There are no sparks, or smoke, as one might expect from a short, because the Arduino's voltage regulator has output short-circuit protection.

The proper way to do it is to remove the wire, that is connected to +5V, when you want an input to be low. When the wire is connected, that is a high. When you remove the +5V wire, the resistor pulls the input low [thus the moniker "pulldown"] .

On further thought, because that 100Ω + LED, on the output exceeds the specified ABSOLUTE MAXIMUM current on an output, odd things may be happening -- like a greater current demand on the input, thus giving the impression that a 1k works better than a 10k.

if you are shorting across the resistor to achieve a "low" on an input of the SN74HC08N, then you are shorting out the Arduino supply,

Rubbish. You can quite happily connect a logic gate’s input to ground.

The proper way to do it is to remove the wire, that is connected to +5V, when you want an input to be low. When the wire is connected, that is a high. When you remove the +5V wire, the resistor pulls the input low [thus the moniker "pulldown"

Have you ever worked with logic gates? I suggest you review that entire post and have a think about it.

Grumpy_Mike: Rubbish. You can quite happily connect a logic gate’s input to ground. Have you ever worked with logic gates? I suggest you review that entire post and have a think about it.

No, silly -- have another look at his diagram, and then review the previous posts -- you'll see what I'm talking about.

Grumpy_Mike:

ReverseEMF:
The proper way to do it is to remove the wire, that is connected to +5V, when you want an input to be low. When the wire is connected, that is a high. When you remove the +5V wire, the resistor pulls the input low [thus the moniker “pulldown”] .

Rubbish.
You can quite happily connect a logic gate’s input to ground.
Have you ever worked with logic gates? I suggest you review that entire post and have a think about it.

HAH!

i’m a n00b about to start something similar and even i can say “removing 5V wires for a low” is not accurate.

i’m going with a cheaper setup of Logic gate chips; 4011, 4071 and 4081 - and HIGH/LOW is just a matter of connecting (pulling, or whatever) an input to EITHER the Vcc(?) (for HIGH or a ‘1’) or to GND (for LOW or a ‘0’).

BabyGeezer:
Rubbish.
You can quite happily connect a logic gate’s input to ground.
Have you ever worked with logic gates? I suggest you review that entire post and have a think about it.

HAH!

i’m a n00b about to start something similar and even i can say “removing 5V wires for a low” is not accurate.

i’m going with a cheaper setup of Logic gate chips; 4011, 4071 and 4081 - and HIGH/LOW is just a matter of connecting (pulling, or whatever) an input to EITHER the Vcc(?) (for HIGH or a ‘1’) or to GND (for LOW or a ‘0’).

OK, guys…let me esplain… First of all, what I meant by removing 5V wire for low is this: if you look at jorgeguberte’s diagram, you’ll see that he has, on each input, a wire going from the input, to +5. ALSO, there’s a 10k resistor going from the input, to ground. SO, if you remove the wire going to +5, the 10k resistor is still there, pulling the CMOS input low. Thus, removing a +5V wire, in this case, is a way to cause a LOW condition.

And, in a later post, jorgeguberte states that he “instead of leaving the inputs connected only to the pull downs, i connected the inputs directly to ground in addition to the pull downs.” he/she doesn’t say anything about removing the wire that goes to the +5 line – so, I was thinking that maybe jorgeguberte was doing his direct to ground hook-up, WITH THE +5 WIRE STILL IN PLACE. That would, of course, cause a short to ground. And since the +5V line is being supplied by the Arduino, this short would put the Arduino’s regulator in short-circuit-shutdown. And, episofacto, that would behave JUST LIKE AN AND FUNCTION – thus giving jorgeguberte a false positive.