Connect with us

Driving red/green LED from high/low/tri-state output

Discussion in 'Electronic Basics' started by Joel Kolstad, Mar 6, 2007.

Scroll to continue with content
  1. Joel Kolstad

    Joel Kolstad Guest

    I have a battery charger IC that tells you the IC's function via a "staus" pin
    output that's one of three states: Hi-Z when a battery isn't present or is too
    hot or cold to charge, high when it's actively charging, and low when it's
    finished charging. I'd like to convert this signal to drive two LEDs, red and
    green (they're actually both in one package, but all 4 pins are accessible).
    The idea being that Hi-Z=>off, high->red (charging), and low->green
    (finished). What's the easiest way to do this? So far I haven't thought up
    any easy schemes... and my first -- now obviously dumb -- approach of
    connecting the pin to the two LEDs connected back to back -- with current
    limiting resistors -- doesn't work in that a Hi-Z output just causes both LEDs
    to glow dimly!

    There's gotta be some really easy way to do this?

  2. Joel Kolstad

    Joel Kolstad Guest

    I think I know how to do this... just tie both ends of the LEDs together
    (making a "2 pin" bi-color LED), drive one end from the status pin, the other
    from a voltage divide formed by 2 resistors, nominally the same values for the
    same current for both red and green, or somewhat different values to vary it.
  3. Randy Day

    Randy Day Guest

    Two more resistors and two transistors?

    V led +v
    - |
    | |
    in | _R_ |<
    | | |\
    | .-. |
    | | |R .-.
    | | | | |R
    | '-' | |
    | | '-'
    | _R_ |/ |
    -|___|-| V led
    |> -
    | |

    (created by AACircuit v1.28 beta 10/06/04
  4. DJ Delorie

    DJ Delorie Guest

    Alternate idea: Connect a resistor from the status line to each of gnd
    and vcc. Use two comparators to compare this three-voltage state with
    1/3vcc and 2/3vcc. This gives you two comparator outputs to work

    I'm doing this in my furnace controller, except in my case I'm using
    it as a tri-state booster.
  5. DJ Delorie

    DJ Delorie Guest

    I've tried this before. Base leakage current is sufficient to keep
    both transistors on when tri-stated. I've even tried putting
    resistors between the bases, like your drawing. Didn't seem to help;
    high enough values to stop the leakage were too high to let the signal
    activate the transistors.
  6. Randy Day

    Randy Day Guest

    Oops. Duh... <smacks forehead>

  7. Put your Leds anode to cathode, one end of the pair to the IC and the other
    to the middle of a voltage divider made by two 500R resistors. It wastes
    power all the time ([email protected]) but then so do the LEDs. ;-)
  8. Chris

    Chris Guest

    Hi, Joel. Assuming both the green and red LEDs have a forward voltage
    drop of around 1.7V, and also assuming your tri-state output can
    source or sink 8mA, you should be able to get what you want with this
    fairly inelegant but workable solution (view in fixed font or M$

    | VCC
    | +
    | |
    | G V ~
    | - ~
    | |
    | D V
    | -
    | |
    | D V
    | -
    | |\ ___ |
    | -| >O--|___|-o
    | |/ 270 |
    | D V
    | -
    |D = 1N4148 |
    | D V
    | -
    | |
    | R V ~
    | - ~
    | |
    | ===
    | GND
    (created by AACircuit v1.28.6 beta 04/19/05

    The forward voltage drops of the two LEDs plus the four small signal
    diodes will be at least 5.8V. If your supply voltage is 5V, that will
    keep the LEDs from turning on when the output is tri-stated.

    The 270 ohm resistor will lead to a little less than 8mA being driven
    through only one of the LEDs when the logic gate is on. That should
    be plenty for high intensity LEDs.

    Make sure to look for red and green LEDs with similar typical forward
    voltages. If the red is still brighter than the green, you may want
    to place a small resistor in series with the red LED to balance.

    Good luck
  9. jasen

    jasen Guest

    you're so close to the answer....

    | This is an ascii schematic, if the diagram appears garbled |
    | try switching to a fixed-pitch font (courier works well) |
    | pasting it into notepad works well on ms-windows. |
    | or in google groups "view source" (found under options) |

    in ---+--|<----+--[RX]--- +v
    | |
    | |
    +--->|---+--[RX]--- gnd
  10. Joel Kolstad

    Joel Kolstad Guest

    Thanks to everyone for their solutions; I've learned a lot. I am using the
    approach that Jasen suggested, and it's working well. I have power to burn
    here, but if I didn't, I think I'd go with Chris's solution. I'd have a hard
    time convincing myself to use a comparator, although that seems like the
    least-kludged approach.

    I can see now why people sometimes use one of those 6 pin PICs or 8 pin AVRs
    to do little more than flash an LED...!
  11. JeffM

    JeffM Guest

    That used to work.
    "view source" is no longer available.

    **Show original** still works.
  12. One of the cheaper, at Digikey, is the PIC10F200. $1 in ones, half
    that in 25's. You could even set it up to handle the three states
    differently, on those two LEDs, say blinking the red when nothing is
    in the charger, setting it solid red when charging, and green when
    done. All with no additional parts if your voltage supply rail is in
    range, except possibly the two current limit resistors -- which is
    only a maybe, as the output drive may self-limit acceptably. Of
    course, you need the means to program the thing. So there is a big
    advantage to the discrete approach, if you don't have the tool setup
    in place. Much easier to make such choices, if you are ready to go,

  13. Joel Kolstad

    Joel Kolstad Guest

    Good point. For copmarison, ATTiny11's are $0.54/1, $0.41/25, $0.38/100 from
    DigiKey. I'd imagine that if you're buying, say, 1,000? 10,000? Microchip will
    happily compete with those prices, however. I also imagine that, in that sort
    of quantities, you could get your favorite distributor to pre-program the
    parts for you, which would be even better.

  14. Yes. I haven't used the ATTiny11 yet or the PIC10F200, so I cannot
    speak to either. I'd need to check the data sheets to see what
    differences may be useful to know about (packaging, oscillator, power,
    peripherals, etc.) But I note that the prices at 25-qty are quite
    similar. Close enough to warrant a close datasheet look, I suppose,
    if I get serious about buying one or the other for 'bubble gum' part
    purposes. (I usually keep two processor types in tubes, around here,
    for that and shift to new ones when the old stuff runs out.)
    I can only hope my hobby interests ever rise to that level of
    purchase. ;)

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day