Smooth LED fading via PWM


Closed Thread
Results 1 to 40 of 55

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    So if I want to store a (ser defined) setting that will remembered after the battery/power source has been removed from the PIC ..is EEPROM is my only option?

    If so, I have a problemette...I presently have 256 bytes that already goes into EEPROM at program time..

    Code:
    Data 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, _
      1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3, _
      3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,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,9,9, _
      9,9,10,10,10,10,10,11,11,11,11,12,12,12,13,13,13,13, _
      14,14,14,15,15,15,16,16,16,17,17,18,18,18,19,19,20,  _
      20,20,21,21,22,22,23,23,24,24,25,26,26,27,27,28,29,  _
      29,30,31,31,32,33,33,34,35,36,36,37,38,39,40,41,42,  _
      42,43,44,45,46,47,48,50,51,52,53,54,55,57,58,59,60,  _
      62,63,64,66,67,69,70,72,74,75,77,79,80,82,84,86,88,  _
      90,91,94,96,98,100,102,104,107,109,111,114,116,119,  _
      122,124,127,130,133,136,139,142,145,148,151,155,158, _
      161,165,169,172,176,180,184,188,192,196,201,205,210, _
      214,219,224,229,234,239,244,250,255
    ok, my first problem is, there's 256 bytes there...which maxes my EEPROM out. (16F1828)

    Now assuming i have no other way of storing a user chosen varaiable after the power has been removed (other than EEPROM), THEN I suppose I will need to forsake one of the 256 bytes in that table above ...therefore 255 bytes + 1 byte that the user chooses (& gets stored away when he presses a switch).

    But how do I control all of this. In other words if I trim the above from 256 bytes, to 255 bytes to free up one byte of EEPROM space, then the 255 bytes will go straight into EEPROM as it does now ....but how do I store the remaining (user defined) byte in the last available slot of EEPROM?

    Sorry for n00by flavour here...but a prolific search didn't yield much that I can digest/apply to this conundrum.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    Hank do you have any code space left?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    Hi Bert,

    Yes, it's getting tight, but about 400 bytes left....

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    Seems like the easy way out will be to store all or part of your table in code. Maybe that is DAT? Then you have some EEeprom left. Next up, how about compressing that data somewhat. Maybe use 2 bytes for each unique number. Ie
    10,1,8,2
    So the 10 means there are 10 1's 8 2's and so forth. But since I don't know how you are using the data it's hard to guess at that.

    As for writing the user variable to EEPROM, there is a command for that. Can't think ou it off the top of my head.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    Hank, just skimmed over the post and I see I have steered you back to where you were. Sorry for that. How are you usin the data? Maybe we can compress it. Are you using it in order or random access?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    Quote Originally Posted by cncmachineguy View Post
    As for writing the user variable to EEPROM, there is a command for that. Can't think ou it off the top of my head.
    Maybe the WRITE command.......
    Thanks and Regards;
    Gadelhas

  7. #7
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default Re: Smooth LED fading via PWM

    I think instead of having 31 consecutive memory locations that contain a "1", I'd just store the first 1 and arrange my code so that when it looks up those locations they all point to the one slot that actually contains the "1".

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