Mixing the output of colored or white LEDs can produce a wide range of hues or white light of various color temperatures. Dynamic tuning can allow users to adjust architectural lighting across the range from cool to warm as desired, or cycle through a range of colors in accent lighting. It can also generate precise, consistent color from strings of LEDs, despite variations introduced by temperature fluctuations and age. By leveraging microcontrollers and closed-loop feedback from color sensors, lighting designers can develop finely tuned systems for repeatable and stable production of the exact shade desired.
Color spaces provide a method for expressing color in terms of red/green/blue wavelengths— tristimulus values (see the TechZone article “LED Color Mixing: The Basics”)—that roughly correspond to the sensitivities of the three human visual receptors for visible wavelengths. CIE 1931 color space expresses a range of colors in terms chromaticity x,y
(shown on plot) and luminous flux, Y
(not shown). The chromaticity values represent a set of RGB values scaled by the tristimulus values:
The coordinates of a red, green, and blue LED plotted in this color space define a triangle that encompasses the range of colors, called the color gamut, which can be realized by mixing the output of those devices in various ratios (Figure 1).
Figure 1: The color and brightness characteristics of red, green, and blue LEDs mapped to the CIE 1931 color-space diagram defines a triangle that encompasses all of the possible shades that can be generated by the output of the three devices; this is known as the color gamut. (Courtesy of Cypress Semiconductor)
In theory, by adjusting the drive current of each primary-color LED to the required ratio, we should be able to generate almost any shade in the color gamut. In reality, the materials systems for different colors of LEDs differ significantly in the amount of output generated by a specific drive current. In addition, the relationship between drive current and output is nonlinear—past a certain threshold, the amount of additional output generated by the current increase falls off, an effect known as droop (see the TechZone article “Identifying the Causes of LED Efficiency Droop”).
For a given device, the output also changes with temperature and age. In addition, fabrication and materials characteristics cause center wavelength for a given type of LED to vary from batch to batch and even among different devices from the same wafer. Finally, the contour gamut includes small discontinuities, which means calculating the amount of each primary color required to generate the desired shade in the gamut cannot be performed with a linear transformation.
Color mixing algorithms
Color mixing starts with identifying the CIE values for the LEDs used, then determining the blend of light required to generate the desired color Cmix
that has CIE coordinates x m, y m,
and Y m
. For basic color-mixing applications, simple look-up-tables can provide the necessary dimming values, but more sophisticated applications requiring highly controllable white light or exacting tunability need to use a dynamic system.
One common approach to color mixing leverages a matrix technique.¹ For any given Cmix
in the color gamut, we can define a conversion matrix A
If we define the total luminous flux required from the three-device LED module as a whole for Cmix
then we can determine the luminous flux required from each LED using:
It is important to note that this basic color-matching algorithm is not constrained to three devices but can be extended to greater numbers, such as three white LEDs warmed up with an amber LED, by simply adding additional terms to the matrices above.
Controllers for color mixing
Cypress Semiconductor takes a different approach to four-channel color mixing with its EZ Color family of high-brightness LED controllers using the superposition of multiple three-device triangles.² The EZ Color controllers are designed specifically for color-mixing applications. The PSoC CY8CLED16 supports configurable pulse-width modulated (PWM) dimmers for up to 16 independent LED channels with 32-bit resolution.
Consider an example using red, green, blue, and amber devices. The LEDs define four distinct triangles in CIE color space: TR1(R,G,B), TR2(R,A,B), TR3(R,G,A), and TR4(G,A,B). Solving Equation 5 for each triangle reveals which sets of base emitters can produce the desired color—negative values indicate that the shade lies outside of a given triangle (Figure 2).
Figure 2: If a desired color lies outside the color gamut for a set of LEDs, such as P2 with respect to the RGB triangle, the color-mixing algorithm will return negative values. (Courtesy of Cypress Semiconductor)
Practically speaking, the CY8CLED16 can execute all this in firmware. The x,y,Y
data for the base LEDs needs to be entered into memory, as well as the coordinates for Cmix
. The firmware performs the matrix calculation to find two valid solution sets (Figure 3). It not only checks for negative values that indicate the requested color is outside the color gamut for a given triangle, it checks to ensure that the requested luminous flux does not exceed the output of the actual devices. If that is the case, it scales the commands appropriately. The controller can also process temperature feedback in order to compensate for known performance variations as a result of thermal cycling.
Figure 3: The EZ-color HB LED controller performance four-channel color mixing by performing multiple sets of three-channel solutions until it finds two valid solutions. (Courtesy of Cyprus Semiconductor)
The 56F8XXX family of digital signal controllers (DSCs) from Freescale Semiconductor provides another option for controlling a matrix of LEDs with a color-mixing algorithm. With a dual Harvard architecture operating at 32 MHz, the MC56F8006, for example, boasts a 6-channel PWM module, a pair of 28-channel, 12-bit ADCs, and two programmable gain amplifiers (Figure 4).
Figure 4: MC56F8006 supports color-mixing algorithms via a full lineup of peripherals. (Courtesy of Freescale Semiconductor)
In operation, the system measures the voltage VR across the current sense resistor R to determine the current through the LED, and then converts that value to color luminosity. The DSC checks the actual value against the requested value (i.e. Yr, Yg, or Yb) determined by the color-mixing algorithm, and adjusts the PWM duty cycle to suit (Figure 5).
Figure 5: The digital signal controller leverages ADCs to check the luminosity of an LED and adjust output as required to deliver the hue and luminosity parameters required. (Courtesy of Freescale Semiconductor)
For applications requiring color tuning with high spectral resolution and stability, systems typically integrate on-board color sensors that feature photodetectors augmented with filters to simulate human visual response. The PIC24FJ16GA002 from Microchip Technologies, for example, can be integrated with a digital color sensor to deliver a specific, desired correlated color temperature. It sports three high-speed, high-resolution PWMs, 1 to 2 kB of RAM, and four parallel integrating ADC channels with a 16-bit output. The modified Harvard architecture delivers 16 MIPS at an operating frequency of 32 MHz.
In the sample application,³ the MCU accesses the sensor data via an I²C bus operating at 400 kHz. Sensor integration time takes place over four PWM cycles, during which time the MCU executes other tasks such as display update and communications.
The spectral discrimination and stability afforded by color mixing can extend the operating lifetime of LED strings in applications demanding high spectral stability or tunability. By choosing from among a range of MCUs sporting a wide variety of peripherals, lighting designers can easily tailor their systems to satisfy performance, reliability, and robustness specifications while meeting their price constraints.
- H. Kim, J. Lui, et al, “An LED Color Control System with Independently Changeable Illuminance.”
- A. Gulati, “Multi Channel Color Mixing Using HB LEDs”
- J. Martis, “Closed Loop Chromaticity Control: Interfacing a Digital RGB Color Sensor to a PIC24 MCU.”