Linearizing an LED for 800 pwm steps'?


Results 1 to 37 of 37

Threaded View

  1. #23
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

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

    Hi Mike,
    exactly
    I haven't got a 12f683 to hand .... I'm still a rather weak/n00by programmer, so wondering what exatly that program is you've posted?!!!

    I tried 1024 PWM levels with a gamma (0.8 & 1.6), but actualy neither of them seemed to fade any better than what I had in place already (which was some anti log kludge).

    The hassle for me here is converting any lookup table to a DW table (to be able to use lots of available code space to store the lookup values), presently, I'm doing the test curves in excel, then saving to a csv...but my version of excel only allows 256 columns wide, so I have to put 1024 values the curve on 4 rows, then save it as a csv.

    Worse still the 'DW' command seems to have a restriction of somewhere in the order of 70 bytes per line entry, so I can't just use a hulking 256 byte long lines, but having to break the 4 long CSV lines, into smaller snippets....

    Code:
        DW 0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11
    & so on...what I really need is to knock up a program that takes an excel 'column' 1024 deep coverts it into blocks of lines 70 bytes long (like the above) all rpefaced with a DW on the front...because presently it's about 30 minutes work just to trial a different curve - it get tiring very quickly!

    While I'm here, can anyone field an elegant way of rescaling....let's say I have 10 bit ADC that I want to scale to a maximum of 800 PWM steps (if you are wondering what I'm trying to achive....a max LED brightnesss setting ...I hoping to have a maximum PWM value (which will differ depending upon the maximum brightness setting required) & need to rescale the incoming ADC to it ...therefore a MAX ADC value of 1023 -> max PWM value of 800 (or 600, 400...whatever I've chosen to be the maximum PWM value)....it's easy to outside of picbasic...

    (max PWM value/1023) * incoming ADC value ...but the first part of the caclulation results in a floating point number. (for example 800/1023 = 0.78201368523949169110459433040078 !!!) ....now I realise you have to gear everything up, but just wanted a little bit of guidance how this is done in Picbasic to set me on my way!
    Last edited by HankMcSpank; - 10th March 2012 at 20:32.

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