Output polarity control for addressable LEDs

I am working on a monochrome low-power LED illumination project (e.g. Christmas tree lights). I want to be able to send patterns and fading/PWM to PCB subboards, and have simple 2-wire connections from there to parallel alternating LED bead strings (e.g. fairy lights), so they become two channels. Also, I want to be able to fade them.

So my requirements are: (1) addressability of groups of LEDs and (2) separately controlled fading on each channel of each LED group, (3) the LED groups are two channel, using only 2 wires (DC + and -),

The first and second requirement can be met by use of LED drivers such as WS2811 (although I'd prefer non-daisychain). The third requirement can be met by connecting each group of LEDs in parallel with alternating polarity, and flipping the power polarity thereby giving 2 channels.

So there would be a master AVR MCU interpreting patterns and sending signals to a string of slave PCBs to which the leds are connected.

I have thought of a few approaches, (a) using WS2811 driver chips, and feeding their output to an H-bridge input (eg R channel) and enable pins (e.g. G B channel), or (2) feeding the WS2811 output to an ATTiny, and driving the LEDs using a pair of output pins driven HIGH/LOW or LOW/HIGH to given the required polarity, or (3) replacing the WS2811 completely by an ATtiny that is controlled by I2C or SPI, does the PWM and the polarity control.

I'm not sure any of these ideas would work, as I am waiting for delivery on parts to test them out.
In any case, it would be very nice if there was a simpler solution. I found a driver chip that seems to support polarity reversal, the WS2821, but I can't find anywhere to source it. https://html.alldatasheet.com/html-pdf/1243797/WORLDSEMI/WS2821/1137/2/WS2821.html

I hope that wasn't too hard to understand, obnoxiously long, or obviously silly in some way.

EDIT a block diagram of the requirements.

Hi tokyodave

It depends how much electronic/coding experience you have. The simplest thing to do would be to get addressable NeoPixel strip(s) 5050 RGB LED with Integrated Drivers YUNBO WS2812B Addressable LED Strip 1M 144 Pixels, RGB 5050 SMD 5V Black PCB IP67 Waterproof Cuttable Smart Flexible LED Lighting : Amazon.co.uk: Lighting as they are 5v LEDs that connect to a data pin without the need to use I2C or SPI. You can code however many LED strips you needed using an Arduino (for e.g. Arduino UNO) using the Adafruit_NeoPixel library and a power supply.

Thanks, that doesn't quite cover all the requirements. I've added a diagram to make clearer what I'm trying to accomplish.
I'm a retired software developer, and I have done some MCU projects. I don't have a lot of electronics background, so I usually copy designs and repackage them in custom PCBs. I should be able to handle IC-centric designs.

Why do you want to use an addressable LED driver (WS2811) to drive a H-bridge or an ATtiny?

I would go for an ATtiny combined with an H-bridge. Communication from master to slaves using RS422 or RS485 (RS232 if distance is not to long between master and slaves).

1 Like

I think the reason for going for the WS2811 is that I'd like to avoid inventing a protocol. Last time I tried wasn't pleasant. I'll see if I can find a software implementation of the WS2811.

Adafruit has a WS2811 / WS2812 library and everything you need to know.

1 Like

I have no idea :wink: I usually don't have a problem :smiley: If you use one way serial communication and only control one set of light per slave, you can basically send something like

<1,255><2,-128><4,0> ...

Indicating
slave 1, section 1 full on
slave 2, section 2 50%
slave 3, no change
slave 4, off

Format based on Robin's updated serial input basics

What kind of distances are we talking about between master and slaves?

Cheers. Distance between modules is around 20-40cm. Also, as indicated above, the protocol needs to support daisy-chaining. Each slave module supports 4 output pairs, which may mean multiple ATtiny chips per module, and the modules themselves can be chained.

You have no current limiting resistors on that chain you want to invert the polarity of. Each LED NEEDS two resistors, so you are better off using another strip of WS2812s.

There is absoloutly no need to "invent" anything. That is what Libraries are for. The two main ones are FastLed and Adafruit Neopixel. The FastLed uses more complex software concepts so maybe it will suit someone with your software background. If not then the Adafruit one is simpler to understand.

Why the ATtiny chips? You don't need them for your project.

That's a high level diagram and doesn't have all the detail. It's a reimplementation and enhancement of a commercial original, which outputs alternating polarity from the master module (5v at max 50% duty?). (A previous version used 5v from the USB, and had resistors on each ornament).
Secondly, as the diagram shows, I want 2 wire going into the LEDs. Those LEDs go into custom ornaments, many quite small, which I already have The wires are what you hang the ornaments with. LED strips fit only 1 of the requirements I gave.

It shows that all the power is derived from the USB port. Have you done the calculations of how much this is going to take?

That is a very odd word to use and I am not sure I understand it in the context you are using it.

As the original post stated, this is for Christmas tree lights. Interior Christmas tree of a couple meters height.

I've now got a more concrete direction. It's always helpful to just write it down and put it in front of others. Thanks for your input.

I'm now considering an ATtiny for the master (selection of LED sequence pattern and sending it to the slaves), and for each slave an ATmega (mostly for the pin count) and a set of H-bridges. Slaves execute the received pattern, inc PWM and fading, and polarity switching. The inter-module communication would be either point-to-point forwarding (e.g. RS232) , or a multidrop or bus protocol like RS485 or Dallas 1 Wire (both new to me) that can handle the distances. Since data is only sent at pattern selection, latency shouldn't be a problem.

For 40 centimeters distance you will not need RS232. If there is one-way communication only, you also don't need RS485; you can connect the TX of the master to the RX of the slaves or you can connect Tx to Rx of first slave, Tx of first slave to Rx of second slave etc. The latter involves a little more software because the first slave must pass the message through to the second one etc.

If you don't have a lot of electronics background then personally I would keep it simple. There's no reason why you can't use my suggestion and attach an Arduino MC on a custom pcb and get the desired effects that you want if it's just for Christmas tree lights.

Also, your diagram does not show a separate power source for your LED's, hopefully you won't use your MC as a power source for your LED's.

The H-bridges are powering the lights. For this config I'm using the L9110S, which I've proof of concept tested for this usage. The biggest ornament load is 1W at ~3V, which is well within its capacity.
I've got the pattern data-driven software PWM portion fully working, and should have the 4 port x polarity-reversing TDM done in a day or two. Lots of fun.
I've done OS ports, including the low-level kernel and hardware programming; my challenges are in the physical electronics layer. A year ago I was working on just being able to wire modules and LED strips together, but I'm in a different space now.

For sure.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.