Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to calculate resistor value to drive led using pic16f877a

Status
Not open for further replies.

ramza038

Junior Member level 3
Joined
Dec 27, 2011
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,438
Plz help me. If u know reference material about pic16f877a plz post me.
 
Last edited by a moderator:

All microcontroller have current source/sink limits by the pin, port and device.

These limits are available in the devices datasheet:

PIC16F87XA Datasheet

Reference: PIC16F87XA Datasheet, Section 17.0 ELECTRICAL CHARACTERISTICS, pg 173.

17.0 ELECTRICAL CHARACTERISTICS

Absolute Maximum Ratings †
Ambient temperature under bias................................................................................................................ .-55 to +125°C
Storage temperature .............................................................................................................................. -65°C to +150°C
Voltage on any pin with respect to VSS (except VDD, MCLR. and RA4) ......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS ............................................................................................................ -0.3 to +7.5V
Voltage on MCLR with respect to VSS (Note 2) .................................................................................................0 to +14V
Voltage on RA4 with respect to Vss ..................................................................................................................0 to +8.5V
Total power dissipation (Note 1) ...............................................................................................................................1.0W
Maximum current out of VSS pin ...........................................................................................................................300 mA
Maximum current into VDD pin ..............................................................................................................................250 mA

Input clamp current, IIK (VI < 0 or VI > VDD)..................................................................................................................... ± 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) ............................................................................................................. ± 20 mA
Maximum output current sunk by any I/O pin..........................................................................................................25 mA
Maximum output current sourced by any I/O pin ....................................................................................................25 mA
Maximum current sunk by PORTA, PORTB and PORTE (combined) (Note 3)....................................................200 mA
Maximum current sourced by PORTA, PORTB and PORTE (combined) (Note 3)...............................................200 mA
Maximum current sunk by PORTC and PORTD (combined) (Note 3) .................................................................200 mA
Maximum current sourced by PORTC and PORTD (combined) (Note 3) ............................................................200 mA

Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - Σ IOH} + Σ {(VDD - VOH) x IOH} + Σ(VOl x IOL)
2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up.
Thus, a series resistor of 50-100Ω should be used when applying a “low” level to the MCLR pin rather than
pulling this pin directly to VSS.
3: PORTD and PORTE are not implemented on PIC16F873A/876A devices.

Knowing these maximum limits and the characteristics of the LED, you can then determine an appropriate current limiting resistor:

Current Limiting Resistor Calculator for Leds





LED circuit

BigDog
 

If i used white led as the o/p of pic16f877a,what is the value of resistor. Plz give me exampe. Is Output voltage of power supply considered as source voltage of led?
 

its not a good practice to source or sink LED current into the controller as it will cause heat descipation in controller. instead you can drive LED through transistor using following formula.
Rs=(Vin-Vf-VCEsat)/Iled
where,
Rs - series resistor
Vin-supply voltage(5V)
Vf- forward voltage drop of LED(2.5V)
VCEsat-voltage drop across collector-emitter during saturation(0.2V)
Iled- current required by LED for proper illumination(normally its 20mA)
using above values, we get Rs as
Rs=(5-2.5-0.2)/20=115 Ohms
 

its not a good practice to source or sink LED current into the controller.....

According to whom?

As long as the operating specs of the microcontroller are observed, it is perfectly acceptable to drive one, two or even half a dozen LEDs or other devices directly from the microcontroller.

Yes, if you need to drive an LED matrix or array, then you'll need to consider other methods to drive LEDs.

However, driving a single LED is not an issue as long as an appropriate current limiting resistor is selected.

BigDog
 

Connection between current, voltage and resistance is given by Ohm's law as:
I=(Vcc-Vf)/R
Thus to calculate resistance you need to know supply voltage and diode voltage drop as well as current which results in satisfactory light intensity. Substitute those values into equation and you got answer (you need to solve for R).

If you don't know exact characteristics of LEDs (for example chinese ones from ebay or aliexpress) the fair assumption is Vf=2V for anything but blue and white for which it is roughly 4V. Safe current for most commercial leds I would assume as 5mA.
 

Thz u all for helping me out. :) especially bigdoggurau for his forgiveness.
 


hi Mr. bigdoggureu, i don't say that we can not connect number of LEDs with controller. i am saying that its a bad practice. have you ever considered thermal characteristics of controller?have you ever considered junction to ambient heat transfer rate?we have to consider all these aspects. writing few lines of codes and glowing the LEDs is not enough dude....
 

Hello!

hi Mr. bigdoggureu, i don't say that we can not connect number of LEDs with controller. i am saying
that its a bad practice. have you ever considered thermal characteristics of controller?have you ever
considered junction to ambient heat transfer rate?we have to consider all these aspects. writing few
lines of codes and glowing the LEDs is not enough dude....

Again, if you want to drive a few LEDs, it's not a problem at all. Now you are talking about thermal
characteristics of the controller? Even when driving LEDs, it does not get hot. I made an experiment
recently with 19 LEDs connected to a single controller (I had only 19 LEDs in my drawer) and it works
fine, although I suspect the voltage drops a little bit. I wouldn't do that for a product because it's out
of the maker specs, but it was just an experiment.
Just curious: you design something with a micro controller, you need 3 status LEDs. What do you
do after having "considered all these aspects"?
If the maker tells you that you can drive 200 mA from a port and 20 mA from a pin, it simply means
that you can do it, and you don't need to enter metaphysical meditation, "shall I, shall I not"...

Dora.
 

hi. the current capacities of the controller ports are given in datasheets at room temperature. everything works on bench testing brother. but the problem comes when we insall our device in some industry or factory where the ambient itself is above 35 degrees C.
if the manufacturere is specifying 200mA per port, it means this capacity is at 25 degrees. but when you go on sinking or sourcing this much current through/from micro, its ambient temperature increases due to which the port current capacity of 200mA @ 25 degrees no longer remains valid. so you have to consider the thermal aspects if its not an experiment.
 

In my place arround 32C is common and during summer time its above 39C.
I never have faced any problem to drive PICs or 8051s with current limiting resistors.
what is the port current @32C to 40C.
 

Hello!

Check the specs! Most of the chips are not specified AT 25 degree, but BETWEEN
-40 and +85 degrees celsius. And between -55 and +125 for military components.
And beside this, if the specs tell you that you can draw 200 mA, then you might
think it is safe to power 5 chip less at 10 mA each, don't you think so?

Dora.
 

I know Dora sir. I just wanted to see what the "thermal aspects consideration" beyond "25C" looked like.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top