Go Down

Topic: High Power RGB LED Shield (Read 12 times) previous topic - next topic


Another demo project, IR remote controlled RGB mood lamp.
Please find details from http://neuroelec.com/2011/03/ir-controlled-mood-lamp/





Apr 29, 2011, 12:50 am Last Edit: Apr 29, 2011, 12:56 am by neurostar Reason: 1
LED Brightness to youreye, Gamma correction - No!

Original post with patched cyzRGB firmware : http://neuroelec.com/2011/04/led-brightness-to-your-eye-gamma-correction-no/

Human perceive brightness change non-linearly

When you want to change the brightness of LED or any light source, one thing you need to consider is how human perceive the brightness. As you see in the following chart, human perceive the brightness change non-linearly. We have better sensitivity at low luminance than high luminance. For example, when we control LED brightness using Arduino PWM, we see big brightness change between analogWrite(9,1) and analogWrite(9,2). We don't see brightness change between analogWrite(9,244) and analogWrite(9,255). If you didn't know, just quickly test yourself with Arduino. If you want to control LED brightness linearly to your eye, it require to have some adjustment.

Mis-understanding of Gamma Correction

In Arduino or any microcontroller, a common way to achieve linear brightness change is a lookup table that compensate or correct the value according to the curve. There are a common misunderstand or confusion regarding what curve to use. Many people use so called gamma correction table or equation which is not related with human perception of brightness. The Maxim App note http://www.maxim-ic.com/app-notes/index.mvp/id/3667 describe "Gamma correction is used to correct for the nonlinear relationship between luminance and brightness" which is simply wrong. The gamma correction is used to correct nonlinear relationship between applied voltage to CRT and luminance of CRT. http://en.wikipedia.org/wiki/Gamma_correction It is nothing to do with human perception. It is not just Maxim, I could find many implementation of gamma correction to correct luminance and brightness.

Why people so easily confuse about it? The gamma correction is necessary for the display application. When movie or image is displayed on LED matrix like a stadium display, you want to have gamma correction since movie and image data itself is already gamma corrected data. It is also useful for LED based LCD backlight. When LED is used for lighting, however gamma correction is irrelevant. A funny thing is co-incidentally gamma correction and human perception of luminance is very similar. http://www.poynton.com/PDFs/SMPTE93_Gamma.pdf Take a look at following chart. Again it is just a co-incidence. So somehow the gamma correction is close approximation of human perception the luminance.

Correction calculation of luminance and brightness describe in CIE 1931 report then used for CIELAB color space.

L* = 116(Y/Yn)^1/3 - 16 , Y/Yn > 0.008856
L* = 903.3(Y/Yn), Y/Yn <= 0.008856

Where L* is lightness, Y/Yn is Luminance ratio.

For the correction curve, you need to inverse the equation.

You can test linearity of LED brightness to your eye using following Arduino example code.

Just put any LED on pin 9 with current limiting resistor.

Code: [Select]
Change brightness of LED linearly to Human eye
32 step brightness using 8 bit PWM of Arduino
brightness step 24 should be twice bright than step 12 to your eye.

#include <avr/pgmspace.h>
#define CIELPWM(a) (pgm_read_word_near(CIEL8 + a)) // CIE Lightness loopup table function

5 bit CIE Lightness to 8 bit PWM conversion
L* = 116(Y/Yn)^1/3 - 16 , Y/Yn > 0.008856
L* = 903.3(Y/Yn), Y/Yn <= 0.008856

prog_uint8_t CIEL8[] PROGMEM = {  
0, 1, 2, 3, 4, 5, 7, 9, 12,
15, 18, 22, 27, 32, 38, 44, 51, 58,
67, 76, 86, 96, 108, 120, 134, 148, 163,
180, 197, 216, 235, 256

int brightness = 0;    // initial brightness of LED
int fadeAmount = 1;

void setup()  {
 // declare pin 9 to be an output:
 pinMode(9, OUTPUT);

void loop()  {
 // set the brightness of pin 9:, 0-31, 5 bit steps of brightness
 analogWrite(9, CIELPWM(brightness));    

 // change the brightness for next time through the loop:
 brightness = brightness + fadeAmount;

 // reverse the direction of the fading at the ends of the fade:
 if (brightness == 0 || brightness == 31) {
   fadeAmount = -fadeAmount ;
 // wait for 500 milliseconds to see the bightness change    


High Power RGB LED Shield 2.0

Here is a second revision of the shield. High Power RGB LED Shield version 2.0 has some improvements. A major change from version 1 is a new I2C PWM converter. The version 1 shield use ATTINY85 with cyzRGB firmware as a I2C PWM converter. Additionally it has couple of smart features like the writable sequence. However smart features was not that useful and it even confused users. I decide to abandon ATTINY with a better alternative, NXP PCA9685, a dedicated hardware I2C PWM converter. PCA9685 provide more muscle than brain. Instead of a few extra commands which was not popular, the shield now have more powerful PWM capability. All demo project codes that are posted are compatible with version 2 shield. It require Arduino or any microcontroller with I2C support for operation.

Overall design of the shield has not been changed except PCA9685. Price of the shield goes up little for the better quality product.

More Muscle than brain

    NXP PCA9685 for I2C PWM

        The PCA9685 support high speed I2C communication up to 1MHz (Now, all chips including mcp4728, tmp421 support high speed I2C). Arduino can support 400KHz I2C communication (default is 100KHz). Total 62 I2C address is supported, so 62 shields can be stacked or controlled from a Arduino.

    12bit PWM resolution

        12bit hardware PWM (4096 steps) is supported. 1: 4000 dimming ratio is achieved just with PWM. 12bit PWM allow smooth correction of brightness curve to human eyes at 8 bit.

    Adjustable PWM frequency - 40-1000KHz

        PWM frequency can be adjustable with default 200Hz. Version 1 shield use fixed 120Hz PWM. While >100Hz PWM is good enough most applications, in some cases you may find high frequency PWM useful. http://neuroelec.com/2011/03/high-pwm-frequency-for-led-good-or-bad/

Better Quality PCB

    Smooth and clean edge by tab routing all around
    Blue silk screen, gold finish
    2oz (70um) copper for better heat dissipation
    Official OSHW (open source hardware) logo , Maybe first Arduino shield with OSHW logo

Schematics and design files

As I do support open source hardware, all schematics and design files are available. If you need any eagle library for the parts, just let me know.





Arduino library for the shield V2.0 is available for download


Go Up