Scaling and offset of a sensor


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,174


    Did you find this post helpful? Yes | No

    Default Re: Scaling and offset of a sensor

    I think I got it.

    My sensor is read at channel 0. So:

    Code:
    offset    var    word
    sensor    var    word
    
    offset_store:         'offset processing
        adcin 0,offset
        write 0,word offset
    return
    
    read_pressure:
        adcin 0,sensor
        sensor=sensor-offset
        sensor=sensor*1023/(1023-offset)
    return
    the problem is how to manage the sensor*1023 since the result might be more than a word and I'd prefer not to use LONG.

    But the 1023/(1023-offset) ends up in a small number like 1.62 or similar. It is not known untill the offset is measured and cannot be substituted as a constant and use */ operator.

    Ioannis
    Last edited by Ioannis; - 13th March 2023 at 21:08.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,174


    Did you find this post helpful? Yes | No

    Default Re: Scaling and offset of a sensor

    RTFM once again.

    Well, DIV32 is the magic trick.

    I used a dummy var to make the sensor*1023 multiplication, saved the 1023-offset to range variable and did a div32 range.

    Solved.

    Ioannis

Similar Threads

  1. Help with scaling math..
    By ardhuru in forum General
    Replies: 4
    Last Post: - 16th May 2017, 00:41
  2. Offset to variable howto ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 3rd October 2008, 10:36
  3. Scaling ADC values
    By purkolator in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th November 2007, 06:14
  4. Help scaling voltage...
    By sirvo in forum Schematics
    Replies: 6
    Last Post: - 30th July 2007, 20:35
  5. Need help with scaling
    By champion in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th November 2006, 04:20

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