Help with scaling math..


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    448

    Default Help with scaling math..

    Hi guys,

    I have a home made capacitive sensor I intend to use to measure the depth of water with.

    Seems to work fine, but here is the issue.

    I am *not* interested in the absolute value of the capaity in terms of uF or nF etc.

    The test sensor is a foot long; when it is completely out of the water reservoir, I get a value of 10. This would be the capacity created by the cable, connector etc.

    When its fully immersed, the value is 60.

    Now, I need to output the reading on a scale of 1 to 100, as a percent. So, 10 would correspond to 1 (or 0?), and 60 to 100.

    Therefore, is calculating the percent as simple as (Actual_Reading-Reading_Min)*100/(Reading_Max-Reading_Min)?

    I plotted the actual readings taken at 0%, 25%, 50%, 75% and 100%, and the expected computed values, and there is a slight discrepency.

    X axis is the inches of the probe under water, and y axis is the reading.

    Is there a better way of scaling, as against the formula I've used, for a better fit?

    Name:  2017-05-15_131532.jpg
Views: 414
Size:  24.4 KB

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


    Did you find this post helpful? Yes | No

    Default Re: Help with scaling math..

    How about: Percentage = (ActualValue - 10) * 2 ?

  3. #3
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Help with scaling math..

    Hank, your formula gives blue line, If I understand correctly, he want red.
    You can try to get more precision formula of red curve in excel. Look what is best approximation, and which you can implement in code. I'll start with polynomial equation, because it easiest to implement.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Help with scaling math..

    Right. I don't know if the chart showed the actual values of the measurment or the values output by the formula used.
    In either case I don't quite understand the X-axis scale of that chart, I would've expected it to end at 100% not 120%.

    If it's the values of the actual measurments it seems to "just" be a dual slope line so it shouldn't be too hard to apply to decide if you're below or above the "knee" and act accordingly. If there's more curve to it than that a lookup table should do it and since it's not really that many values (only 50) there's really no need to do any interpolation between points.

    I'd like more data before trying to come up with a solution though. Like a table with the raw value, as seen by the PIC, for every 10% from 0-100.

    /Henrik. Not Hank :-)

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Help with scaling math..

    your chart with equation.... how to remove first image???

    Name:  Capture.JPG
Views: 403
Size:  60.1 KB
    Attached Images Attached Images  
    Last edited by amgen; - 16th May 2017 at 01:04.

Similar Threads

  1. Scaling ADC Result to a Set Range
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 20th February 2016, 02:09
  2. strange A2D 5V scaling result - 16F819
    By Max Power in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th April 2010, 03:28
  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 : 2

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