Show Posts
Pages: [1] 2 3 4
1  Development / Other Software Development / Re: Quad 12-bit DAC MCP4728 libary on: March 13, 2012, 10:16:13 am

Just curious if you are planning to upgrade this library to Arduino 1.0 ?


Arduino 1.0 compatible library is available.
2  Development / Other Software Development / Re: Quad 12-bit DAC MCP4728 libary on: May 16, 2011, 02:13:05 pm
Updated to Version 1.2

Download :


- eepromReset() : reset all setting to factory default
- All library functions are fully documented.
- add keyword.txt
- add reference to this thread for discussion and feedback

I think the example code has enough details on how to use the library. setVref() was explained in the example code.
I added a link to this thread for discussion.

3  Development / Other Hardware Development / High Power RGB LED Shield 2.0 on: May 05, 2011, 05:02:30 pm
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.

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
4  Development / Other Hardware Development / LED Brightness to eye, Gamma correction – No! on: April 28, 2011, 05:50:16 pm
LED Brightness to youreye, Gamma correction – No!

Original post with patched cyzRGB firmware :

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 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. 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. 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.

 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    
5  Using Arduino / Project Guidance / Re: Advice on power scheme for 5 3w RGB LEDs on: March 25, 2011, 05:29:03 pm
Still not quite clear. When you power 5 x 3W LED = 15W, why do you need 12V x 5A = 60W power ? If you use switching driver you mentioned, you just supply whatever voltage that the driver support. Switching driver normally have >75% effciency. 1.5A> at 12V would be OK. If you use linear LED driver like CAT4109, you want to have as close as possible to LED Vf to reduce power dissipation and increase efficiency. >3A at 5V should be good for the linear driver.
6  Using Arduino / Project Guidance / Re: Advice on power scheme for 5 3w RGB LEDs on: March 25, 2011, 03:24:14 pm
It was a bit hard to follow. What I understand is you want to control every RGB LED seperately, otherwise it does not make sense to have 15 drivers. How you are going to have 15 PWMs from a Arduino ?. If you need to have high dimming ratio, you may need to change the PWM frequency. take a look at,51887.msg390972.html#msg390972. LED driver should not dissipate much heat at 200-350ma. I don't think location of LED driver is going to be a problem.
7  Using Arduino / Project Guidance / Re: filtering on: March 25, 2011, 03:10:38 pm
Im trying to filter out different frequencys from music to control lights. At the moment im trying to get an led to light on every beat.

Probably this is something you are looking for.,56331.0.html

8  Development / Other Software Development / ELM Chan's FFT Library for Arduino on: March 23, 2011, 05:11:04 pm
I'm planning to make my version of "color organ".
I tried couple of FFT code for Arduino and found ELM Chan's works best for me. It seems accurate and faster than others.
So I just more less package the library. All credit should go where it belongs.

Original Fixed point FFT library is from ELM Chan,
A way to port it to the Arduino library and most demo codes are from AMurchick,37751.0.html
Processing app is based on codes from boolscott

FFT Library and Processing code download :

Code :

Here is a demonstration video comparing FFT from Arduino and Ocilloscope

If you have any suggestion, let me know.
9  Development / Other Hardware Development / Re: High Power RGB LED Shield on: March 23, 2011, 05:27:36 am
Two more videos of the shield demo projects. These are more of basic sensor tutorials.

RGB LED Mood Light Clock

Intrusion Detect Mood Lamp

10  Using Arduino / Programming Questions / Re: Creating an Arduino Library on: March 17, 2011, 11:02:09 pm
I had similar experience couple of month ago.  smiley You definitely need more coffee.
Following and libraries people created before helped me.

By the way, do you know irremote library? seems similar to what you are trying to doing.
11  Using Arduino / Microcontrollers / Re: ATtiny85 - OneWire.h on: March 17, 2011, 10:33:33 pm
Thanks again. Now I understood.
12  Using Arduino / Microcontrollers / Re: ATtiny85 - OneWire.h on: March 17, 2011, 10:04:52 pm
Absolutely helpful. I read the method while back. Never actually tried it. I will try soon. By the way, I appreciate your arduino-tiny work.
Would briefly explain what applications works better with reading the value from EEPROM? I thought once I get optimal value, hard code is natural.
13  General Category / General Discussion / Re: Can you identify what is in this picture? on: March 17, 2011, 09:53:27 pm
Gold button. give it to me smiley
14  Using Arduino / Sensors / Re: optical flow sensor for mobile robot navigation on: March 17, 2011, 09:44:57 pm
What resolution of sensor are you going to use? I don't think high resolution image analysis at a proper speed can be done on Arduino or any similar 8 bit microprocessor. For low resolution, I found following link.
15  Using Arduino / Microcontrollers / Re: ATtiny85 - OneWire.h on: March 17, 2011, 09:32:38 pm
I have a question regarding calibration. So, I connect attiny with ftdi converter to computer, then keep press 'x' key on the terminal program. Is that all it need?
Pages: [1] 2 3 4