Newbie to Logic gates, super simple NAND question - Page 1
Forum section: electronics / beginners

author: newastrocity
author_rank: Contributor
timestamp: December 14, 2016, 06:16:35 am
content: Hi guys, I have been learning about logic gates via youtube, and really want to get started. I want to get some various types of logic gates at the store this weekend, but until then I decided to desolder some I found on a dead board of unknown status (other than "not working"). The chip I got is a SN74LS00N which as I understand it is a TTL NAND gate.I applied 5V to pin 14 and grounded pin 7. Then I put a 220 ohm resistor on pin 8, to an LED which was grounded at the other leg.Now, my understanding is that pin 8 is the output pin, and 9 and 10 are the logic input pins for that gate, and it is a NAND, so that when both pins are low, the output pin should be high and light the LED, but this is not the case, the LED stays off.I also notice that when pin 7 is grounded, if I ground EITHER pin 9 or 10, the LED also lights up.So is my NAND just toast, or am I misunderstandingt what it SHOULD be doing?Also in general, do my pins have to be grounded to be considered low, or can just letting them float as in on a breadboard be sufficient to be considered low?Thanks for the help!

author: MK14
author_rank: Super Contributor
timestamp: December 14, 2016, 06:31:03 am
content: It is best to tie the inputs you are using, to logic 0 (ground) or logic 1 (+5 volts). Leaving them floating, is not a good idea, and can be problematic. Floating inputs (TTL), tend to be a logic '1'. So if both inputs were floating (bad idea, as it can potentially sometimes become a logic 0), the Nand would be outputting a logic 0 = LED off.

author: ataradov
author_rank: Super Contributor
timestamp: December 14, 2016, 06:34:19 am
content: Quote from: newastrocity on December 14, 2016, 06:16:35 amPin 8 is an output, so if you ground it, your LED will be connected to ground on both pins, so there is no way it will light up.Quote from: newastrocity on December 14, 2016, 06:16:35 amActually grounding them is a good idea. It probably won't matter much for TTL, but may matter for CMOS, or at least it may lead to increased power consumption and oscillations.

author: newastrocity
author_rank: Contributor
timestamp: December 14, 2016, 06:39:19 am
content: Quote from: ataradov on December 14, 2016, 06:34:19 amSorry, I got my pin #s messed up in my post and you got to it before I could edit. I know pin 8 is output! I meant if either 9 or 10 is grounded, sorry!Quote from: newastrocity on December 14, 2016, 06:16:35 amActually grounding them is a good idea. It probably won't matter much for TTL, but may matter for CMOS, or at least it may lead to increased power consumption and oscillations.Thanks, good to know. If I leave the gates I am not using floating, could it interfere with the gate I am using? Or are they seperate?

author: ataradov
author_rank: Super Contributor
timestamp: December 14, 2016, 06:43:50 am
content: Quote from: newastrocity on December 14, 2016, 06:39:19 amThen you have both pins disconnected -> they are high, so NAND output is low, no LED. Either one goes to ground -> output is high, LED is on. The fact grounding both disables the LED makes no sense, but I don't think it is a busted chip. Are you sure you read the markings correctly? Try to connect all other inputs to ground to give them definitive state.Quote from: newastrocity on December 14, 2016, 06:16:35 amIt can in some cases, but probably not in this simple experiment.

author: tautech
author_rank: Super Contributor
timestamp: December 14, 2016, 06:45:55 am
content: Quote from: ataradov on December 14, 2016, 06:34:19 amYep, ALWAYS check the datasheet for recommendations of what to do with 'Unused Inputs'. Failure to do so can often explain unexpected behaviour.For those new to logic gates or just wanting to experiment, a site that I find handy from time to time:https://tams.informatik.uni-hamburg.de/applets/hades/webdemos/00-intro/00-welcome/chapter.html<Gate level circuits>

author: newastrocity
author_rank: Contributor
timestamp: December 14, 2016, 06:53:47 am
content: I think floating pins were my problem because when I ground the two input pins now I get a high output and LED illumination, but when I pull the pins and let them float I get nothing. Thank you guys for the help, when I make sure to either ground them low or feed them high, my NAND is ending up with the proper results on the truth table.I'm amazed you guys helped me so fast, I really appreciate it.edit: I think part of my confusion was in my head I assumed if only ONE pin was grounded and high, it was not AND but an OR, but it's a NAND (not sure if that makes sense, I'm experimenting when kind of sleepy... I think I just got confused until I actually grounded my inputs properly and went through the entire truth table step by step instead of winging it)

author: tautech
author_rank: Super Contributor
timestamp: December 14, 2016, 06:56:56 am
content: Quote from: newastrocity on December 14, 2016, 06:53:47 amDon't just do that,RTFMread the datasheet.

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2016, 07:05:42 am
content: If you want to go down a rabbit hole with logic gates, there is an interesting site that builds a virtual computer with nothing but NAND gates.http://www.nand2tetris.org/This is a totally impractical project for real gates but there's a lot of design going on building multiplexers, demultiplexers, counters, memory, etc. The ultimate project is a programmable CPU which includes an assembler and compiler.As a practical matter, wire-wrapping hundreds of packages together to build a project is a lot of work. You will want to progress toward CPLDs and, eventually, FPGAs. Where else can you build a project with a MILLION gates in a single chip? Cool stuff to play with and no wire-wrapping.

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2016, 04:40:29 pm
content: Quote from: newastrocity on December 14, 2016, 06:53:47 amIf you are working with TTL, you must provide pull-ups for NANDs and pull-down resistors for NORs (not used nearly as often).This article recommends 4.7k resistors (and this is what I remember using):http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/This is a much more complete discussion:http://www.electronics-tutorials.ws/logic/pull-up-resistor.htmlThe point is that the pull-up resistor needs to provide 10x the required IIHwhile meeting the VIH

author: Paul Moir
author_rank: Frequent Contributor
timestamp: December 14, 2016, 09:45:48 pm
content: Another thing perhaps worth talking about is the 74LS series non-symmetrical output current capabilities. Which is to say, it can only put out (source) something like 0.4mA but it can take in (sink) 8mA. This causes problems when wiring LEDs like you have with the current coming out of the gate, through the LED into ground.Say your gate output voltage is 3.5v open circuit. Loading it with a red LED and a 220 ohm resistor asks for (3.5v-1.7v) / 220 ohm = 0.8mA. In real life the gate output voltage will just fall dropping the current, but you are exceeding it's abilities.If you look at old schematics, they often wire it around the other way. One end of the LED is connected to +5v and the current flows into the logic gate via the resistor. That takes advantage of the 8mA sinking capabilities of the gate, which was good because old LEDs needed a far bit of current or they were pretty dim. The consequence of doing it this way is that logic 1 becomes "LED off" and logic 0 becomes "LED on".More modern CMOS versions like the 74HC series don't have this problem and can source or sink something like 20mA. Their output voltages are also closer to 5v & 0v.

author: Ian.M
author_rank: Super Contributor
timestamp: December 14, 2016, 10:10:10 pm
content: Bipolar TTL logic(74xx, 74Sxx, 74LSxx etc.) inputs float high (but don't rely on it - always use a pullup resistor if you need a guaranteed high level) Don't directly tie their inputs to +5V. You can tie any inputs that need to be logic '0' directly to the 0V rail. If using a pulldown resistor you'll need to check the input bias current isn't raising the voltage too close to the logic '0' threshold.CMOS 'TTL compatible' logic (74Cxx 74HCxx 74ACxx ect.) inputs float at an indeterminate level. All unused inputs *MUST* be either pulled up/down, or tied to the supply or ground, or paralleled with another input of the same function.Although most CMOS logic has far more symmetrical output capabilities, its generally still better at sinking current than sourcing it. For the same current, the voltage drop sinking and thus the power dissipation in the chip is typically lower than when sourcing current so its still usually preferable to connect the LED + resistor between the supply and the output rather than between the output and ground.

author: MK14
author_rank: Super Contributor
timestamp: December 15, 2016, 07:21:15 am
content: Quote from: rstofer on December 14, 2016, 04:40:29 pmQuote from: Ian.M on December 14, 2016, 10:10:10 pmAre you BOTH 100% sure about that ?Remember that the original TTL has multiple emitter input transistors (when necessary), which did mean that it was recommended to use pull up resistors, to protect its relatively low (compared to Vcc) 5.5V absolute maximum input voltage rating.But the OP is using LS.Quote from: newastrocity on December 14, 2016, 06:16:35 amBecause the LS has got "improved" input circuity, surely it does not need a pull up resistor anymore ?Unless you are putting it in for other reasons, such as to reduce the effects of short circuits.Some sources:http://ecee.colorado.edu/~mcclurel/ON_Semiconductor_LSTTL_Data_DL121-D.pdfQuotehttp://www.ti.com/lit/ds/symlink/sn74ls00.pdfQuote

author: tautech
author_rank: Super Contributor
timestamp: December 15, 2016, 07:35:28 am
content: Quote from: MK14 on December 15, 2016, 07:21:15 amQuite.But as I've stated beforeRTFMdatasheet.I've never seen a Logic IC datasheet that doesn't give clear instruction as to what to do with unused inputs.From the one offered above:11.1 Layout GuidelinesWhen using multiple bit logic, devices inputs must never float.Devices with multiple-emitter inputs (SN74 and SN74S series) need special care. Because no voltage greaterthan 5.5 V must be applied to the inputs (if exceeded, the base-emitter junction at the inputs breaks down), theinputs of these devices must be connected to the supply voltage, VCC, through series resistor, RS (see Figure 5).This resistor must be dimensioned such that the current flowing into the gate or gates, which results fromovervoltage, does not exceed 1 mA. However, because the high-level input current of the circuits connected tothe gate flows through this resistor, the resistor must be dimensioned so that the voltage drop across it stillallows the required high level. Equation 1 and Equation 2 are for dimensioning resistor, RS, and several inputscan be connected to a high level through a single resistor if the following conditions are met.Plus formulas that won't copy/paste on P11

author: MK14
author_rank: Super Contributor
timestamp: December 15, 2016, 07:44:19 am
content: Quote from: tautech on December 15, 2016, 07:35:28 amSo to check my understanding, youAGREE, LS devices no longer strictly need the pull up resistor ?(I'm not sure from reading your post).But it may be useful to put them in anyway, so that they continue to be compatible with the original TTL devices, and to improve its ability to cope with short circuits.

author: tautech
author_rank: Super Contributor
timestamp: December 15, 2016, 08:02:32 am
content: Quote from: MK14 on December 15, 2016, 07:44:19 amI agree with the statement you have made for THIS ^^ IC but otherwise I would never make such a generalisation.We've given the OP the correct advice but really he should've just downloaded the datasheetand read itfor the IC being used.Just referring to Absolute Maximum Ratings and Recommended Operating Conditions without looking at the manufacturers recommendations forUnused Inputsis a recipe for a stuff up.RTFMRTFMRTFM................

author: MK14
author_rank: Super Contributor
timestamp: December 15, 2016, 08:15:53 am
content: Quote from: tautech on December 15, 2016, 08:02:32 amIagreewith you.I was partly wrong and may have gone too far. Since there are many LS TTL devices (different 74xx numbers), and use to be a number of different TTL device manufacture's. So it would be risky to generalize it too quickly!I weakly remembered about TTL (in general) needing pull-up resistors. But decided to make a quick and short reply (in the second post of this thread), rather than a complicated/detailed one. Which probably would have mentioned about pull-up resistors.

author: newastrocity
author_rank: Contributor
timestamp: December 15, 2016, 08:58:18 am
content: You guys' discussion has been highly educational, and I really appreciate it. In defense of me needing to RTFM, I was tinkering around with my breadboard late at night while very groggy. I will RTFM before posting again in the future, but in my defense NONE of the logic gate videos I watched on youtube mentioned floating pins whatsoever, I only brought it up because of my own suspicions.

author: rstofer
author_rank: Super Contributor
timestamp: December 15, 2016, 04:26:11 pm
content: Like everything else, it's a little more complicated than 'just use pull-ups'.For UNUSED inputs, pulling LS TTL high MIGHT be optional. But we don't often have unused inputs on NAND gates because if we're just using it as an inverter, there's no reason not to tie the inputs together (other than fan-out).The other reason for pull-ups on inputs connected to switches is to provide enough voltage, and more importantly, current to make the physical switch conduct. Unless we're using gold plated bifurcated contacts, there is always an issue with contact resistance and oxidation. That's why you will often see TTL pull-ups down in the 1k or even 470 Ohm region. Yes, 4.7k is about what it takes to guarantee the NAND is happy but it might take a good deal more current to work the switch.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: December 15, 2016, 08:09:41 pm
content: QuoteIt's all well and good to say that all the information is in the datasheet for us who have read many thousand, but for a beginner they must be daunting. It's hard to pick out the parameters that are critical to you if you're unfamiliar with their layout. It's important to previously know what you can ignore for the moment such as ESD ratings or in the OP's case the entire switching characteristics section so you can focus on matters important to your application. We know it's important to read the wordy bits crammed in under the timing sections and that as soon as you hit the Packaging section you can start tuning out again."How to read a datasheet" I think would be an excellent subject for the Blog; it could be entertaining and informative.Did you notice the "Applications" section in the SN7400 datasheet linked above? I didn't until I wrote this post.

author: rstofer
author_rank: Super Contributor
timestamp: December 15, 2016, 08:56:54 pm
content: Not only are datasheets hard to read but every single number in the document puts some kind of restriction on how the part can be used or how it will respond. Every single number is important and there will be a test later. The good news is that the format is kind of standardized and the nomenclature certainly is. If you know what VIHmeans for one device, you can carry that knowledge forward (mostly).They actually paid people money to write those datasheets (although some must have been overpaid, regardless of how little they received) and it took some amount of talent to get the data for all of the charts and graphs (assuming they are somehow related to reality).Sometimes you just need to sit down with a cup of coffee and cogitate on the meaning of datasheets.

author: tautech
author_rank: Super Contributor
timestamp: December 15, 2016, 09:02:00 pm
content: Quote from: Paul Moir on December 15, 2016, 08:09:41 pmNo I didn't and just checked them.A bit of what's on the first page of datasheets is well.......shall we call it an overview otherwise it might get crude.Back to datasheet info......what else is out there that is easily obtainable and specific to a device ?AN's, no they don't containallthe specific info to implement correct device use, a lot yes but not all.These days it's much better, datasheets often contain a link to App notes where in years gone by you had to hunt for them.Just as use of any device needs understanding so does the reading of datasheets and extracting the info that's relevant to your use. Just another skill an EE need be capable of.Then there's errors in datasheets, I remember a CMOS 4001 sheet had an error, it was a TI one IIRC and that sheet is hard to find now, I'll see if I can hunt it out........Quote from: rstofer on December 15, 2016, 08:56:54 pm