Offset to variable howto ?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Ok played a bit following your help,

    and this code works, actually it was quit simple but did not found it =(

    Assuming that the given offset is positive but that's enough as you can go 360 degrees in total:


    loop:
    Offset = 400 ' example add 400 as offset
    gosub read_position ' get the position: 10bit 0=0deg, 1024 =360deg
    gosub set_offset
    goto loop

    set_offset:
    position_temp = position + offset
    if position_temp => 1024 then
    Position_cor = position_temp - 1024
    endif
    if position_temp <= 1024 then
    position_cor = position_temp
    endif

    Seems to work very well

    Thanks for your help,and nice to learn from others

    Walter

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RFsolution View Post
    position_temp = position + offset
    That was one of my solutions, but since I couldn't see the program, the whole program, and nothing but the program, I wasn't sure.
    The other answer would've been whether or not you were defining your variables as BYTEs or WORDs.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi skimask

    I was thinking about the following feature:

    imagine the encoder is mounted in the opsit way
    so the the real 10bit value is increasing while it should decrease

    Any idea how to reverse this

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. HSEROUT full 3 digit display of variable howto ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th October 2008, 13:53
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21

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