Logic gate problem - Colt45 solved it

dullard

Elite Member
May 21, 2001
26,032
4,663
126
I'm teaching myself electronics and need help (no, this isn't homework).

New question:
Ok, I bought some parts for a circuit and put them into a breadboard. Almost everything operates very well. I was surprized that it went so smoothly. But I have one remaining problem.

I boiled it down to the logic gates. These things just aren't as simple as I'd like them to be. If I strip all the extra stuff out that functions properly, what I have left is this diagram. I have an input of ~5 V, two switches, an AND gate, a 160 ohm resistor and an LED. The AND gate is described here.

When both A and B are closed, the LED is at 100% brightness. Good so far. Problem: When A, B, or both switches are open, the LED is at ~50% brightness. Why isn't it off? Does the logic gate allow that much leakage? Is there anything I can do to prevent it?

Problem 2: While investigating this problem, I noticed that if I physically touch any of the wires connecting to pin 1, 2, or 3, then that 50% bright LED randomly goes to off, 50% bright, or 100% bright. It stays in that random state until I touch a wire again. Heck, if I even bring my hand close to a wire, the LED will change states. But if both A and B are closed the LED is always 100% bright as it should be.

What am I doing wrong? Thanks.

Old question:
Can someone explain to me how logic gates function (in terms of resistances, voltages, and where current flows)?

Suppose you had a generic logic gate. You'll have these features:
[*]Supply voltage pin, Vdd.
[*]Input voltage pins, Vin.
[*]Output voltage pin, Vout.
[*]Ground pin (sink), Vs.

Suppose the gate is supposed to output a true value (1), does Vout = Vdd?
[*]In this case, is there a significant internal resistance from Vdd to Vout?

Suppose the gate is supposed to output a false value (0), does Vout = Vs?
[*]In this case, is the supply voltage sent to ground? Is there an internal resistance for this?

I'm basically interested in what happens to each of the input/supply lines.
 

PurdueRy

Lifer
Nov 12, 2004
13,837
4
0
Originally posted by: dullard
Can someone explain to me how logic gates function (in terms of resistances, voltages, and where current flows)?

Suppose you had a generic logic gate. You'll have these features:
[*]Supply voltage pin, Vdd.
[*]Input voltage pins, Vin.
[*]Output voltage pin, Vout.
[*]Ground pin (sink), Vs.

Suppose the gate is supposed to output a true value (1), does Vout = Vdd?
[*]In this case, is there a significant internal resistance from Vdd to Vout?

Suppose the gate is supposed to output a false value (0), does Vout = Vs?
[*]In this case, is the supply voltage sent to ground? Is there an internal resistance for this?

I'm basically interested in what happens to each of the input/supply lines.

I believe the general answer would be:

1. Not quite. There is some internal resistance, however it will be close to that voltage

2. Voltage can't be "sent" to ground. I believe in this case the resistance is just very very high. This allows little to no current to be used(efficiency) and for the voltage to basically be zero.
 

dullard

Elite Member
May 21, 2001
26,032
4,663
126
Originally posted by: PurdueRy
It also depends on if you are sourcing or sinking
I would be sourcing the outputs to light LEDs.
Originally posted by: chuckywang
Depends on if the gate is n-type or p-type.
I'm trying to learn this info from catalogs, which aren't very helpful. What is the difference between those types?
 

PurdueRy

Lifer
Nov 12, 2004
13,837
4
0
Originally posted by: dullard
Originally posted by: PurdueRy
It also depends on if you are sourcing or sinking
I would be sourcing the outputs to light LEDs.
Originally posted by: chuckywang
Depends on if the gate is n-type or p-type.
I'm trying to learn this info from catalogs, which aren't very helpful. What is the difference between those types?

then I think you will find my answers to be correct.
 

hypn0tik

Diamond Member
Jul 5, 2005
5,866
2
0
Originally posted by: dullard
Originally posted by: PurdueRy
It also depends on if you are sourcing or sinking
I would be sourcing the outputs to light LEDs.
Originally posted by: chuckywang
Depends on if the gate is n-type or p-type.
I'm trying to learn this info from catalogs, which aren't very helpful. What is the difference between those types?

Google NMOS and PMOS.

Look up a simple MOS inverter, you'll get some of the fundamental concepts of logic gates.
 

theeedude

Lifer
Feb 5, 2006
35,787
6,197
126
Originally posted by: dullard
Can someone explain to me how logic gates function (in terms of resistances, voltages, and where current flows)?

Suppose you had a generic logic gate. You'll have these features:
[*]Supply voltage pin, Vdd.
[*]Input voltage pins, Vin.
[*]Output voltage pin, Vout.
[*]Ground pin (sink), Vs.

Suppose the gate is supposed to output a true value (1), does Vout = Vdd?
[*]In this case, is there a significant internal resistance from Vdd to Vout?
Suppose the gate is supposed to output a false value (0), does Vout = Vs?
[*]In this case, is the supply voltage sent to ground? Is there an internal resistance for this?

I'm basically interested in what happens to each of the input/supply lines.
Basically you have two switches. One from Vout to Vdd and one from Vout to Vss. Both switches have a resistance. One of them is on, depending on which value you want to output. So there is a resistance between Vout and either Vdd or Vss.
 

dullard

Elite Member
May 21, 2001
26,032
4,663
126
Originally posted by: PurdueRy
1. Not quite. There is some internal resistance, however it will be close to that voltage

2. Voltage can't be "sent" to ground. I believe in this case the resistance is just very very high. This allows little to no current to be used(efficiency) and for the voltage to basically be zero.
So it basically acts like a switch on Vdd. When the switch is closed (with small internal resistance) the power source current goes from power source to the output. Or the switch is open (with large internal resistance) and a very tiny current goes from the power source to the ground.

And there is always a large internal resistance from Vin to ground.

Is this the correct understanding? Thanks for the clarifications everyone.
 

PurdueRy

Lifer
Nov 12, 2004
13,837
4
0
Originally posted by: dullard
Originally posted by: PurdueRy
1. Not quite. There is some internal resistance, however it will be close to that voltage

2. Voltage can't be "sent" to ground. I believe in this case the resistance is just very very high. This allows little to no current to be used(efficiency) and for the voltage to basically be zero.
So it basically acts like a switch on Vdd. When the switch is closed (with small internal resistance) the power source current goes from power source to the output. Or the switch is open (with large internal resistance) and a very tiny current goes from the power source to the ground.

Is this the correct understanding?

For the basics, ya that's pretty much how they work. You can expect a voltage output of around 4.5V off a 5V source. When the switch is a 0 then you can expect around 0 V.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: PurdueRy
Originally posted by: dullard
Originally posted by: PurdueRy
1. Not quite. There is some internal resistance, however it will be close to that voltage

2. Voltage can't be "sent" to ground. I believe in this case the resistance is just very very high. This allows little to no current to be used(efficiency) and for the voltage to basically be zero.
So it basically acts like a switch on Vdd. When the switch is closed (with small internal resistance) the power source current goes from power source to the output. Or the switch is open (with large internal resistance) and a very tiny current goes from the power source to the ground.

Is this the correct understanding?

For the basics, ya that's pretty much how they work. You can expect a voltage output of around 4.5V off a 5V source. When the switch is a 0 then you can expect around 0 V.

I disagree on the 4.5/5 on the pull up and 0 on the pull down. The pull up or pull down current will be always on until VDS limits towards zero. The limiting factor on how high or low the output will rail is dependant on the leakage of the other transistors. That ratio shouldn't have a 0.5V drop from VDD.

Standard CMOS design is based on the principles of whether or not the output is connected to VDD or VSS through transistors. So the output DOES in fact get pulled to ground or pull to VDD.
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
when the switches are open, the pins are floating. logic doesnt like stuff floating.

put some pulldown resistors on the inputs.. like ~10kohm (doesnt matter much) to ground..
 

dullard

Elite Member
May 21, 2001
26,032
4,663
126
Originally posted by: Colt45
when the switches are open, the pins are floating. logic doesnt like stuff floating.

put some pulldown resistors on the inputs.. like ~10kohm (doesnt matter much) to ground..
Ok, I'll try that. Thanks.

It worked! Fastest good answer to a question ever. :beer:
 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
Originally posted by: dullard
Originally posted by: Colt45
when the switches are open, the pins are floating. logic doesnt like stuff floating.

put some pulldown resistors on the inputs.. like ~10kohm (doesnt matter much) to ground..
Ok, I'll try that. Thanks.

It worked! Fastest good answer to a question ever. :beer:

:)