Help with the conversion math


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,623


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Yeah, deja vu indeed....

    Ed,
    * The resolution of the ADC is 10 bits.
    * It does not return a reading directly in Volts.
    * Basically it takes the difference between Vref+ and VRef- and divides that by 1024 (2^10, the resolution of the ADC). Each "count" in the value is then "worth" that amount.

    So, if VRef- is GND (0V) and VRef+ is 5V the difference between the two is 5V. Each "count" in the ADC result is then "worth" 5/1024=4.88mV.
    If the ADC returns 745 the voltage at its input is 5/1024*745=3.638V

    I can't make out anything from that datasheet, it's just garbage numbers when viewed on my machine. I managed to find this one. And, I'm guessing you've got the 7psi sensor, correct? If so then something like this might work. I have not tested it though so all bets are off....

    Of course you need to configure pins etc as usual (!)

    Code:
    Accumulator VAR WORD
    i VAR BYTE
    ADResult VAR WORD
    
    Accumulator = 0
    
    Main:
    
    For i = 0 to 39
      ADCIN 4, ADResult  
      Accumulator = Accumulator + ADResult
      PauseUs 500
    NEXT
    
    ADResult = Accumulator / 10   ' Psuedo 12bit resolution, ADResult is now 0-4092
    
    ' Sensor outputs 0.5V (ADResult=409 ) at 0psi (nominal)
    ' Sensor outputs 4.5V (ADResult=3683) at 7psi (nominal)
    
    ADResult = ADResult - 409   ' Offset for zero output, ADResult is now 0 to 3274 for 0 to 7psi
    ADResult = ADResult */ 547  ' Scale up, ADResult is now 0 to 6995 for 0 to 7psi 
    
    ' Display Pressure: x.xx psi
    HSEROUT["Pressure: ", DEC ADResult/1000, ".", DEC2 ADResult//1000, "psi", 13]
    
    PAUSE 1000
    
    Goto Main
    /Henrik.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Quote Originally Posted by HenrikOlsson View Post
    Yeah, deja vu indeed....


    I can't make out anything from that datasheet, it's just garbage numbers when viewed on my machine.

    /Henrik.

    ditto for the pdf
    do we have a 54A L07H2210 or a 54ALL07H2210 or a 54AL007H2210 or a 54A 007H2210 ?
    they are all different animals and the 54ALxxx are 3.3v devices

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

    PDF works for me.

    The sensor is a 0.07 psi low voltage range with output from 0.5-4.5V

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


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    that makes it a "54A L07H2210" not what was posted , its best to be sure

    steve can you read the characteristics in the data sheet ,that what comes out garbled for me
    Last edited by richard; - 24th November 2014 at 10:57.

  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

    '* Notes : For a 18F1320 and 54AL07H2210 *

    was it not?

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    this is what I mean
    Attached Images Attached Images  

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,623


    Did you find this post helpful? Yes | No

    Default Re: Help with the conversion math

    Is this not a repeat of the left and right output justification as on the previous thread in Richard's link.
    Yes, that's exactly what it is. The reason for the results have been covered in that thread but not a way to end up with a correct pressure reading - which is still kind of hit and miss since we need specific details no the actual sensor used.

    /Henrik.

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

    Is this not a repeat of the left and right output justification as on the previous thread in Richard's link.

    7040 left justified is 110 right justified using Henrik's 4.88mV then

    110*4.88/1000=0.5368 V

    Or put another way 7040/64=110 which shifts the 10 bit left justified result 6 bits to the right making the result the same as a right justified result.

Similar Threads

  1. AD conversion
    By CipiCips in forum mel PIC BASIC
    Replies: 8
    Last Post: - 19th May 2011, 02:09
  2. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 02: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, 11:22
  4. conversion
    By pramodsinha in forum Forum Requests
    Replies: 2
    Last Post: - 19th January 2006, 16:58
  5. ºC -> ºF Conversion
    By CocaColaKid in forum General
    Replies: 6
    Last Post: - 15th March 2005, 10: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