Shop OBEX P1 Docs P2 Docs Learn Events
Convert A/D result to pressure — Parallax Forums

Convert A/D result to pressure

ArchiverArchiver Posts: 46,084
edited 2002-03-01 00:06 in General Discussion
>I've got a 12 bit A/D which is getting 0-4 volts from a pressure
>sensor. I want to display the pressure from 0 - 30 PSI but am
>having some problems with the conversion formula. Do I multiply the
>reult by .976 milivolts? If so how is that done. Thanks in advance!

That would give you millivolts. More likely you will want psi
directly, so multiply times 0.0073242 (=30psi/4096 counts). Probably
also you want the result calculated in units of 0.01 psi, or better.
That means multiply the raw count times 0.73242. In Stampese that is:
psi100 = rawCount ** 48000
debug psi100/100,".",dec2 psi100,cr


(ratio for **: 48000/65536 = 3000/4096)


-- best regards
Thomas Tracy Allen PhD
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-02-28 23:42
    I've got a 12 bit A/D which is getting 0-4 volts from a pressure sensor. I
    want to display the pressure from 0 - 30 PSI but am having some problems with
    the conversion formula. Do I multiply the reult by .976 milivolts? If so how
    is that done. Thanks in advance!


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-01 00:06
    In a message dated 2/28/02 3:40:39 PM Central Standard Time,
    ricky@m... writes:


    > I've got a 12 bit A/D which is getting 0-4 volts from a pressure sensor. I
    > want to display the pressure from 0 - 30 PSI but am having some problems
    > with the conversion formula. Do I multiply the reult by .976 milivolts?
    > If so how is that done.

    There are two operators that allow you to multiply by fractional values --
    but both return integer results. If you multiply the result by 9.76 (tenths
    of millivolts) that's what the units result value will be. Here's a quick
    demo of both operators.

    a2d var word
    result var word

    a2d = 4095
    result = a2d */ $9C2
    debug dec result / 10000, ".", dec4 result, cr, cr

    result = (a2d * 9) + (a2d ** $C49C)
    debug dec result / 10000, ".", dec4 result


    The star-slash operator multiplies by units of 1/256; the star-star operator
    multiplies by units of 1/65536. I personally find that I end up tweaking the
    */ or ** parameter to give the best results based on test input. This, of
    course, is affected by your desired precision.

    The best practical explanation of these operators is on Tracy Allen's site.
    Tracy builds very cool dataloggers with the BASIC Stamp and has solved more
    of these tricky math problems than most of us will encounter.

    http://www.emesystems.com/BS2index.htm

    -- Jon Williams
    -- Parallax






    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.