Help with the conversion math


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    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?

  2. #2
    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 " !!!
    *****************************************

  3. #3
    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.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    You mean that at page 156 of the datasheet you saw ADCON1 and at page 157 ADCON2 and concluded that are the same at bit 7 ? They are not and must be setup accordingly to your needs ALL of them. DO NOT rely on power up defaults.

    You have to set if not all, the most registers for the PIC to work as expected.

    ADCON0, ADCON1, ADCON2 should ALL be set as YOU desire, NOT the PIC's default state. Each register has its own bits for different setting. Otherwise why have dozens of registers if they were all the same?

    Ioannis
    Last edited by Ioannis; - 26th November 2014 at 06:15.

  5. #5
    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 Ioannis,
    This is my very first attempt at using the PIC's A/D.
    I think that ADCON0 should be 000100?1 as I am not sure what "GO/DONE" should be set at.
    ADCON2 looks like it should be 11101010 and again I am not certain of the last 3 bits.

    Thanks, Ed

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Ed,

    Settings depend on your hardware and software requirements.

    E.g.: Do you have internal or extrernal Vref for the ADC? If it is internal and you want the Vref to be at Vdd and ground span, you should set VFG1:0 as 00.

    So, I will try to give you an approach and if it is not close to your circuit we can change it.

    ADCON0: %00000001 ' This sets the ADC channel to 0 (AN0) reference at power supply and converter is ON, ready to convert.
    ADCON1: %00000001 ' All inputs digital except channel 0 (AN0)
    ADCON2: %10110010 ' Right justification, 16Tad acquisition time, Fosc/32 to be safe.

    Now, when all this are setup, you only have to set the GO/DONE bit (ADCON0.1=1) and wait until it is cleared (WHILE ADCON0.1:WEND).

    Then get your 10bit result from the ADRESH/ADRESL registers or the variable you use in ADCIN.

    Ioannis

  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 Ioannis!
    Thank you!
    The connections are very simple, the sensor output is connected to pin 8 (AN4) of the 18F1320.
    So to me this would make ADCON0: %00010001.
    Then ADCON1: %11101111, all inputs digital except channel 4 (AN4) which would be set to analog.
    Then ADCON2: %10110010 as you wrote.

    Or did I misunderstand something completely?

    Again, Thank you for all the time you are spending with me.

    Ed

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