Duty Cycle Subroutine Gamma Correctedhttps://www.microchip.com/forums/(c) Microchip30Re: Duty Cycle Subroutine Gamma Corrected (bitdoctor)If you choose a gamma = 2, a simple square will give you a very decent LED gamma correction:<br/><pre class="prettyprint">// provide LED gamma correction<br />uint8_t LED_gamma(uint8_t intensity) {<br /> unsigned int result = (intensity * intensity) >> 8;<br /> return (uint8_t) result;<br />}<br /></pre><br/>It's running on my desk as we speak, and it looks great.<br/>https://www.microchip.com/forums/FindPost/1119832Fri, 22 Nov 2019 13:56:06 GMTRe: Duty Cycle Subroutine Gamma Corrected (1and0)<blockquote class="quote"><span class="original">jack@kksound</span><br/> <br/>Of course but possibly less then the larger table? Not sure as I have not tried it but was just a thought...<br/></blockquote><br>Possibly yes.<br/>https://www.microchip.com/forums/FindPost/1119386Tue, 19 Nov 2019 12:29:18 GMTRe: Duty Cycle Subroutine Gamma Corrected (jack@kksound)<blockquote class="quote"><span class="original">1and0</span><br/>It still requires program memory space to calculate the interpolation. ;)<br/><br></blockquote><br>Of course but possibly less then the larger table? Not sure as I have not tried it but was just a thought...<br/>https://www.microchip.com/forums/FindPost/1119383Tue, 19 Nov 2019 12:20:51 GMTRe: Duty Cycle Subroutine Gamma Corrected (1and0)It still requires program memory space to calculate the interpolation. ;)<br/>https://www.microchip.com/forums/FindPost/1119372Tue, 19 Nov 2019 10:14:24 GMTRe: Duty Cycle Subroutine Gamma Corrected (jack@kksound)Maybe linear interpolation between the 32 table values to get 64?<br/>https://www.microchip.com/forums/FindPost/1119353Tue, 19 Nov 2019 09:00:27 GMTRe: Duty Cycle Subroutine Gamma Corrected (1and0)As I've said, start going over your assembly code and optimizing it to free some program memory space.<br/>https://www.microchip.com/forums/FindPost/1119314Tue, 19 Nov 2019 04:14:35 GMTRe: Duty Cycle Subroutine Gamma Corrected (Designer)You got it.I can easily have space for a 32 level gamma table.But in lower duty cycles the LEDs gets some noticeable flicker due to lack of dimming steps.That is why I shifted it to a 64 level table to make smooth fades.<br/> <br/>The above formula, the power into XX part (^) needs bigger multiplication routine with floating points which will require more space than my complete 64 level table.<br/> <br/>This is for WS2811 pixel LED lights.My maximum brightness value is 160 & lowest is 1.I need to dim them smoothly.<br/>https://www.microchip.com/forums/FindPost/1119298Tue, 19 Nov 2019 00:41:40 GMTRe: Duty Cycle Subroutine Gamma Corrected (1and0)<blockquote class="quote"><span class="original">Designer</span><br/>I'm implementing a gamma corrected duty cycle routine (instead of a gamma lookup table) due to lack of program memory space available on my PIC12F629 I do not have enough space "64 plus" lines of a "lookup table" to be inserted.<br/>The below formula working nicely in computer software program.But I need to implent it to a small PIC with assembly language to find out the duty cycle values. Can this be simplified?<br/> <br/>Gamma Factor = 1<br/>PWM Steps= 160<br/>Gamma Steps = 64 Levels<br/>i = 0 to 63<br/> <br/>Duty Cycle = INT(PWM Steps^((i+1)/Gamma Steps)+ Gamma Factor) <br/></blockquote><br/>Is that ^ a power operator or the XOR operator? At first glance, assuming it's a power operator, that formula most likely will take more than 64 words of program memory. That being said, I'm willing to bet your assembly code can be optimized to get enough memory for that lookup table. ;) Or use a PIC with more memory.<br/> <br/> <br/>https://www.microchip.com/forums/FindPost/1119234Mon, 18 Nov 2019 12:19:40 GMTDuty Cycle Subroutine Gamma Corrected (Designer)I'm implementing a gamma corrected duty cycle routine (instead of a gamma lookup table) due to lack of program memory space available on my PIC12F629 I do not have enough space "64 plus" lines of a "lookup table" to be inserted.<br/>The below formula working nicely in computer software program.But I need to implent it to a small PIC with assembly language to find out the duty cycle values. Can this be simplified?<br/> <br/>Gamma Factor = 1<br/>PWM Steps= 160<br/>Gamma Steps = 64 Levels<br/>i = 0 to 63<br/> <br/>Duty Cycle = INT(PWM Steps^((i+1)/Gamma Steps)+ Gamma Factor) <br/>https://www.microchip.com/forums/FindPost/1119226Mon, 18 Nov 2019 11:50:30 GMT