Linearizing an LED for 800 pwm steps'?


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Linearizing an LED for 800 pwm steps'?

    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?

  2. #2
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: Linearizing an LED for 800 pwm steps'?

    Quote Originally Posted by RossWaddell View Post
    Would I use Gamma array size = 100 and pwm steps = 256?
    Yes... Good luck with your project...

    Cheerful regards, Mike

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Linearizing an LED for 800 pwm steps'?

    Thanks Mike!

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Linearizing an LED for 800 pwm steps'?

    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?

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts