Article View: sci.electronics
Article #1473Correct answers.... (was Re: LED buffer (how?) (was 8051 help needed))
From: Dana H. Myers
Date: Fri, 31 Jul 1992 17:24
Date: Fri, 31 Jul 1992 17:24
50 lines
2917 bytes
2917 bytes
OK, I know I'm setting myself up for a fall here, but I'm going to assert that most of the "answers" about hooking an LED to an 8051 port pin have been only partially correct, and some have been completely wrong. The MCS-51 port pins (with some exceptions) are what Intel refers to as "quasi-bidirectional". What this means, is that they can operate as both an input and output. The way it works, a port pin is essentially an open-drain (open-collector for TTL fans) output with a weak (5k) pull-up resistor to the +5V supply. This is internal to the chip. When the pin is outputting a '1', it is capable of sourcing very little current, and can be used as an input. When the output is set to '0', it is capable of sinking something like 2mA (I don't have the data in front of me). There are some gotchas, however. Port 0 is normally open drain, with no internal pullups. When using external memory with the processor, Port 0 and Port 2 provide the external multiplexed address/data bus, and will use strong internal pullups when driving address/data information. So, where does this leave the gent trying to interface an LED to the pin? Well, if you connect the LED from the pin to ground, it won't light very brightly since the LED current is maybe 750 uA. If you connect it from the +5V supply to the pin (observing correct polarity), it will light with reasonable intensity since the LED current is probably 5-10mA, but, if you connect several LEDs to the processor this way, you could potentially exceed the chip power dissipation rating since each output pin would be good for about 40 mW of dissipation. A good choice is to use a common emitter NPN transistor buffer for the LED, as previously suggested. However, you do not need a resistor in series with the base, since the 8051 will drive the base through a 5k resistor. Also, I'd suggest using a 330 ohm resistor to limit the LED current to 10 mA. If you prefer a brighter LED, you could use a 150 ohm resistor giving about 20 mA of current. The transistor could be a 2N2222, but any general purpose plastic part will do (2N3904 or MPQ3904, for example). Good luck. -- * Dana H. Myers KK6JQ | Views expressed here are * * (213) 337-5136 | mine and do not necessarily * * dana@locus.com DoD #466 | reflect those of my employer * * "Dammit Bones, spare me the lecture and give me the shot!" *
Technical Details
Message-ID:
<1992Jul31.172417.2859657@locus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!orchard.la.locus.com!devnet.la.locus.com!danaReferences:
<1992Jul30.181542.19932@uwm.edu> <l7h4kiINN6vs@appserv.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Newsgroups: sci.electronics Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!orchard.la.locus.com!devnet.la.locus.com!dana From: dana@locus.com (Dana H. Myers) Subject: Correct answers.... (was Re: LED buffer (how?) (was 8051 help needed)) Message-ID: <1992Jul31.172417.2859657@locus.com> Organization: Locus Computing Corporation, Los Angeles, California References: <1992Jul30.181542.19932@uwm.edu> <l7h4kiINN6vs@appserv.Eng.Sun.COM> Date: Fri, 31 Jul 1992 17:24:17 GMT Lines: 50