View Full Version : Conversion from millibars or inches mercury to kilopascals

08-01-2006, 09:28 AM
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.


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, [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, [MoveTo,0,38 ,"AT in Hg ", DEC PRESS_Hg_100/100, ".", DEC PRESS_Hg_100//100, CR] 'and display


The complete program is attached. Thanks for any replies!

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

08-01-2006, 11:28 AM
A google search gives http://forums.parallax.com/attachment.php?attachmentid=74082

So you could do:
SEROUT TxD, Baud, [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, [DEC PRESS/10,".",DEC PRESS//10]


08-01-2006, 12:39 PM
Yes, I saw the stuff on google as well - just didnt know how to change it to what the stamp uses, like you did :D
But I learn a little more every day.....

Ahhhh that works great!
Thank you!