Sinking current from 9V into a PIC pin.


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    Quote Originally Posted by sayzer View Post
    ...
    You will see that LED will not fully turn OFF.
    ....
    Quote Originally Posted by HankMcSpank View Post
    The LED *does* turn off ! (ie the PNP tranny is working as I intended/required - real world, not simmed or theorized!) .....
    Quote Originally Posted by HankMcSpank View Post
    ... I've actually got 5V going to the PNP emitter (not the 9V I thought was on there).

    Just to prove the point...I put 9V on the emitter...the PIC lived, but the LEDS didn't turn off when the duty cycle went to 255.

    ....
    Hello there....

    I was going to ask you to measure the voltage on the emitter. But you already had it.

    And for the idea of yours, you have a pwm pin and also LED pins.
    And you are trying to show the voltage level, as much as I understood.
    So, as the voltage drops, you want to show it with the LEDs.
    Say, if the voltage is 8V, you have one LED off. Am I right? or something like it.
    But, why are you using PWM then?
    Can you explain more?
    How the pwm and the LEDs will work?
    Last edited by sayzer; - 23rd March 2011 at 07:34.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    Hi Sayzer,

    I'm just learning about driving LEDs & PWM here.

    I want to be able to have numerous LED patterns (hence the individual PIC connections to the LEDS, but also a 'common' dimming ability (hence the PWM to the, tranny controlling the supply to all the anodes).

    What I was ideally after was to connect the 'common' supply (controlled by the transistor) for all the LED anodes to 9V. This would save some heat losses, whereby the 9V gets regulated down to 5V first, & then feed the anodes.

    the problem of course with using an unregulated power source, is that when the voltage starrts drooping (as the battery life fades), then the current through the LEDS will be less.

    9V battery = plenty of LED brightness
    7.8V battery = less LED brightness.

    My idea was to monitor the voltage level of the battery within the PIC and then have an adjustable PWM ' maxceiling' to suit, therefore....

    Fresh 9V battery = PWM value of 220 *max*
    7.8V battery = PWM value of 255.

    In other words I get the PIC to regulate the 'effective' voltage as presented to all the common anodes based on the battery voltage its monitoring.
    Last edited by HankMcSpank; - 23rd March 2011 at 09:34.

  3. #3
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    This application calls for a transistor to operate in it's linear region, and not as a switch.
    Use an NPN transistor. The base gets connected directly to RC5, The collector to 9V and the emitter to the LED Anodes. This will accomplish your objective of having the current come directly from 9V instead of your small regulator. The NPN effectively becomes a regulator as it's emitter will be either a diode drop below 5V (4.3V or 4.4V) when RC5 is high, or 0V when RC5 is low.
    The voltage across the transistor when it's on will be 9V - 4.3V = 4.7V Multiply this by the current flowing to get the power dissipated by the device, and if it is too high, then choose a resistor, based on the maximum current, and put it between the collector and 9V to move some power out of the transistor and into the resistor. (I doubt you will need to do this).
    As a side note, the LED will maintain brightness down to about 6V without any adjustment of pulse width, so if this is the only reason for the PWM then you could connect the base directly to 5V instead of RC5. However, left at RC5 you can still dim the LEDs for aesthetic reasons, and power savings.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    Quote Originally Posted by Charlie View Post
    The voltage across the transistor when it's on will be 9V - 4.3V = 4.7V Multiply this by the current flowing to get the power dissipated by the device, and if it is too high, then choose a resistor, based on the maximum current, and put it between the collector and 9V to move some power out of the transistor and into the resistor. (I doubt you will need to do this).
    So in essence, I'm moving the 9V->5V 'conversion heat' dissapation from the regulator, directly to the tranny controlling the LEDs?

    Perhaps I'd be better just upping the spec of the regulator?

    I guess what I was shooting for was the most battery friendly way of driving six LEDs from 7.5V thru 9V, and in my simplistic world I thought that avoiding regulating the 9V down to 5V (direct heat loss), and using PWM to switch the tranny on/off would be the way to go!

  5. #5
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    You can certainly use a higher rated regulator, although splitting current into 2 devices to share power load is pretty standard practice and not at all bad form - especially if increasing the regulator current would drive you to a heat sink! However, using the PWM to dim the LEDs will still save power if you keep the transistor in the circuit. Your intent was to make them the same brightness as the voltage dropped, which won't be necessary. But you could instead make them 1/2 brightness all the time with the PWM - and save 1/2 the power. Or any other ratio you choose.

  6. #6
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Sinking current from 9V into a PIC pin.

    Hi Hank,
    Hope this may assist you. In such matters I tend to use and optical isolator which has 2 LED's and transistors in one 8 pin package such as the NTE3086.

    Best, Ed

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