Offset to variable howto ?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1

    Default Offset to variable howto ?

    Hi all

    I have the following problem

    I read an ADC 10bit but would like to add an offset and keep the 10bit resolution

    When the ADC value is smaller than the offset value I got a wrong indication on the LCD
    substraction is going negative
    any idea how i can solve this ?

    eaxample:
    offset: 200
    if ADC = 512 - offset = 312 => no problem
    if ADC = 180 - offset = -20 => wrong value

    So i would like to keep the 10bit resolution but just shift it with the offset value ?


    Thanks

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    See {I} {S} DEC {1..10} in the LCDOUT (and others) section of the manual.

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RFsolution View Post
    I read an ADC 10bit but would like to add an offset and keep the 10bit resolution
    eaxample:
    offset: 200
    if ADC = 512 - offset = 312 => no problem
    if ADC = 180 - offset = -20 => wrong value
    This is not addition !!

    JF

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Ok you are right it is not addition but I mean

    the 10 bits 1024 represents a position from a potmeter
    in order not to change the fysical position i would like to add or substract an offset
    but finnaly need to keep the 10bit resolution for further calculation
    But I dont now how to do that

    any help welcome

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Ok, I think I understand it now. You want to move the physical position of the pot in code.
    You will be able to offset the reading. But the part that you've discarded due to the offset will be lost, so you cannot expect the full 10bits once you do this.

    JF

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Question Crystal ball needed

    Quote Originally Posted by RFsolution View Post
    Ok you are right it is not addition but I mean

    the 10 bits 1024 represents a position from a potmeter
    in order not to change the fysical position i would like to add or substract an offset
    but finnaly need to keep the 10bit resolution for further calculation
    But I dont now how to do that

    any help welcome
    Hi, RF

    Could you be more precise about what you want to do ...

    The physical position of WHAT ???

    i.e. read a pot with ADC , and from this reading show the pot angle, then place a servomotor's arm ... or what ???

    Skimask's answer is one of the numerous possibilities ... consider it !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Hi Alain and others

    Well I read a potmeter or other position encoder which is 10bit for full resolution
    or equal to 1 single turn

    Later I will convert this to Degrees (which is no problem)
    But i would like to keep the maximum resolution to 10bit
    but shift in the software the actual position instead of moving the potmeter mechanicaly

    example

    0 deg = 0V, 5V = to 360 (1024) or 10bit

    imagine that the true 0 degree is at a value of 120 (decimal) and I dont want to move
    the mechanical position of the potmeter but would like to see 0 as a decimal value
    SO i would like to implement an offset of 120 decimal
    whitout touching the 1024 10bit resolution for 1 revolution

    I hope this is more clear

    Walter

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    So why not ADD an offset of 120 (using your example)...

    That way zero will be in reality -120, 120 will be zero, and 240 is actually +120 ???

    This way you will never go below zero, because zero is your REAL reference point, and your offset value is actually your mechanical zero.

    Simple maths prior to displaying the figures will have it display whatever you want it to display.

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