Maker Pro
Maker Pro

74HCT08: an IC beginning

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Hello,

I'm trying to teach myself electronics so I guess this counts as "self assigned homework" ;)

I've got an SN74HCT08, Quad 2input AND gate (http://www.nxp.com/documents/data_sheet/74HC_HCT08.pdf)

It's always running "TRUE" and I don't get why: mind you this is the very first IC i've ever tried to hook up. Have read the datasheet but no doubt missing something
  • I've got a 5v feed to the right side of a breadboard from a Pi, and a 3.3V in to the left side (for benefit of understanding my photos below)
  • I've got ground from the Pi (pin6) going to board
  • I've got +5v running in to VCC pin (at top right of IC)
  • I've got the GND pin connected to ground
  • I've got an LED going from pin "1Y" to ground through a resistor (100R, probably a third of what i SHOULD be using I think? But destroying my Pi aside...)
Just with this setup, and nothing going in to 1A or 1B, 1Y is already true (image36), IMAG0036.jpg i.e. my LED is bright. This seems odd to me: I'm thinking perhaps "1A and 1B disconnected" somehow still triggers TRUE, whereas perhaps 1A and 1B at 1.35V (the datasheet max low voltage) would give me the desired FALSE at this point?) Given the datasheet doesn't list a minimum for "low" I would assume that disconnected is as low as you can get and would satisfy the logic?

I also routed 3.3V in to my input pins, 1A only, 1B only, as well as 1A-and-1B... still 1Y remains TRUE, LED glaring at me like it knows something I don't... stoopid smug LED! (image37) IMAG0037.jpg

Thanks heaps for any help you can offer :) First Post Done!

- Simon
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
(to be clear, I expected LED to be off unless both 1A and 1B were at 3 volts...)
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
Hi Simon

You need a pull down or pull up resistor depending on the logic level you want on the output. This is your first lesson :), don't leave input pins floating, tie them to one of the supply lines. Example if you are going to be exerting the pins high then you pull them low and vice versa. Use a large value resistor for this, something like a 1 MOhm will do.

Adam
 
Last edited:

Supercap2F

Mar 22, 2014
550
Joined
Mar 22, 2014
Messages
550
It sounds like you left the inputs floating (ie you left them unconnected). All the inputs you don't use and the inputs your using should be hooked up to one supply or the other. The common in your circuit is what you hook them to for the 0 state and your positive supply for 1 state. If you have a switch and one side is hooked up to the input pin and the other side is hooked up the the positive supply, you will need what's called a pull down resistor hooked up to the input pin. All that is is a resistor that has one side hooked up to the input pin, and one side hooked up to the common.

EDIT: Adam got to it first!
Dan
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,724
Joined
Nov 17, 2011
Messages
13,724
Given the datasheet doesn't list a minimum for "low" I would assume that disconnected is as low as you can get and would satisfy the logic?
Unfortunately this is an invalid assumption.
You should never leave unused pins of a CMOS chip open. Always use a pull-up or pull-down resistor to ensure a defined logic level high or low when nothing is attached to the input. An open input is undefined for CMOS and can lead to any unpredcitable behaviour. Examples range from arbitrary low or high to oscillations and extremly high current consumption with a defect chip as a consequence.
This goes also for unused gates, but for unused gates you can simply connect the inputs to GND or VCC (although it doesn't hurt to use pull-ups or pull-downs here, too).

If you have a driving gate connected to the input, you do not need the pull-up or pull-down as the driving gate should ensure a valid logic level.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Thanks guys! Much appreciated. I shall do some more reading as it doesn't quite make sense to me (after doing a little bit of reading) Feel free to just let me go work this out for myself, but for ponderings sake: tt sounds like from 3.3v, i go to a large resistor, then fork and go to ground and go to the input pin... for arguments sake if there is a switch/break to ground then the input pin will be HIGH, if the connection to ground is closed/complete then the pin will be LOW. Is that right? I get how the LOW state works, because the current will find the shortest path to ground and only a tiny bit will flow in to the pin... What I don't quite get is that in the HIGH state, the large resistor would be restricting voltage in to the pin... or is that current? or both? ok i really am a beginner... i guess it's just still enough voltage and current to count as a HIGH state... but you wouldn't want a stupidly large resistor would you or that would fail too? OK im going to go make some "EveryCircuit" circuits...

Thanks again for putting me on the right track :)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
but for ponderings sake: tt sounds like from 3.3v, i go to a large resistor, then fork and go to ground and go to the input pin...

No, for high you can connect the input to an appropriate voltage. "appropriate" typically means the same voltage as that powering the chip (it may be called Vdd, or Vcc).

For low you connect to the ground voltage -- typically the negative side of the power supply (also called Vss)

There are specifications which define this far more exactly, but let's not worry too much about that.

Quite often you connect via a resistor, but there is no reason in most cases to use one. The advantage for a beginner is that if you use a resistor and you accidentally connect to the wrong pin, you won't short anything.

Also there is no forking :)

for arguments sake if there is a switch/break to ground then the input pin will be HIGH, if the connection to ground is closed/complete then the pin will be LOW. Is that right?

Here is a reason to use a resistor. If you want to use a switch to produce a direct connection between a pin and one of the supply rails then you need a resistor to pull the input to the other supply rail when the switch is open. Clearly using a simple connection to the power supply here would cause the switch to short the power supply.

In this case the resistor acts (kind of) like a spring to return the input to the other supply rail when the switch is opened.

I get how the LOW state works, because the current will find the shortest path to ground and only a tiny bit will flow in to the pin... What I don't quite get is that in the HIGH state, the large resistor would be restricting voltage in to the pin... or is that current? or both? ok i really am a beginner... i guess it's just still enough voltage and current to count as a HIGH state... but you wouldn't want a stupidly large resistor would you or that would fail too? OK im going to go make some "EveryCircuit" circuits...

Yes, a small amount of current is required to force the input to go from one state to the other. When you're using CMOS that current is so vanishingly low that in some cases the pin on the IC can pick up enough power from a nearby magnetic field to switch state.

Other logic types (TTL for example) are different in that they will naturally go to one particular logic state and need to be actively held in the other state.

Understanding all of this completely will not happen overnight. Expect to pick up more and more about this for a long time. As soon as you think you understand, along may come an unusual circuit which will make you scratch your head until you learn another piece of the puzzle.

Hopefully you quite rapidly learn how things will work if you operate within the bounds of the specifications (even though you might not completely understand what they are yet!). As you learn more, the knowledge of what the common specifications are will become fairly well known, and later you may even understand what happens when you operate (intentionally or not) the devices outside their specifications.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Thanks Steve much appreciated! This is sitting a lot better now. Appreciate the words of encouragement: that's good advice. When stepping outside ones comfort zone, one needs to remember not to beat themselves up too much :)
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
For fellow beginners stumbling upon this thread I thought I'd share my solution. Disclaimer: I can't guarantee it doesn't contain any stupid decisions. For one thing, I believe I should've put a 300R resistor on the LED line a) it might blow LED, b) it might be too much current going back in Raspberry Pi? (being used for power and ground)

and gate.jpg
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,724
Joined
Nov 17, 2011
Messages
13,724
Yes, you should add a series resistor to the LED. In this specific circuit, the output stage of the IC is (ab)used as a current limiter since it can drive only a limited current. However, it is not designed to be operated in this fashion and overall operation of the chip may be adversely affected (gates not working properly).
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,880
Joined
Jun 21, 2012
Messages
4,880
Note: the chip you say you have is the SN74HCT08N. The T in the part number means it uses TTL inputs and should have a 5 V supply. It is still a CMOS circuit though, meaning low-power operation and typically low-current inputs and outputs.

I would use the output to drive the base of a small NPN transistor (I am partial to 2N3906) through a 10 kΩ resister, emitter to ground, and the LED in the collector in series with a 330 ohm resistor connected to Vcc. Put all this in a corner of your prototyping board and use with a jumper wire whenever you need to observe the logic state of a single output our input from amongst several available. It is a good idea to purchase an inexpensive CMOS/TTL logic probe. Later you will need an oscilloscope to keep track of things, but a logic probe IMHO is a necessity to use while learning.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,880
Joined
Jun 21, 2012
Messages
4,880
Great advice, but the 2N3906 is a PNP. Should be 2N3904.
Oops! I have a two 35 mm film cans filled with both, but I always keep a data sheet handy when breadboarding with them. Thank you for the correction.
 
Top