Drive an LED direct from a PIC IO pin (ie no current limiting resistor)


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    Still mulling my options here.

    Here's the conundrum....I want to be able to run upto 12 leds off either AA - or more likely AAA - batteries. It's be cool if I could use rechargeables.

    Therein lies a problem....3 x 1.2V is 3.6V ....an LDO would be no good here (they normally have a drop out voltage of about 0.8V.....meaning with 3 batteries the max I could expect to get regulated is about 2.7V (& that's with fresh batteries!)

    I could up the battery quota to 4 batteries, but I'm really pushed for space...so I'd like to stick with 3 x 1.2V batteries (or 2 x 1.5V batteries)

    Ok, blue LEDS ....yep, they normally have a forward voltage quoted around the 3.4V mark....having measured the batch I have, the current through 'em at that particular voltage is about 20mA. I actually want to 'under volt' them....the blue LEDs I tested only pull about 10-12mA at around 3.1V....but they're still plenty bright.


    So here's what I was thinking....

    use a 'LF' PIC variant, supplied by battery but the PIC gets it's supply via low quiescent current 2.5V regulator.

    Drop the unregulated battery supply via a two resistor divider, so that the max that can be seen at the PIC ADC pin from the resistor the junction feeds is 2.5V.

    So for example.....3 x normal AA batteries (fresh @1.6V initially), would mean 4.8V unregulated.....so eg use two resistors R1 2.3K, R2 =2.5K.

    Ok, now with fresh batteries, there'll be 2.5V at the junction....feed this into a PIC, ADC it, now use a LUT....

    If the PIC's ADC reading is 255, then the duty cycle (to the leds) should be 168 (66%)...therefore the effective voltage the LEDS 'receive' is 3.1V (4.8V x 67%)

    Ok, now the batteries drop after usage, let's say they now amount to 3.8V in total ...this would read as an ADC value at the pic pin of 201, the duty cycle to the LEDs is 211 83%,so what I'm proposing is a simple lookup

    if ADC value = 255 the duty_cycle = 168
    if ADC-value = 201 then duty cycle = 211

    & all values in between.

    Or is there an LED driver IC (or an inductorless buck converter ....as inductors don't work well in guitars) to save me the bother? (to recap, I don't want to lose the 'spare/excess' voltage as wasteful heat (ie via a linear regulator)....but rather use PWM to 'manage/massage' the effective voltage that the LEDs ' receive'

    (yes I know leds are current devices, but there's a good correlation between voltage applied across them & current they draw...also, again, I'm going to be underpowering them)
    Last edited by HankMcSpank; - 19th May 2011 at 21:37.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    You get the idea.

    Look Melanie Dice example, or do it simple, plug your LED directly to the PIC and have a PWM running out of your PIC, use a MOSFET to drive the common GND or VDD of your LED (whatever floats your boat).

    You now have a variable intensity, using a minimum of parts... BUT, the more the battery get flatten, the less intensity you'll also have (assuming you don't use anything to monitor it... and if so... you end up with more extra hardware than a simple LDO regulator)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    Quote Originally Posted by mister_e View Post
    You get the idea.

    Look Melanie Dice example, or do it simple, plug your LED directly to the PIC and have a PWM running out of your PIC, use a MOSFET to drive the common GND or VDD of your LED (whatever floats your boat).

    You now have a variable intensity, using a minimum of parts... BUT, the more the battery get flatten, the less intensity you'll also have (assuming you don't use anything to monitor it... and if so... you end up with more extra hardware than a simple LDO regulator)
    This is exactly the setup I'm proposing....use a transistor to control the 'effective' voltage the LEDSs 'see'. But for monitoring, I'll use a spare ADC pin on the PIc to monitor the unregulated supply voltage....and then adjust the PWM to the LEDs accordingly.

    The problem with using an LDO regulator, is they're very inefficient.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    I would suggest to use a Mosfet with a decent small Rds, this way you could/should loose less voltage across than a regular BJT.

    Add a small value resistor between the MOSFET source and GND, put a cap on it, feed it to the ADC and voila you monitor the current.

    Tons of way to do it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    Quote Originally Posted by mister_e View Post
    I would suggest to use a Mosfet with a decent small Rds, this way you could/should loose less voltage across than a regular BJT.

    Add a small value resistor between the MOSFET source and GND, put a cap on it, feed it to the ADC and voila you monitor the current.

    Tons of way to do it.
    All good stuff there....have you any example of suitable mosfets you've used in the past? (just to give me a general vibe of the spec - I'm ideally looking for something in a SOT23 package)

    Edit: Hmm: I'm thinking here that I'm only going to be switching 3.3V across the leds - do mosfets work ok that low (all the ones I'm seeing on digikey are typically 20V VDS or more ...ok so that's a max figure, but never having used modfets, are they ok with switching 3.3V well)
    Last edited by HankMcSpank; - 20th May 2011 at 10:23.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    Yish, me and remembering Mosfet Part # are two different animal

    I would say go on Digikey website, type Mosfet SOT23, then shop by max current and Rds.

    How much current you'll need?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    And don't forget to check the datasheet... Vgs...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Drive an LED direct from a PIC IO pin (ie no current limiting resistor)

    Quote Originally Posted by mister_e View Post
    Yish, me and remembering Mosfet Part # are two different animal

    I would say go on Digikey website, type Mosfet SOT23, then shop by max current and Rds.

    How much current you'll need?
    Not much....8 possibly 12 leds....ay about 15mA each max ....say 180mA, I'll have a sniff on Digikey.....


    Edit: Hmm: I'm thinking here that I'm only going to be switching 3.3V across the leds - do mosfets work ok that low? (all the ones I'm seeing on digikey are typically 20V VDS or more ...ok so that's a max figure, but never having worked with MOSFETS previously, are they ok with switching 3.3V well)
    Last edited by HankMcSpank; - 20th May 2011 at 10:24.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts