Looking for ideas for custom PWM controller. 30 Channel

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
At the moment I am using an IS31FL3218 LED driver (18 channel 1 kHz PWM) to run six RGB LEDs. It works great except after dimming so far the green LED starts to over power the red and blue. I added a PIC that is running a software PWM to drive anode transistors thinking I could use that for a dimmer and raise the cathode duty cycle and even the colors out. It too works good, but around 50% duty cycle and less the PWMs of the PIC and the LED driver overlap wrong and it starts to flicker and such. I could just redesign the anode controller to use a better PIC. I would like to do it different and thought I would see if anyone has any ideas.

What I hope to accomplish is create a group of three PWMs for the cathodes that will increment the anode PWM after every cycle. In other words the Anode will be on x number of 256 cycles of complete cathode PWM cycle (also 256 steps). I can do this already with a couple PICs I have, but I'll end up with 28 pin parts for a 9 pin project. The smaller packages either lack the speed for a software solution, or the hardware to make it possible. Assuming a final frequency of 100 Hz for the LEDs and 65536 total PWM cycles for each cycle it looks like I'll have to be over 6.5 MHz for the cathode PWM.

That covers 24 PWMs. The other six are for separate LED rings that are stand alone PWMs.

A PI Zero currently sends data to the PIC and LED driver through I2C now to alter the LEDs and I would have no problem sticking with I2C. I am trying to stay away from SPI as I have other plans for the PI SPI. The idea of a parallel interface between the Pi and the controller(s) is a possibility (I already have a partial driver programmed).

I have been kind of wanting to learn a bit about FPGAs and thought this might be a good project for one. Write only parallel interface with eight data pins, an address / data pin, and a clock pin. The only problem is I know nothing about making them work... Will have to learn.

I could just use the 28 pin PICs, but in the end it will take six of them. Still not enough speed or hardware to do more than LED one per controller. I'd like to keep the project small.

The Pi is too far away for WS2812 and the like. I had some APA102 types working for a while, but being outside they gave me some issues. The most reliable has been through hole standard RGB.

I'd like to be able to do it all with a single controller. Any thoughts?
 
Last edited:

MisterBill2

Joined Jan 23, 2018
18,176
It would make a lot more sense to just use one PWM control for each color, and adjust the commands in a processor. Then it would just be more code and much simpler wiring and much less chance of flicker.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
So how do you communicate between the Pi and the LEDs? Surely you ate not running 90 wires between the two!
Actually it's just standard Cat 5 riser cable between the LEDs and the controller. One cable each light. One wire for the RGB anode, three for the cathodes, and another pair to power a secondary ring.

It would make a lot more sense to just use one PWM control for each color, and adjust the commands in a processor. Then it would just be more code and much simpler wiring and much less chance of flicker.
That is what I pretty much had before with the color issues. Maybe just have to do some more experimenting.

The problem is at a duty cycle of 6% the lights are getting too bright for the effects I'm trying to achieve, and are more green than any other color. Around 12% the colors start to look right, but that is way brighter than I want to go. 90% of the time they are just accent lighting, but when a motion detector gets triggered they are turned full on white, and a secondary ring of white is lit. Ends up looking something like six 40 watt household lights and provides enough light to do most outside activities in the area.
My thought was if I can skip cycles then I could maybe even out the colors by raising the cathode duty cycles.

leds.jpg

An overly simplified schematic of the current setup.
 

MisterBill2

Joined Jan 23, 2018
18,176
My suggestion of separate PWM signals for each color will allow independent adjustment at every brightness point, but it will require a bit more code, and three controllers. But then all the LEDs can share one common return circuit.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
Actually I think I just found the problem. The driver datasheet gives a formula on page 8 that I always skimmed over. They call it a PWM so I always assumed it was max current for the duty cycle. It seems the "duty cycle" is actually a current reducer as a proportion of the maximum current set by R_Ext. That would explain the change in color.

@MisterBill2 looks like you're going to be right in light of the recent discovery. I wish I wold see this stuff before I ask the questions. I can get it done with one PIC I believe. I should be able to match up instructions close enough in assembly that it will look almost perfect on a scope, and still be over 100 Hz at the end.
 

MisterBill2

Joined Jan 23, 2018
18,176
Really, "Duty Cycle" control varies the average power but the on state current is always about the same. That way you do not get the color change with current or voltage changes, because they don't get changed. At least that is how it is supposed to work.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
I'll set up a side by side comparison and see if there is any difference between a PIC based setup and the driver IC. It may just be a characteristic of the EBay leds I bought.

This is where I picked up on the idea of varying currents:

formula.jpg
But that would not explain the flicker I get which could only be caused by PWM overlap timings in the current setup. It seems if I run the anode at around 1 kHz I can pretty much black the led out for a short while until the PWMs get enough out of sync to work again.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
As an experiment I set up a series of resistors between the R_Ext and ground, and moved the ground jumper along the resistors to alter the max current. The first resistance of 3800 should give a max current of 20.014 mA, the second resistance of 13800 would be 5.51 mA and the final of 23800 would be 3.195 mA. The LED became more green as the max current was reduced similar to the effect I see with the PWM in the lower duty cycles.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,201
@MisterBill2 thanks for all the comments. I was thinking the same with the colors not changing. Luckily for now they are on a "candle" program and I programmed an offset to make the red four steps higher than green to make a nice yellow.

I do have an old board made up with a PIC that I was using before my last revamp to deal with shorting surface mount LEDs. Will get to testing it out in a few days. Should just take a couple slight changes to work with the current design.
 
Top