# RGB LED colour mixing

• posted

I'm going to drive a Kingbright SMT RGB LED from a PIC with the intent to be able to display an apparent full colour spectrum. Plan is to "white balance" the thing using the current limit resistors and then PWM each channel, with 8 bit resolution if required. I'm wondering how many actual colours you need to display to make the thing scan through a convincing spectrum from a subjective human viewpoint. Also is there any algorithm that lets me calculate advance how to mix these colours, or have I just got to experiment to get a particular mixed colour? I'm aware that there are big differences in emission characteristics between the 3 LED's on the chip. I also wonder how much the linearity there is with respect to PWM drive level and output, and whether this varies between colours. All of this could make the output colour pretty arbitrary I guess.

Steve

• posted

On 09/01/2006 the venerable Steve etched in runes:

You need to start off with an understanding of the CIE chromaticity chart and how the human eye responds to colour stimulus. There are a couple of good references here:

and here:

Then plot your three primary wavelengths on the chart and you can reproduce any colour within that triangle. A study of the photopic curves will reveal a large negative lobe in the red sensitivity and a much smaller one in the green. In the early days of colour TV development we spent a long time looking for the elusive 'sucking phosphors' (try saying that after a glass or two of Merlot) to reproduce the gamut correctly. The answer of course was to do it electronically in the camera with a linear matrix.

Unfortunately colour reproduction is very subjective as at least 1 in 6 of the male population suffers from red/green colour blindness. Also for many years the unit of colour measurement was the JND or 'just noticable difference'! How scientific is that?

Anyway to answer your question, I think that for your project 64 steps for each of R, G & B would be more than adequate but the steps will not be linear and a look-up table for the PWM durations would be a good idea. Aim at a repetition rate of at least 70Hz and most of all have fun.

```--
John B

Delete \'spam blocker\' to reply direct```
• posted

Thanks for that John, I'll read the references, good to know 64 levels might do it. Will certainly have fun, indeed this one is purely a fun thing, it's going under my ice boots :-).

Steve

of R, G & B would

the PWM durations

have fun.

• posted

FWIW, I'm currently approaching completion of the first of a series of pre-programmed microcontrollers that will do PWM (BAM actually, to avoid patents) mixing of LEDs with 12 bits of resolution and at least 125Hz refresh. The first chip drives up to 21 LEDs (7 RGBs) from a 28-DIP, but the next version will drive 3 or 4 LEDs (RGB or RGBW) in an 8-DIP. They're controlled via I2C, but I can easily make versions that color-cycle internally, if people have specific cycles in mind.

Email me if you're interested in these chips.

TTYL, Omega aka Erik Walthinsen

• posted

I wrote quite a few routines for doing color analysis; and also have CIE data tables for the various sensitivities at differing resolutions (nm widths.) I can provide some thoughts based on my experiences and reading, too. But unless folks are interested in having a discussion and data tables and code bandied around here, perhaps we should take it to private email? (Mine is not obfuscated.)

Of course, none of this is particularly relevant if your main approach will be to simply work out what works from practice with your own vision. And for your use, that may be fine, with all the modeling and math more of an exploratory side-route than a direct path. Still, it can be fun to play with.

If you were putting these LEDs closely side by side into a grid and driving them, you may find the need to calibrate each one. It turns out that manufacturers haven't got processes or assembly processes tweaked well enough to guarantee that the emission bands are sufficiently close to each other for each die, or the dispersions similar enough, so that even at the same drive currents they do not emit the same optical amplitudes with the same dispersion distributions over angle and at the same wavelengths. Enough so that folks do notice differences in uncalibrated, gridded situations like outdoor LED displays supporting NTSC inputs.

Jon

• posted

Thanks Johathan,

Interested to hear of the issues for those needing to match colour output accurately. This application is pretty basic, it just needs to look like I'm displaying a spectrum to the casual viewer. I have mailed you with a bit more detail!

Steve

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.