Word Variable and I2C


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Word Variable and I2C

    Henrik, thanks again for the reply.

    Using the code in my last post (#5) the LED on channel 1 of the PCA chip fades up, all the way until pcaPwmValue reached 4096. At 4097 it went off, and as it increased (now at 6745) the LED on channel 1 has lit up but not on full brightness. What I can't understand is I have a B_MAX variable which has a value of 4095, with an "If B_PWM=B_MAX then doe something else statement which seems to be ignored. I was reading up on the variable statement and the manual comments that there is a size statement, with the use of additional modifiers, but I couldn't find any decent examples. Is there a way of simply limiting the word to 4095 something like B_PWM VAR Word size 4095 ??

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Word Variable and I2C

    Hi,
    Is there a way of simply limiting the word to 4095 something like B_PWM VAR Word size 4095 ??
    Two ways that I can Think of right now, your way which you've somehow implemented wrong and the way I tried to explain in my previous post.

    Code:
    IF pcaPwmValue >= 4095 THEN pcaPwmValue = 4095   ' Clamp value at 4095
    LCDOUT $FE,$D4+0,"PWM ",dec pcaPwmValue
    Or....

    Code:
    pcaPwmValue = (B_PWM & 4095)    ' Roll over value at 4095
    LCDOUT $FE,$D4+0,"PWM ",dec pcaPwmValue
    By your explaination it sounds as if the PCA chip is basically doing what the second approach above does, ie start over at 4096 and again at 8192 and again 12288 and so on.

    /Henrik.

Similar Threads

  1. Stumped with word variable
    By Scampy in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 11th November 2013, 14:11
  2. Word variable and storing correct value
    By Scampy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2012, 13:04
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 12:20
  4. adding new word variable ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 21st February 2008, 01:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

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