Driving LED

Bond

New Member
Im a bit new to this
I am using a picaxe 14M2

I have connect a 330 resisted and a LED down to ground on a PMW pin
I can control the brightness by adjusting the PMW no problem

but am struggling to under stand how much current is going to be pull though the chip

I only get about 2.5 volts out off the pin so it appears to be using around 9ma (I was expecting it to be near to 15ma)?

I am trying to work out the best way to add as many LED on 1 pin with out blowing up the chip

can anyone explain the best way to do this (at what point should I be look at using a driver circuit? (I really what to keep to the least amount of components possible)
 

hippy

Technical Support
Staff member
Rich (BB code):
Vpwm >---.   ---.
        .|.     |
        |_|     | Vr
         |      |
         |   ---{       Vpwm = Vr + Vfwd
        _|_     |
       _\ /_    | Vfwd
         |      |
  0V ----^-- ---'
With the PICAXE on a 5V power supply Vpwm will be 0V or 5V.

The LED will have a Vfwd voltage which depends on the LED type and colour. For a typical LED this will be -

1.6V to 2.0V (1.8V) - Red
2.0V to 2.1V (2.0V) - Orange
2.1V to 2.2V (2.1V) - Yellow
1.9V to 4.0V (3.0V) - Green
2.5V to 3.7V (3.1V) - Blue
2.5V to 3.7V (3.1V) - White

The voltage across the resistor, Vr will be Vpwm - Vfwd.

For a typical red LED: Vr = 5V - 1.8V = 3.2V.

The current through Vr will be Ir = Vr / R.

For a 330R and Vr of 3.2V: Ir = 3.2V / 330R ~= 10mA

Because current is constant through the circuit, Ipwm = Ir. So ~10mA will be drawn from the PWMOUT pin.

That's the current when Vpwm is high, but the average when it is switching high and low will proportionally reduce. When on for half the time the current will be half what it is when it is always on.

A peak current of ~10mA is perfectly acceptable for drawing through a PICAXE pin so you shouldn't need a driver of any kind, just the current limiting resistor.

You may be able to increase that from 330R and still have acceptable brightness which will lower the current if you do wish to minimise it.

Note the maths above is something of a simplification because Vfwd can vary with the current through the LED which depends on Vpwm and R. Actual Vpwm also varies depending on the amount of current drawn. But it's good enough to give a ballpark figure.
 

depeet

New Member
Altough not completely correct, you don't measure the full 5Volt on a PWM pin. You are actually measuring an average voltage that would depend on the PWM-rate. If you connect a LED in serie with a resistance, you will only measure the drop voltage over the LED. This voltage depends on the material used in the LED to obtain a certain colour as what hippy already mentioned.
 

Attachments

Hemi345

Senior Member
I am trying to work out the best way to add as many LED on 1 pin with out blowing up the chip
I think you'll want to use a logic-level n-channel mosfet connected to the single picaxe pin to do what you want. A resistor from V+ to each Led then tie all cathodes to the source on the mosfet which will drive them to ground when on. That will only add two extra components, the mosfet and a high value pulldown resistor (100K) to help turn the mosfet off during pwm cycles.
 

Hemi345

Senior Member
Do you mean Drain, with Source to 0V?
Oops, yes, you are correct. I typed that on my phone - I shouldn't do that because I always make mistakes!

I was thinking something along the lines of this:


The gate on the MOSFET would be tied to a pin on the PICAXE.
 
Top