Conversion from millibars or inches mercury to kilopascals
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.
The complete program is attached. Thanks for any replies!
Post Edited (Robert@HCC) : 8/1/2006 2:32:05 AM GMT
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
bsp
![](/plugins/FileUpload/images/file.png)
8K
Comments
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
But I learn a little more every day.....
Ahhhh that works great!
Thank you!
Robert