Quote Originally Posted by Mike, K8LH View Post
Hi Hank,

Sorry for the late reply. Glad you figured it out. Another slightly more recent version of that Gamma Table program is listed below.

Gamma values of 1.7 to 1.9 worked good for me but it's very much dependent on your LEDs, voltage, hardware, etc..

Cheerful regards, Mike

Code:
 '  Leo Bodnar's 'antilogarithmic'
 '  gamma correction algorithm (Mike, K8LH)
 '
 '  JustBASIC (free) interpreter
 '
 Input "Gamma array size: "; arraysize
 Input " Total PWM steps: "; width
 Input "Gamma correction: "; gamma       ' try 0.5 to 1.0
 Input "Entries per line: "; entries     '

 FOR index = 0 to arraysize-1
    dcyval = INT(width^(((index+1)/arraysize)^gamma)+.3)
    if(index MOD entries = 0) then
      PRINT
      PRINT "  DW ";
    else
      PRINT ",";
    end if

    if(dcyval < 100) then print " ";
    if(dcyval < 10) then print " ";
    PRINT dcyval;
 NEXT index
 PRINT
 PRINT
 REM CLOSE
Hi Mike,

I'm implementing a LED dimmer using Darrel Taylor's MIBAM library (see http://www.picbasic.co.uk/forum/cont...-Modulation%29) which accepts values from 0 - 255 for the duty cycle. I also want to smoothly fade the LEDs so I believe I need to include something similar to your Gamma correction algorithm, but I'm having trouble understanding what you mean by 'Gamma array size'. On another thread I see you posted a chart where you used 100 for that value (and 512 for pwm steps) - is that analogous to saying, 'My brightness can go from 0 (fully off) -100% (fully on, max LED brightness) with 512 steps'? Would I use Gamma array size = 100 and pwm steps = 256?