Multiplex question for multiple RGB LEDs

I have previously used PWM for colour mixing single RGB LEDs (purely for hobby purposes if anyone from Philips IP Department is watching).

I'm trying to scale this approach to achieve individual control of 80 RGB LEDs (common anode) but I'm having problems.

I was proposing to use the following hardware method: Tie all the Red cathodes to a MOSFET or NPN transistor, ditto Green & Blue. Scan these at 300Hz (to get a 100Hz overall refresh) and drive the 80 anodes from transistors using latched data from 74HC595s.

The problem comes in (my understanding of?) the method of PWM dimming. In the single working prototype, I used a microcontroller with each RGB tied to individual port pins. A timer interrupt occurred at approx

25,500Hz (to give 255 levels @ 100Hz) and within this an 8 bit variable "gate" was decremented. If this result was less than the value of either R, G or B, the respective LED was switched on, if it was greater, it was switched off.

This has worked fine but trying to scan 3 columns requires an interrupt at 76,500 Hz which is proving problematic. I have access to AVRs or PICs.

Any advice appreciated.

Reply to
Mike G
Loading thread data ...

On a sunny day (Thu, 03 Apr 2008 07:46:49 +0100) it happened Mike G wrote in :

Your hardware would be much simpler with an FPGA.

Reply to
Jan Panteltje

You can drive the array with a 4-bit port. Continue with the timed interrupt at 255x100=25500 Hz, update the RGB outputs at the same time, and output a clock edge every 85 interrupts ( this means output 1 on

85th and then 0 on 86th) to produce 300Hz for a ring counter drive, like so: View in a fixed-width font such as Courier.

. . V+ . | . .-------+------. . | | | . | | | . __ | | | . R>---------------| \\ | | |< . | o-----|-------|----| . .---------|__/ | | |\\ . | | | | . | | | | . 100Hz | __ | | | . G>-----|---------| \\ | |< | . update | | o-----|-----| | . | .------|__/ | |\\ | . | | | | | . | | | | | . | | __ | | | . B>-----|--|------| \\ |< | | . | | | o---| | | . | | .---|__/ |\\ | | . | | | | | | . | | | | | | . | | | B-anode G-anode R-anode . | | | . | | | . ----------- . | Q0 Q1 Q2 | . 300Hz>------> | . | 4017 | . 25500 ----------- . = ----- ring counter . 85 . . .

Reply to
Fred Bloggs

Actually if you simply toggle the clock output for every interrupt at

25500Hz, that gives you 12750Hz, and the ring counter partitions the LED anode drives at 33% anyway. This makes things easier for the LEDs, because you have to drive them with 3x the current, or more, for same brightness as steady state, and the 12750Hz higher frequency means a pulse duration of only 78us at this elevated instantaneous power dissipation versus 3.3ms with the 300Hz. Transistor switching losses increase, but these can be made negligible at that frequency. View in a fixed-width font such as Courier.

. . V+ . | . .-------+------. . | | | . | | | . __ | | | . R>---------------| \\ | | |< . | o-----|-------|----| . .---------|__/ | | |\\ . | | | | . | | | | . 100Hz | __ | | | . G>-----|---------| \\ | |< | . update | | o-----|-----| | . | .------|__/ | |\\ | . | | | | | . | | | | | . | | __ | | | . B>-----|--|------| \\ |< | | . | | | o---| | | . | | .---|__/ |\\ | | . | | | | | | . | | | | | | . | | | B-anode G-anode R-anode . | | | . | | | . ----------- . | Q0 Q1 Q2 | . 12750Hz>---> | . | 4017 | . ----------- . ring counter . . . .

Reply to
Fred Bloggs

Try this... it's not PWM but you get the same effect with a much lower clock rate...

At each interrupt, ADD the brightness value to a counter. Set the led output to the CARRY. I.e (in pseudocode):

interrupt_handler: mov #0, r0 add red_bright, red_count setc 1, r0 add green_bright, green_count setc 2, r0 add blue_bright, blue_count setc 4, r0 mov r0, led_port iret

Note that this is the same algorithm as used to draw diagonal lines in pixels (Bresnehan's Algorithm) - it distributes the "on" bits evently throughout the cycle while maintaining the desired number of them.

So, your effective resolution is determined by the ratio of your interrupt frequency to 60 Hz - a 240 Hz interrupt is two bits, etc. However, your counters can still be 8 or 16 bits - whatever your chip is fastest at adding.

The extra bits in your counter cause the brightness to vary slightly from cycle to cycle, with the average brightness being as accurate as your counter.

I've got an R8C module that has 128 LEDs (half red, half green) that I do this with - each LED has an 8-bit brightness and I dither them all (8 rows, 16 columns) fast enough to have no flicker:

formatting link

Reply to
DJ Delorie

Thanks for your reply. I'll give it a try.

Regards, Mike

Reply to
Mike G

Thanks for your reply & also the URL. I'll give it a go.

Regards, Mike

Reply to
Mike G

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.