Author Topic: How do I programtically change power to bi-polar leds  (Read 572 times)

0 Members and 1 Guest are viewing this topic.

Offline RAPoTopic starter

  • Frequent Contributor
  • **
  • Posts: 804
  • Country: nl
How do I programtically change power to bi-polar leds
« on: August 22, 2024, 01:43:06 pm »
I want to create an array of 64 bipolar 2-pin LEDs arranged in a de Bruijn cycle, lighting up 6 consecutive LEDs in one of the two colours.

What I need is a method (by programming an Arduino or something like that) that
changes a chosen subset of LEDs to the opposite colour, i.e. reversing the plus and minus applied to the LEDs.

What is the best way to do this with minimal component count?

To be explicit, the question is not about how to extend the number of GPIO pins,
but is about the way to change the plus/minus voltages applied to a set of pins.
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2733
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #1 on: August 22, 2024, 03:38:40 pm »
To be explicit, the question is not about how to extend the number of GPIO pins,
but is about the way to change the plus/minus voltages applied to a set of pins.

It's not really possible to separate the two.  There are many ways to solve the problem, but the best one will depend on how many IO pins you have available and what kind of control you want to have over the LEDs.

Do you need to be able to turn individual LEDs off as well, or just select one of two colors?  If you just need one color or the other, then you could use a single IO line per LED, route that directly to one side of the LED, and then through an inverting buffer to the other side of the LED.  The state of the IO pin then selects the color.  If you need to be able to turn LEDs off as well, then you can connect one side of the LEDs all together, drive that side with a pair of transistors (sufficient to handle the combined current of all of the LEDs), and then wire the other side of each LED to an independent IO line.  Set each of those IO lines high for one color, low for the other color, or tristate for off, and then toggle the common side between high and low.  That effectively multiplexes the LEDs by color, so all of the LEDs set to color A will be on, then all those set to color B, etc.  You can use fewer IO lines by multiplexing somehow, but that's challenging with bipolar LEDs -- in any sort of matrix arrangement, there will be parasitic paths that will carry current through LEDs that should be off, and they might light up when you don't want them to.  Modern LEDs are crazy efficient, and can visibly glow at surprisingly low votlage/current.

Are you trying to control the brightness as well or just the color?  Generally you wouldn't change the voltage to change the brightness -- if you want analog dimming, then it's better to control the current through the LEDs rather than the voltage.  But it takes fewer components to do the dimming digitally, by controlling how much time each LED is on.  Exactly how you accomplish that will again depend on how they are connected. 
 

Offline RAPoTopic starter

  • Frequent Contributor
  • **
  • Posts: 804
  • Country: nl
Re: How do I programtically change power to bi-polar leds
« Reply #2 on: August 22, 2024, 04:21:12 pm »
Thanks for your quick answer ajb.

My situation is a bit more complex: each led can be one of three states: Off,Red,Yellow. Red color is +/- power, Yellow color is -/+ power.
The program calculates a new state for each of the leads, and the LEDs will have to be powered off/on.

A simplified example with 4 LEDs and two LEDS on goes as follows
Initial led 1= off, led 2=Red, led 3 Yellow, led 4 =off.
The program calculates the new state as display LED 1 and LED 3, all in color Red.

So LED 1 has to have +/- power, LED 2 = off, LED 3=+/- power, LED 4 is off.
Each of the possible states is possible, so in a next round LED 3 can be yellow (-/+ power) and LED 4 RED etc
« Last Edit: August 22, 2024, 04:49:04 pm by RAPo »
 

Offline AVGresponding

  • Super Contributor
  • ***
  • Posts: 4841
  • Country: england
  • Exploring Rabbit Holes Since The 1970s
Re: How do I programtically change power to bi-polar leds
« Reply #3 on: August 22, 2024, 05:50:06 pm »
Does this help?

« Last Edit: August 22, 2024, 05:55:45 pm by AVGresponding »
nuqDaq yuch Dapol?
Addiction count: Agilent-AVO-BlackStar-Brymen-Chauvin Arnoux-Fluke-GenRad-Hameg-HP-Keithley-IsoTech-Mastech-Megger-Metrix-Micronta-Racal-RFL-Siglent-Solartron-Tektronix-Thurlby-Time Electronics-TTi-UniT
 
The following users thanked this post: RAPo

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1982
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #4 on: August 22, 2024, 06:21:42 pm »
Does this help?



Add a current-setting series resistor, or probably two resistors if the red / yellow forward voltage drops are significantly different.
edit:  I forgot that was a two-lead LED.  One resistor.
« Last Edit: August 22, 2024, 06:23:40 pm by fourfathom »
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline Kim Christensen

  • Super Contributor
  • ***
  • Posts: 1747
  • Country: ca
Re: How do I programtically change power to bi-polar leds
« Reply #5 on: August 22, 2024, 06:31:41 pm »
I would treat it similar to driving a raw LCD display (sort of). Connect one side of all LEDs to a push-pull driver that's driven with a constant 50% duty cycle squarewave from the MCU. Then each LED connects to an IO pin via a resistor.

1) If you want a LED off drive it in phase with the common.
2) If you want a Red lit, drive it's IO pin low. (It'll be lit at 50% duty cycle)
3) If you want it Yellow, drive it's IO pin high. (It'll be lit at 50% duty cycle with reversed polarity)

You could also do dimming and color blending by varying the duty cycle of each IO pin.
« Last Edit: August 22, 2024, 06:34:17 pm by Kim Christensen »
 
The following users thanked this post: fourfathom

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2733
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #6 on: August 22, 2024, 07:00:29 pm »
AVGresponding's circuit will work, but the gates are probably not necessary.  Assuming these are modern low power indicator LEDs, you typically need 1mA or less to get adequate brightness, so if you have an MCU with 128 GPIOs available, you can just run one GPIO to each end of each LED and skip the gates altogether*.  Likewise if you're using IO expanders, you'll need 128 pins either way, so the gates don't really offer any benefit here. 

You can get the same results using only 65 GPIO lines.  I don't have any red/yellow bipolar LEDs in my library, but the basic idea is attached. 

2347205-0

If you have GPIO pins that can tristate (IE, you are connecting directly to an MCU), set the LED GPIO lines low for red, high for blue, or set them to inputs to turn an LED off, and then toggle the Blue and #Red line between high and low (you can tie them together in this case).  The red LEDs will be on when Blue/#Red are low, and the blue LEDs will be on when those lines are high.  Toggle fast enough, and the eye won't notice the change, it will look like both are on at the same time. 

If you cannot tristate the GPIO lines (IE, if you're using shift registers or whatever to drive the LEDs), then you'll need to toggle between these states:

- set Blue/#Red high and each LED GPIO high for blue, and low for off/red (blue LEDs will be on, all others off)
- set Blue/#Red low and each LED GPIO low for red, and low for off/blue (red LEDs will be on, all others off)

Ideally you would change the states of all of the control lines at the same time, which is pretty easy with a chain of shift registers.  If you aren't able to do that, then you might need to incorporate an 'off' state in between the red and blue to ensure that no LEDs light up during the transition.

* Note that if you were to turn all 64 LEDs on at once the total current might exceed the maximum current rating for the MCU's power pins, in which case using gates would help.  But for only 6 LEDs at a time that shouldn't be a concern with indicator LEDs run at reasonable current.  If you're using IO expanders, then there isn't really a concern.
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1982
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #7 on: August 22, 2024, 07:22:33 pm »
AVGresponding's circuit will work, but the gates are probably not necessary.  Assuming these are modern low power indicator LEDs, you typically need 1mA or less to get adequate brightness, so if you have an MCU with 128 GPIOs available, you can just run one GPIO to each end of each LED and skip the gates altogether*.  Likewise if you're using IO expanders, you'll need 128 pins either way, so the gates don't really offer any benefit here. 

You can get the same results using only 65 GPIO lines.  I don't have any red/yellow bipolar LEDs in my library, but the basic idea is attached. 

(Attachment Link)


If that Blue/Red signal ever goes tristate (at power-up for example), those mosfets will probably be both biased on and draw huge current. I would use either the pull-up, or the pull-down -- not both.
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2733
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #8 on: August 22, 2024, 08:45:03 pm »
If that Blue/Red signal ever goes tristate (at power-up for example), those mosfets will probably be both biased on and draw huge current. I would use either the pull-up, or the pull-down -- not both.

Whoops! I had originally drawn them as separate control lines, hence the separate pull up/down, forgot to delete one of them when I changed that, thanks! 
 

Offline AVGresponding

  • Super Contributor
  • ***
  • Posts: 4841
  • Country: england
  • Exploring Rabbit Holes Since The 1970s
Re: How do I programtically change power to bi-polar leds
« Reply #9 on: August 23, 2024, 05:14:39 am »
Does this help?



Add a current-setting series resistor, or probably two resistors if the red / yellow forward voltage drops are significantly different.
edit:  I forgot that was a two-lead LED.  One resistor.

:-//

The drawing was for conceptual purposes only. I also omitted the logic input pull-ups, and the power supply
nuqDaq yuch Dapol?
Addiction count: Agilent-AVO-BlackStar-Brymen-Chauvin Arnoux-Fluke-GenRad-Hameg-HP-Keithley-IsoTech-Mastech-Megger-Metrix-Micronta-Racal-RFL-Siglent-Solartron-Tektronix-Thurlby-Time Electronics-TTi-UniT
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3248
  • Country: us
Re: How do I programtically change power to bi-polar leds
« Reply #10 on: August 23, 2024, 05:53:49 am »
Are the LEDs going to arranged in a ring? If so I'd use those WS2812 smart RGB LEDs. You can get them already arranged in rings of various lengths:

https://www.aliexpress.us/item/2251832604607665.html

Unfortunately rings of 64 LEDs doesn't seem to be available but you can get 60 in a ring.

Or get a strip:

https://www.aliexpress.us/item/3256806037815487.html

which you can divide up however you want to create whatever physical arrangement you want.

Only requires one GPIO.
 

Offline RAPoTopic starter

  • Frequent Contributor
  • **
  • Posts: 804
  • Country: nl
Re: How do I programtically change power to bi-polar leds
« Reply #11 on: August 23, 2024, 06:10:45 am »
Thanks for all these nice suggestions. I will check them out over the weekend. At the moment, I work with shift registers for the LEDs (just the 5mm one's)

Yes, the LEDs are arranged in a ring (making a de Bruijn cycle). The program can ensure that only 6 less will ever light up.

Indeed, going the WS2812 route would be the easiest, but there is something about seeing blinking lights the old way (and I have a thousand of them;-)).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf