Shop OBEX P1 Docs P2 Docs Learn Events
Driving two leds from one pin — Parallax Forums

Driving two leds from one pin

ErNaErNa Posts: 1,752
edited 2010-05-31 18:03 in Propeller 1
Hello, I wanted to have two leds, but only had one free pin. So I connected the leds in serial, but took care, the operating voltage is <=3.3V. The output pin is connected via a resistor to the center tab of the diodes. Whenever the pin is tristated, no current flows, when active high, the lower diode is lit, when active low, the upper one. Works quite well.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away wink.gif

Post Edited (ErNa) : 5/29/2010 6:37:24 PM GMT

Comments

  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2010-05-29 11:22
    I've been using this scheme with bi-color led and PWM - changing duty cycle changes color from red through yellow to green
  • RaymanRayman Posts: 14,887
    edited 2010-05-29 12:18
    Brilliant!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-05-29 13:04
    I've used the same trick to make diy dirt-cheap logic probe in the past [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
  • Miner_with_a_PICMiner_with_a_PIC Posts: 123
    edited 2010-05-29 14:22
    ErNa, the same scheme can be used on two outputs driving a piezoelectric element. In this configuration you get much more volume as you can send one line high while sending the other low and visa versa cyclically. You are essentially making a low current H-bridge that doubles the voltage swing (i.e. piezo sees +-3.3V rather than just 0 or +3.3V).
  • ErNaErNa Posts: 1,752
    edited 2010-05-29 15:01
    Yes, thats right and as a piezo seem to be a cap, you can use it in instead of the resistor (maybe) to have enlightening and sound wink.gif . It is also possible to drive the beepers from a motherboard, but take care of flyback voltages. Also it is possible to drive leds and read buttons in a matrix from a minimal number of pins. We should make a box, where this info is collected, could be in OBEX

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
    Hello Rest Of The World
    Hello Debris
    Install a propeller and blow them away wink.gif
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-05-29 15:22
    Hey, that's cool. I might need that ability this week. Thanks for the tip!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-29 16:52
    That's really neat! It's the Prop's 3.3V Vdd that makes it possible. 'Wouldn't work at 5V with any but blue or white LEDs.

    -Phil
  • RaymanRayman Posts: 14,887
    edited 2010-05-29 17:09
    Is there any concern about raising the Vdd rail voltage due to the drop by the protection diodes?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • 10gigbill10gigbill Posts: 79
    edited 2010-05-29 17:28
    Dose anyone know of a multi pin, totem-pole driver chip that could be used
    In this manor to drive higher current/voltage LED’s ?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-05-29 17:33
    'Missed the ">3.3V" part, and I'm mystified why that's necessary. It seems that it would work better with a 3.3V supply

    -Phil.
  • ErNaErNa Posts: 1,752
    edited 2010-05-29 18:38
    Oh, was mistyped! It is just, that the forward voltage of both diodes is less than the supply to have no current when center is not pulled or pushed. Otherwise, a diode in series adds another .7V, if necessary

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
    Hello Rest Of The World
    Hello Debris
    Install a propeller and blow them away wink.gif
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-05-29 22:16
    I couldn't see your link but I only just the other day combined 6 sets of leds this way though I am sure I have done this before as it seems logical. I used a red and a green in series and at 3.3V there was only a bit of leakage current flowing which means that the leds just glow slightly. In the end I put this on to a PIC running at 3.3V off the I2C bus.

    EDIT: attached a schematic of what I mean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*

    Post Edited (Peter Jakacki) : 5/29/2010 10:33:38 PM GMT
    377 x 556 - 9K
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-05-30 02:00
    This article was published in April of 2002 ...

    electronicdesign.com/article/digital/circuit-controls-two-leds-with-one-microcontroller.aspx

    ... and I know for sure this has come up in the forums more than a few times even before then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-05-30 09:02
    ErNa said...
    Yes, thats right and as a piezo seem to be a cap, you can use it in instead of the resistor (maybe) to have enlightening and sound wink.gif . It is also possible to drive the beepers from a motherboard, but take care of flyback voltages. Also it is possible to drive leds and read buttons in a matrix from a minimal number of pins. We should make a box, where this info is collected, could be in OBEX

    The scheme that Miner mentioned involves two pins to drive one piezo whereas this whole thread is about driving two leds with one pin so it should really be another thread. However, the two pin method is very common for capacitive loads such as piezo elements (not active piezo buzzers). Typically piezos need a bit of drive voltage and because of the capacitance should really be driven in push-pull configuration which is what you get when you use two I/O pins in full-bridge configuration.

    As to driving leds and sensing buttons in a matrix with a "minimum" of pins you should look to the charlieplexing threads, start around here:
    http://forums.parallax.com/showthread.php?p=696424

    About the information OBEX I agree, I did look into this a while ago but we need some more input as to how to set it up. I'm thinking of just setting up a Yahoo group just to collect this information but I don't want to shift any forum discussion away from here though, so it requires a bit of thought as to how to do it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • RaymanRayman Posts: 14,887
    edited 2010-05-30 17:06
    I'm sure this idea has been used for a long time...· But, here's why it's better with a Prop:

    1.· Tristate outputs:· Both LEDs can be off.

    2.· 40 mA per pin source/sink:· Both LEDs can be driven at their usual 20 mA average current limit.

    3.· Multicore:· Can easily use a spare cog to have 256 or more brightness levels for each LED.·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-05-30 22:25
    Rayman, I have to take exception to the 40mA per pin because even though you can do it you must remember that it is the ABSOLUTE MAXIMUM RATINGS and that means that this is not the maximum operating ratings. There is ABSOLUTELY no margin for error here and any manufacturer does not guarantee their devices if you are trying to operate at the AMR. This is the rider that Parallax uses:

    8.1. Absolute Maximum Ratings
    Stresses in excess of the absolute maximum ratings can cause permanent damage to the device. These are absolute stress
    ratings only. Functional operation of the device is not implied at these or any other conditions in excess of those given in the
    remainder of Section 7.0. Exposure to absolute maximum ratings for extended periods can adversely affect device reliability.

    Bear in mind too while we are talking about AMRs (for the sake of a better abbreviation) that the Prop has a AMR of 300mA through the Vss and Vdd connection (as one). As the maximum operating current of all 8 cogs at 80MHz is around 100ma then this does not leave 200ma to play with as 300ma is the AMR remember so I wouldn't push more than say 160ma through all the I/O combined.

    In general it is best not to bandy about any AMR figures as if they were operating conditions.

    Also, the other exception I take to is quoting the average current limit of LEDs as 20ma!! Unless I am trying to blind the operator I usually operate in the more sedate but exceedingly bright range of a few mAs. I know that there are D grade LEDs left over from the 70's that might need 20mAs just to glow but they are the exception.

    I'm a bit curious as to your first statement though, aren't all processor I/Os tristateable (except for some 8051 variants etc)?

    Other than "that" smile.gif I concur with your statements.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • RaymanRayman Posts: 14,887
    edited 2010-05-30 23:16
    Sadly, I'm not very familiar with very many other processors...

    But, I have to agree it's best to stay below AMR...

    My main point is that the Prop can drive much higher currents than a couple other chips I've looked at...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • ErNaErNa Posts: 1,752
    edited 2010-05-31 05:58
    There is a word "sufficient". What makes a solution working is just: have plenty of options and take what is needed. Sometimes an old technology is reanimated by new hardware. Some are just forgotten. And then: "reinvented". I never had more than since I use the propeller!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
    Hello Rest Of The World
    Hello Debris
    Install a propeller and blow them away wink.gif
Sign In or Register to comment.