Try this modification (untested):
RobertCode:... if(index = 0) then PRINT PRINT "DW "; else if(index MOD 34 = 0) then 'this dictates how many values per line PRINT " " 'this puts no comma at the end of the line PRINT "DW "; else ...
Try this modification (untested):
RobertCode:... if(index = 0) then PRINT PRINT "DW "; else if(index MOD 34 = 0) then 'this dictates how many values per line PRINT " " 'this puts no comma at the end of the line PRINT "DW "; else ...
Hi, that worked a treat, here's the output after modifying with your snippets...
Many thanks....this will save me a lot of time experimenting with different gamma values with the LUT going into the PICCode:Gamma array size: 255 Total PWM steps: 1023 Gamma correction: 2 DW 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 DW 19, 20, 21, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 36, 37, 39, 40, 42, 44, 45, 47, 49, 51, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72 DW 74, 77, 79, 81, 83, 86, 88, 90, 93, 95, 98,100,103,105,108,111,113,116,119,121,124,127,130,133,136,139,141,144,148,151,154,157,160,163 DW 166,170,173,176,180,183,186,190,193,197,200,204,208,211,215,219,222,226,230,234,238,241,245,249,253,257,261,265,269,274,278,282,286,290 DW 295,299,303,308,312,317,321,326,330,335,339,344,349,353,358,363,368,373,377,382,387,392,397,402,407,412,417,423,428,433,438,444,449,454 DW 460,465,470,476,481,487,492,498,504,509,515,521,526,532,538,544,550,556,561,567,573,579,586,592,598,604,610,616,623,629,635,641,648,654 DW 661,667,674,680,687,693,700,707,713,720,727,734,740,747,754,761,768,775,782,789,796,803,810,817,825,832,839,846,854,861,868,876,883,891 DW 898,906,913,921,928,936,944,952,959,967,975,983,991,999,1007,1014,1023
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
Last edited by Mike, K8LH; - 11th May 2013 at 02:14.
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?
Next question - if this produces data than I **think** gets added to a .pbp file with the ASM/ENDASM block, how do I search/look up values from it in code?
Bookmarks