Help with the conversion math


Closed Thread
Results 1 to 31 of 31

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    And this 65472, isn't the 1023 with left justification?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    At page 157 of the Data sheet, it is shown that the PIC defaults to ADFM at 0 (zero), so it is really Left Justified by default. You have to make it a 1 for Right Justified result.

    The register is the ADCON2 and bit 7.

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Just for grins I took a 10K resistor and fed the A/D input pin with 5 volts. The reading I got was 65472!
    Yes, because you have the freaking thing configured wrong for the way that ADCIN works for crying out loud :-)
    Just set the justification bit correct, as Ioannis shows AND as we've already discussed in the other thread where we went thru all this resolution and justification stuff last time.

    OK, so it's a 0.07psi and not 7psi as I based my code around..... Well, then we need to change the scaling but lets see if it works at all first.

    /Henrik.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,728


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    that works out pretty nicely every adc 100 count is almost exactly .01 psi

    0=110 , 0.07 = 820 couldn't be easier


    assuming I read the data sheet properly and that 0.07 psi = 4.0 volts and vref=5 v of course
    Last edited by richard; - 25th November 2014 at 06:49. Reason: still can'y type

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Quote Originally Posted by richard View Post
    that works out pretty nicely every adc 100 count is almost exactly .01 psi

    0=110 , 0.07 = 820 couldn't be easier


    assuming I read the data sheet properly and that 0.07 psi = 4.0 volts and vref=5 v of course
    Not quite Richard. In theory

    0=102.4 at 0.5 volts and 0.07=921.6 at 4.5 volts.

    assuming as you say the vref=5 v.

    102.4 is the zero offset and 0.07/(921.6-102.4) is the slope.

    to convert to psi

    psi=(reading-offset)*slope

    psi=(reading-102.4)*0.07/819.2

    psi=(reading-102.4)*0.0000854492.....

    I do seem to remember this is for a depth gauge on a model submarine and am wondering what depth of water is 0.07 psi. The answer is 100 mm of water (99.54mm).

    Giving

    mm of water=(reading-102.4)*0.12207028.....

    just to check at maximum reading = 921.6

    therefore

    mm of water=(921.6-102.4)*0.12207028

    mm of water=99.9999

    I am now wondering if this gauge is suitable?

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


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Quote Originally Posted by EarlyBird2 View Post
    I am now wondering if this gauge is suitable?
    0.07 psi gauge surely is a differential one ... so, one could reasonnably think it's for measuring SPEED with a pitot tube ...

    just my two cents ...

    Hi, Ed

    Why not download that jewel ???
    http://curveexpert.software.informer...nload/?ca13e51

    Alain
    Last edited by Acetronics2; - 25th November 2014 at 20:49.
    ************************************************** ***********************
    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
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Hi! So if I understand correctly I need to use ADCON2 instead of ADCON1 with the same bit configuation? Yes Alian your are completely correct! It is a differntial sensor for my submarine. As the sub dives you need to subtract out the pressure at a given depth for the incoming pressure to stay meaningful.

Similar Threads

  1. AD conversion
    By CipiCips in forum mel PIC BASIC
    Replies: 8
    Last Post: - 19th May 2011, 01:09
  2. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  4. conversion
    By pramodsinha in forum Forum Requests
    Replies: 2
    Last Post: - 19th January 2006, 15:58
  5. ºC -> ºF Conversion
    By CocaColaKid in forum General
    Replies: 6
    Last Post: - 15th March 2005, 09:42

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