Shop OBEX P1 Docs P2 Docs Learn Events
Bicolor LED driver — Parallax Forums

Bicolor LED driver

DynamoBenDynamoBen Posts: 366
edited 2014-12-06 11:59 in General Discussion
I'm working on a project where I need to independently control 8 bicolor LEDs via I2C (LEDs are in some switches). I'd like to be able to dim them via PWM and not lose amber (Red and Green together). Normally I would use a PCA9685 but I'm not using discrete red and green LEDs this time around. Any thoughts on something similar that might get the job done or a way to pull this off with the PCA9685?

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-12-05 18:03
    DynamoBen wrote: »
    I'm working on a project where I need to independently control 8 bicolor LEDs via I2C (LEDs are in some switches). I'd like to be able to dim them via PWM and not lose amber (Red and Green together). Normally I would use a PCA9685 but I'm not using discrete red and green LEDs this time around. Any thoughts on something similar that might get the job done or a way to pull this off with the PCA9685?

    I would be more inclined in new designs to just use WS2812 NeoPixel LEDs as they are cheap (perhaps cheaper than bicolor+I2C) and you can run them from the one I/O.
  • DynamoBenDynamoBen Posts: 366
    edited 2014-12-05 18:47
    I would be more inclined in new designs to just use WS2812 NeoPixel LEDs as they are cheap (perhaps cheaper than bicolor+I2C) and you can run them from the one I/O.

    These are LEDs in existing switches so neopixels are out. Sorry. I2C is a requirement because I'm pairing it with a port expander to read the switches.
  • Buck RogersBuck Rogers Posts: 2,185
    edited 2014-12-05 19:21
    DynamoBen wrote: »
    These are LEDs in existing switches so neopixels are out. Sorry. I2C is a requirement because I'm pairing it with a port expander to read the switches.

    Hello!
    DB, who makes these switches? Not too long ago NKK released a series of switches that contain an RGB LED set and an appropriate switch. One enterprising pair of chaps built a Simon style game using one switch and an Arduino type controller. The resulting game was, they think, rather pleasing and even interesting.

    Depending on the switch brand, the controller chip for RGB LED items is available as a separate entity, but I forget where, and there is Propeller code available for the driver chip. Although it might be bundled with the pixel function configured one.......... (The LED set that is.)

    [Spins Peter's prop.] I have several of those NKK switches here, but I'll be kesseled if I can come up with a working application for them.
  • DynamoBenDynamoBen Posts: 366
    edited 2014-12-05 20:16
    It's a MEC switch (4FTH98222) nothing terribly exciting, and I'm using it as a lower cost alternative to a more costly NKK switch.

    While I appreciate all the flashiness of RGB its overkill for this project. I just need three colors (Green, Red, Amber) and the ability to dim them...super simple. Normally I would just run the switches directly to the Prop but I have far too many (multiple sets of 8), hence the I/O expander plus LED driver on an I2C bus.

    If there isn't a good alternative to the PCA9685 for what I'm doing then I will need to continue to hunt for a switch that works for this application. If I can't find one I will either need to use the more costly switch or look into a PIC as the interface.
  • kwinnkwinn Posts: 8,697
    edited 2014-12-06 09:44
    DynamoBen wrote: »
    I'm working on a project where I need to independently control 8 bicolor LEDs via I2C (LEDs are in some switches). I'd like to be able to dim them via PWM and not lose amber (Red and Green together). Normally I would use a PCA9685 but I'm not using discrete red and green LEDs this time around. Any thoughts on something similar that might get the job done or a way to pull this off with the PCA9685?

    It's worse than not having discrete leds since the red and green leds are connected with the red + to the green - and vice-versa. Very difficult if not impossible to control with a standard led driver chip. It could be done with TPIC's or similar S-P registers for each set of 8 leds but dimming them via pwm would be tricky. A propeller chip to control them (24 switches per chip) would probably be a better choice.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-12-06 10:07
    The PCA9685 is pretty sophisticated and offers both the delay% and the pwm% parameters. And it can both source (10mA) and sink (25mA). Allow for 10mA drive. Can you hook the bi-pin led between pin x and pin x+1, x stays low while you pwm x+1 for levels of red, and vice versa for the levels green. To get amber, run pin x with 0% delay and 50%pwm, and pin x+1 with 50% delay and 50%pwm. (No, I haven't used that chip, just wondering).
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-12-06 10:33
    I would use an inexpensive MCU with 16 available I/O lines -- the Propeller fits the bill -- and have your main processor talk to it via I2C. Switch reading is thrown in for free, as you'll have 24 free lines. I'm wondering if you could even do this without a crystal, but even so, it's maybe $12 in parts, and hugely flexible. I know you have considered this, but from an opportunity cost standpoint, it might be the best option, especially if you know the Prop and Spin already. You could create a small board with a couple of Props on it.
  • DynamoBenDynamoBen Posts: 366
    edited 2014-12-06 11:56
    Can you hook the bi-pin led between pin x and pin x+1, x stays low while you pwm x+1 for levels of red, and vice versa for the levels green. To get amber, run pin x with 0% delay and 50%pwm, and pin x+1 with 50% delay and 50%pwm. (No, I haven't used that chip, just wondering).

    I was considering this to see what I would get but frankly didn't know where to start. I knew if the timing got off I wouldn't get amber but rather off. Going this route would be ideal if it works, so I may mock something up.
  • DynamoBenDynamoBen Posts: 366
    edited 2014-12-06 11:59
    I would use an inexpensive MCU with 16 available I/O lines -- the Propeller fits the bill -- and have your main processor talk to it via I2C. Switch reading is thrown in for free, as you'll have 24 free lines. I'm wondering if you could even do this without a crystal, but even so, it's maybe $12 in parts, and hugely flexible.

    You are correct I did consider this as an option over a PIC, its been a few years since I've done PIC work so I'm more comfortable with a Prop. My hesitation was the $12 cost versus other options, but my quick research indicates that a PIC might not be up to the task, most only have 1-2 PWM outputs so I would need to do it in software.
Sign In or Register to comment.