Shop OBEX P1 Docs P2 Docs Learn Events
Conversion from millibars or inches mercury to kilopascals — Parallax Forums

Conversion from millibars or inches mercury to kilopascals

Robert@HCCRobert@HCC Posts: 80
edited 2006-08-01 05:39 in General Discussion
I am using a MPX4115 Pressure sensor, MAX407 OpAmp and a LTC1298 ADC to get atmospheric pressure. My setup works better than I could have desired - but for one thing...my math sucks big time, and the code I have only displays the data in milibars and inches mercury.

Anyone care to take a stab at this and tell me how I can get kilopascals out of this conversion ?

AD_AVG is the raw dat from the ADC (256 samples that are averaged, then stored in AD_AVG). Offset is the calibration value to adjust for difference in my location's pressure versus a known pressure@sealevel.



Main:


  AD_COMMAND = $0D                                                        ' Ch 0 relative to ground
  GOSUB MEAS_AD0                                                          ' perform 256 measurements and average


  PRESS = (2*AD_AVG/10) + (7 * AD_AVG/100) + 105 +41 + Offset             ' Calculate At. Pressure in millibars, subtract error correction figure..
  SEROUT TxD,Baud, [noparse][[/noparse]MoveTo,0,37, "AT millibars   ", DEC PRESS, CR]                                    ' and display


  PRESS_Hg_100 = (7*AD_AVG/10) + (9*AD_AVG/100) + (7*AD_AVG/1000) + 295 + Offset    ' Calculate At. Pressure in inches mecury,..
                                                                                    ' subtract error correction figure..
  SEROUT TxD,Baud, [noparse][[/noparse]MoveTo,0,38 ,"AT in Hg   ", DEC PRESS_Hg_100/100, ".", DEC PRESS_Hg_100//100, CR]            'and display

RUN 1




The complete program is attached. Thanks for any replies!

Post Edited (Robert@HCC) : 8/1/2006 2:32:05 AM GMT

Comments

  • Harrison.Harrison. Posts: 484
    edited 2006-08-01 04:28
    A google search gives attachment.php?attachmentid=74082

    So you could do:
    SEROUT TxD, Baud, [noparse][[/noparse]DEC PRESS/10," kpa"]

    Unfortuantely this causes a loss of precision and significant figures.· So you have to preserve the decimal after calculation.· So use:
    SEROUT TxD, Baud, [noparse][[/noparse]DEC PRESS/10,".",DEC PRESS//10]

    Harrison
    606 x 32 - 769B
  • Robert@HCCRobert@HCC Posts: 80
    edited 2006-08-01 05:39
    Yes, I saw the stuff on google as well - just didnt know how to change it to what the stamp uses, like you did [noparse]:D[/noparse]
    But I learn a little more every day.....


    Ahhhh that works great!
    Thank you!

    Robert
Sign In or Register to comment.