Hank,
The PWM "step" size makes a significant difference at the low end too. It's amazing how much more light you get from a LED running at 1/1024th duty cycle with 1-usec PWM steps compared to, say, 125-nsec steps. Getting more brightness resolution at the lower duty cycle range seems to pay off with better smooth fade capability.
What's with the 0.3 at the end of the formula ...where did that come from?
Oh, the 0.3 was for rounding. Sorry if it caused any confusion.
BTW, here's a little program I use for building my gamma array tables. It uses the free JustBASIC program. After running it I copy the array from the console into my PIC source file. Hope it may be of some use.
Regards, Mike
And here's what the output looks like when you run the program;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 FOR index = 0 to arraysize-1 dcyval = INT(width^(((index+1)/arraysize)^gamma)+.3) if(index = 0) then dcyval = 0 PRINT else if(index MOD 10 = 0) then PRINT "," else PRINT ","; end if end if if(dcyval < 100) then print " "; if(dcyval < 10) then print " "; PRINT dcyval; NEXT index PRINT PRINT REM CLOSE
Code:Gamma array size: 64 Total PWM steps: 256 Gamma correction: .84 0, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 45, 49, 53, 57, 62, 67, 72, 78, 84, 90, 98,105,113,122,132,142,153,165,177,191, 205,221,238,256
Bookmarks