Stuck on porting code to 18F4520


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stuck on porting code to 18F4520

    Hi Guys,

    I've stumbled on a small issue that is doing my head in.

    Whilst using 8 bit resolution for the fading (ie 0 - 255) the code works and allows a minimum fade up / down time of 5 minutes, I now want to increase the resolution to 4095 steps.

    Code:
    blue_delay_in = fadesetHR[0] * 3600 + fadesetMN[0] * 60 / 255
    white_delay_in = fadesetHR[1] * 3600 + fadesetMN[1] * 60 / 255
    blue_delay_out = fadeoutHR[0] * 3600 + fadeoutMN[0] * 60 / 255
    white_delay_out = fadeoutHR[1] * 3600 + fadeoutMN[1] * 60 / 255
    If the above is changed by removing the 255 at the end of each line and replacing that with 4095 it means the minimum fade in/out time is now 68 minutes as anything less results in an FP decimal which isn't supported by PBP

    The resulting value for blue_fade_in etc is then used in the case statements to perform the PWM

    Code:
    case DAWN 
    lcdout $FE,$80+15,"DAWN "   
    if ss//blue_delay_in = 0 then
    if ss != old_ss_blue then
    B_PWM=B_PWM+1
    old_ss_blue=ss
    endif
    endif
    if B_PWM = B_Mid then
    Blue_Day_Cycle = MORN
    endif
    Is there anything I can do to the code as it stands to get the timing so that I can use the 4095 resolution, and still have fade in/out times of 5 minutes or more rather than 68 minutes.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Stuck on porting code to 18F4520

    Could this be a byte VS word issue?

    Sorry, falling asleep.

    Robert

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stuck on porting code to 18F4520

    Hi Rob,

    Yes I've changed the variable from byte to word.

Similar Threads

  1. Porting code to new PIC
    By malc-c in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 31st December 2010, 23:20
  2. Kind of stuck
    By gti_uk in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st May 2009, 20:45
  3. Getting Stuck in loop
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 19th November 2008, 15:46
  4. Any idea's on porting this to PBP?
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th October 2008, 19:21
  5. Replies: 1
    Last Post: - 8th May 2008, 00:52

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