How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT

    Hi All,

    I'm trying to linearize LEDs for use with 1024 PWM (lots of different types of LEDs), but I'm finding it really troublesome ...I'm using a lookup table & using a 'hit & hope' method (&very* time consuming)...worse still when I get it 'close' for on LED colour, using the same LUT on another LED colour is often wildy different.

    I need a quicker method for finding out the rough values need for each LEDs LUT.

    it strikes me what I need is a way of manually hand drawing a rough curve on say my PC (S-curve, log, anti log etc), then getting this into my PIC LUT to see what gets me the closest visually (as I eyeall the LEDs)...so I need a way of being able to draw 1024 levels, then getting these values somehow or other quickly into a table that picbasic can use.

    Any top tips?

    tks,
    Hank.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,806


    Did you find this post helpful? Yes | No

    Default Re: How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT

    Unless you have all the time of the world, I would not recommend this way.

    LEDs are current controlled devices. PWM is controlling the mean voltage that the LED receives. So, I think the way you try it is wrong.

    You have to control, by the PWM signal, the current flow through the LED.

    Then, you only have to find the min and max current the LED needs to light. Rest should be close to linear.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT

    Hi Hank,

    Not sure if this will help but I created an Excel spreadsheet that charted the gamma "duty cycle" values generated by the "anti-log" formula in that simple JustBASIC program I use for generating the anti-log gamma tables. Here's what the Excel chart looks like;

    Name:  gamma chart.png
Views: 2820
Size:  41.4 KB

    And if you've forgotten, here's the program I use for generating the gamma brightness level correction tables (using the free JustBASIC program as well as an example of the output window;

    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 = 0) then
          dcyval = 0
          PRINT
          PRINT "  DW ";
        else
          if(index MOD entries = 0) then
            PRINT ","
            PRINT "  DW ";
          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: 100
     Total PWM steps: 512
    Gamma correction: .55
    Entries per line: 10
    
      DW   0,  2,  2,  3,  3,  4,  4,  5,  5,  6,
      DW   6,  7,  7,  8,  9, 10, 10, 11, 12, 13,
      DW  14, 15, 16, 17, 18, 19, 21, 22, 23, 25,
      DW  26, 28, 29, 31, 33, 35, 37, 39, 41, 43,
      DW  45, 48, 50, 53, 56, 58, 61, 64, 67, 71,
      DW  74, 78, 81, 85, 89, 93, 97,102,106,111,
      DW 116,121,126,132,137,143,149,155,162,168,
      DW 175,182,190,197,205,213,222,231,240,249,
      DW 258,268,279,289,300,311,323,335,347,360,
      DW 373,387,401,415,430,446,461,478,494,512
    Good luck on your project.

    Cheerful regards, Mike

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT

    Thanks guys (& sorry for the delay in coming back here)

    Quote Originally Posted by Ioannis View Post
    Unless you have all the time of the world, I would not recommend this way.

    LEDs are current controlled devices. PWM is controlling the mean voltage that the LED receives.
    But current doesn't flow without voltage, so in a roundabout way by controlling the mean voltage you are controlling the current.

    Mike...thanks for reminding me (I do recall your spreadsheet now)....it's a really nice utility, but doesn't allow me to go off-piste with some odd curves ....but in the light that there's nothing else forthcoming, I'll likely roll with that again :-)


    Many thanks.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,806


    Did you find this post helpful? Yes | No

    Default Re: How can I achieve this? (hand drawing a curve then mapping values to 1024 LUT

    If you control the current through the LED, the Voltage Drop on the LED will be varied in a very small percetage. Remember that it is a diode with a very steep curve.

    So if you control the voltage drop on the LED, you have to control in steps of mV, in a very small range and NOT in linear fashion.

    If you, on the other hand, control the current the voltage drop is left on the LED to be determined. Also current control can be linear.

    To measure the current, you just need a small resistor in series with the LED and maybe an opamp to amplify it in the levels your ADC needs.

    Then controlling the current (by PWM) of the LED you can get feedback just nicely.

    Or use a cheap IC from ZMDI and control it by your PIC.

    Soon I will have a power LED from Citizen (10 or 25 watts) controlled this way. I'll try to upload a video also.

    Ioannis

Members who have read this thread : 1

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