Sei sulla pagina 1di 4

Using an NPN transistor to drive multiple LEDs from a PIC microcontroller output

http://picprojects.org.uk
Supply voltage

V is the power supply voltage


Vf is the LED forward voltage
If is the LED forward current

Rled =

V - Vf
If

Vf

V is the power supply voltage


Vf is the LED forward voltage
n is the number of LEDs in series
If is the LED forward current

Rled = V - ( n x Vf )
If

Vf
Vf

Vf

To PIC 1K

To PIC 1K
Driving a single LED

To PIC 1K

Connecting multiple LEDs in series

The configuration above can be used when


the number of LEDs in series would be
greater than the supply voltage. Try to work
with a margin of 1 volt or greater between the
supply and the total LED forward voltage.

The supply voltage should be a regulated DC source.


When connecting multiple LEDs in series, the number of LEDs must be such that the sum
of their forward voltages is less than the supply voltage otherwise they cant operate.

How to calculate the value for the LED current limiting resistor
Supply voltage

V is the power supply voltage


Rled is the current limit resistor value

V
Rled =

(V - Vf )
If

Vf is the LED forward voltage


If is the LED forward current
These parameters should be taken from the datasheet for the
specific LED being used. If this isnt available you will need to
measure the forward voltage (see below)
You cant measure the forward current so if you dont know it you
should work with a value of 15mA

To PIC
1K

Example

(10 volts 2 volts ) = 533 ohms


0.015amps

Resistors come in standard values, pick the nearest higher standard


value to the one calculated in this example it would be 560 ohms

How to calculate the power rating for the LED current limiting resistor
The larger the difference between the power supply voltage and the LED forward voltage, the more
power the LED current limiting resistor has to dissipate. The resistor used must have a power rating
greater than the power it will have to dissipate. This is calculated as shown here

Pwatts = If x If x R

Example (0.015 amps x 0.015 amps x 560 ohms = 0.126 watts

How to measure the LEDs Forward Voltage (Vf)


If you dont have the datasheet for the LEDs you plan to use, or just
want to check the actual forward voltage you can measure it using
the test circuit shown here. Make sure the LED is illuminated and
then measure the voltage across the LED with a voltmeter.
The forward voltage for a standard red, yellow and green 5mm LEDs
will be around 1.8 Volts to 2.2 Volts. For high brightness LEDs it will
typically be 3 volts to 4 volts.

+5 volts
150R

1999
Vdc A
Vac

Using an NPN transistor to drive multiple LEDs from a PIC microcontroller output
http://picprojects.org.uk
Transistors
Since standard 3mm, 5mm, 8mm and 10mm LEDs only require around 15mA to operate,
we can use a small NPN transistor to drive them.
Some transistors that are suitable for use in LED driving applications are listed below.
The Ic (collector current) max value is an absolute maximum and operation at or near to
this value should be avoided. For the full specification of each transistor consult the
manufacturers datasheet for the specific device.
Device
2N2222A
2N3053
2N3704
2N3705
2N3904
2N4401
BC107
BC108
BC109
BC182
BC183L
BC184
BC237
BC238B
BC337
BC546
BC548
BC549
ZTX457

Ic max (mA)
800
700
600
600
200
600
200
200
200
100
100
100
100
100
500
100
100
100
500

Current here is
LED string1 If

To PIC
1K

Current here is
LED string2 If

Current here is:


LED string1 If + LED string2 If

Where one transistor is used to drive LEDs in


the arrangement shown, the transistor will be
passing the sum of the current in all the
parallel strings of LEDs

High Power LEDS


This document has described how to drive multiple high brightness, low power LEDs.
High power LEDs, such as those manufactured by Cree, Luxeon etc work in the same way as
small LEDs and the calculations for current limit resistor and forward voltages can still be used.
However, the power dissipated is much greater which in turn requires power transistors or better
still N channel MOSFETs along with high wattage resistors. Managing the heat and the physical
size of components can be an issue.
Ideally rather than using the passive current limiting described in this document some type of
active current regulator should be employed. This is beyond the scope of this document.

Examples
http://picprojects.org.uk

12 Volts

LED parameters
Vf = 3.2 volts
If = 20mA

Calculate value for R


12 volts ( 3 x 3.2 volts)
20mA

2.4
0.02

= 120 ohms

Calculate power rating for R


20mA x 20mA x 120 ohms = 0.048 watts
To PIC

In this case we can use a standard 120 ohm


resistor with a power rating of at least 0.125 watt

1K

5 Volts

LED parameters

Vf = 2.1 volts
If = 15mA

Calculate value for R


5 volts ( 2 x 2.1 volts)
15mA

0.8
0.015

= 53.3 ohms

53.3 ohms isnt a standard value so well use 56 ohms

Current through
transistor is
2 x 15mA = 30mA

Calculate power rating for R


To PIC

15mA x 15mA x 56 ohms = 0.126 watts

1K

Use a resistor with a power rating of at least 0.25 watt

9 Volts

LED parameters

Vf = 1.8 volts
If = 35mA
Calculate value for R
9 volts 1.8 volts
35mA

7.2
0.035

= 205 ohms

205 ohms isnt a standard value so well use 220 ohms


Calculate power rating for R
To PIC
1K

35mA x 35mA x 220 ohms = 0.269 watts


Use a resistor with a power rating of at least 0.5 watts

Driving LED Arrays using PIC microcontroller


picprojects.org.uk

Vin

Calculate Rled

Rled

Rled

Rled

Rled

Rled

Rled

Rled = ( Vin - Vfled x n)


Ifled
Vin = 12 volts
Vfled = 3.3 volts
Ifled = 20mA
n = number of LEDs in series
Rled = ( 12 3.3 x 3) = 105R
0.02

Each column of LEDs needs its


own series resistor.
Never do this

Use nearest E12 resistor = 100R


10R
100K

to PIC i/o pin

N channel logic level MOSFET

Power rating for the resistor

e.g. STP36NF06L

Power = Ifled2 x Rled

Note: Must be a logic level MOSFET

0V
Vss
Gnd

Ifled = 20mA
Rled = 100R (from calculation above)
Power = 0.022 x 100 = 0.04W
Here you could use an 1/8W or 1/4W resistor

Notes:
MOSFETs require a minimum voltage at the gate terminal to turn on.
Logic level MOSFETs are designed to operate with a gate voltage of
5 volts. Standard MOSFETs will generally operate with 5 volts on the
gate terminal but may not be able to handle higher currents. I
recommend that if you are buying MOSFETs to build a driver buy a
logic level version.

Example for a 350mA power LED with 12R


resistor
Ifled = 350mA
Rled = 12R
Power = 0.3502 x 12 = 1.47W
This would require a 2W resistor

Power supply current (example)


The input voltage Vin needs to be a regulated DC voltage. If you are
using a power source that can / will vary then you should calculate
the value of the current limiting resistors using the worst case
(highest) voltage.
e.g. For use with a 12V automotive system, use a value of 14.5V Vin
when calculating the resistor values.
The 100K gate pull-down resistor ensures the MOSFET is turned off
when the circuit powers up. At this time the PICs I/O pins are
configured as inputs, without the resistor the gate will float and the
MOSFET will start to turn on.

3 LEDs per column, 33 columns = 99 LEDs


99 x 20mA = 1.98amps
Make sure Vin Power Supply and MOSFET Ids are
suitably rated.

E12 Resistor values from 10R to 820R


10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82
100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820

You can use two resistors in parallel to get


a value between two E12 values.
e.g. two 270R resistor in parallel are equivalent to a single
135R resistor

= 135

135

270

270

270

Potrebbero piacerti anche