Continue to Site

can i connect LEDs directly to the 80c51 output port??

Status
Not open for further replies.

karo89

Newbie level 5
can i connect LEDs directly to the 80c51 output port??

You need to look at the data sheet of your 80c51 variant in the elctrical specifications.
That should tell you what current the port you intend to use can source or sink.
And of course, a led being a diode, needs a series resistor to limit the current.

The resistor value can easily be calculated.
If you are using a 5 volt rail, assume the led drops 1.2 volts and you want a 10mA current.

R = (5 - 1.2) / .01;
R = 3.8 / .01;
R = 380;

Resistor = 390 Ohms nearest preffered value.

mayurs

mayurs

Points: 2
thank you
the output current of the port is 15mA

Then that should by ok.
You can get low current leds that only require ~3mA.

the o/p current capabilty is it per pin? or is it total?

In practically you can connect one led to test.

karo89

karo89

Points: 2
I think you need to write some code i.e LED ON/OFF..
If you connect direct LED to 80c51 it may not glow so write some necessary code and interface with LED...

And note that when the output is 15 mA the voltage will not be 5 and 0 , you will have a voltage drop/rise (output will be lower than 5 and higher than 0)
There should be a graph in the datasheet of your mcu that shows the output voltage vs output current.

Alex

---------- Post added at 15:35 ---------- Previous post was at 15:32 ----------

I think you need to write some code i.e LED ON/OFF..
If you connect direct LED to 80c51 it may not glow so write some necessary code and interface with LED...

He is not asking if he should write a code, he is asking if he should use some kind of led driver like a transistor or if he can connect the LED directly to the pins of the mcu.

Alex

karo89

karo89

Points: 2
even if he want to connect LED to mcu he need some circutry,right?

If the mcu can provide 15mA like he says (per pin) it will be more than enough to drive a led which is usually driven with 10mA, only a resistor is needed.
As long as he doesn't exceed to total output current limit for the mcu (using many leds turned on at the same time) it would be fine

Alex

my doubt is why this 8051 has low power, while pic has enough power to switch a led on. When i tried it in a 8051 i need to use a transistor switch.

If the OP can provide a specific datasheet of the device he uses we will able to talk with facts.
The specification of each device or mcu type (AVR,PIC, ARM etc) is different , it's up to the manufacturer.

Alex

yes it provide 15mA per pin
When connected through the resistance(330ohm) be very faint lighting and has a link without resistance to be somewhat better lighting
What do you think?

then at that current the voltage is so low.
what controller you are talking about ? type number ?

any controller requires a buffer to drive .
on its port pin at such current level.

---------- Post added at 15:44 ---------- Previous post was at 15:42 ----------

though you have indicated 80c51 , my question is, whether you have any particular manufacturers ic.
(this is what i mean by , what controller you are talking about ? type number ?)

NEVER use the led without the resistor, you will damage the mcu output.
You led will probably have a Vf of 2.2 (green I suppose) and the mcu voltage will not be 5v but lower so you have to use the correct values to calculate the resistor.
If it is too high it will limit the led current too much, if it is too low you will have a big voltage drop on the mcu output so the light will be low.
Also some mcu can sink more current than they can source, that means that if you connect the cathode to the mcu you may get better results.

In any case please provide a link to the datasheet so we can do the proper calculations.

Alex

my microcontroller is atmel 89C51

for atmel 89c51 , it is max current at 'o' level.
and max current at that level for all pins permitted is 70mA.
the controller draws a current of 20mA.

so , what you said as per pin is a misunderstanding of datasheet.

at any cost , you require a buffer , if you want to turn on led at 1 level.

You mcu ports are open drain/collector with internal pull-ups for port1,2,3 and without pull-ups for port0.
They outputs can't provide any current at the high state, they can only sink current (provide ground) at the low state.

Note 1 in the datasheet says

Under steady state (non-transient) conditions, IOL must be externally limited as follows:
Maximum IOL per port pin: 10 mA
Maximum IOL per 8-bit port: Port 0: 26 mA,Ports 1, 2, 3: 15 mA
Maximum total IOL for all output pins: 71 mA

If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test conditions.

Maybe you can get away with one led at about 8mA (driving the cathode with the mcu, will light with logic 0) and only one led in the port but it would be better to use a transistor to drive the led and be able to use the led with a higher current.

Alex

As for as LEDs are concerned two things you have to notice it...
1) Minimum Biasing Voltage
RED colour LED [R] -> 1V
GREEN colour LED [G] -> 1.2V
YELLOW colour LED [Y] -> 1.5V

2) Current Rating
For Normal LED [Translucent] -> 10mA
For Transparent LED [High Intensity] -> 2mA

If the output current of microcontroller is high [say 15mA], then You can connect translucent LED directly to controller or if it is less [say 5mA], then High intensity LED connect directly to controller [Both the cases current limiting resistor should be must]...

There is proper method to calculate the current limiting resistor too...

R = [Vin - Vled] / [Iled] ohm

thanks
iam very grateful to you

---------- Post added at 16:42 ---------- Previous post was at 16:21 ----------

You mcu ports are open drain/collector with internal pull-ups for port1,2,3 and without pull-ups for port0.
They outputs can't provide any current at the high state, they can only sink current (provide ground) at the low state.

Note 1 in the datasheet says

Under steady state (non-transient) conditions, IOL must be externally limited as follows:
Maximum IOL per port pin: 10 mA
Maximum IOL per 8-bit port: Port 0: 26 mA,Ports 1, 2, 3: 15 mA
Maximum total IOL for all output pins: 71 mA

If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test conditions.

Maybe you can get away with one led at about 8mA (driving the cathode with the mcu, will light with logic 0) and only one led in the port but it would be better to use a transistor to drive the led and be able to use the led with a higher current.

Alex

what do you mean by sink current?

Status
Not open for further replies.