General Question

bpeoples's avatar

Solving the Barometric Equation for the standard atmosphere for altitude?

Asked by bpeoples (2551points) August 31st, 2007
8 responses
“Great Question” (0points)

Hi,
Another super-geeky question for the jellies:

I’m trying to come up with a general solution (that I can implement in c on a microcontroller) to solve for the altitude when I only have the pressure.

I only need to solve it in zone 0 (0–36k feet), but the h term is tied up in an exponent, and I can only find the barometric formula solved for pressure. Here’s what I’ve got (imperial, sorry, since I’m solving for feet):

P = 29.92126 * (288.15 / (288.15 * -0.0019812*h))^(-5.225)

But I can’t work out how to extract the h from the 5.225 without taking the 5.225-th root of it, which seems like there should be a simpler way involving log?

I’ve considered just logging the pressure, and then when the data downloads doing a lookup table, but it’d be nice to be able to have the uC flash out it’s current/highest altitude.

Thanks!

Observing members: 0
Composing members: 0

Answers

bpeoples's avatar

One solution I found, but haven’t cross-checked it is:

alt(feet) = (1 – ( (P/1013.25)^0.190284) ) * 145366.45

P in hPa…

bpeoples's avatar

Okay, ran a table of the upper equation vs. the lower equation (feeing the pressure result of the first into the second equation)—looks like it works. There’s an error (probably rounding) of around -0.04% between the two. It becomes a problem at around 20k feet, where the error is about 10 feet (the resolution of my sensors)

mvgolden's avatar

Yes Logs will help. For a quick lesson in log algebra check http://www.gomath.com/htdocs/ToGoSheet/Algebra/exponent.html

I think it works out to

Log P = Log 29.92126 * (288.15 / (288.15 * -0.0019812*h))^(-5.225)

Log P =-5.225 * Log 29.92126 * (288.15 / (288.15 * -0.0019812*h))

Log P / -5.225 =Log 29.92126 Log (288.15 / (288.15 * -0.0019812*h))

Log P / -5.225 – Log 29.92126 = Log 288.15 – Log (288.15 * -0.0019812*h)

- [Log P / -5.225 – Log 29.92126 – Log 288.15 ] = Log 288.15 Log -0.0019812 log h

- [Log P / -5.225 – Log 29.92126 – Log 288.15 ] – Log 288.15 – Log -0.0019812 = log h

10^ {- [Log P / -5.225 – Log 29.92126 – Log 288.15 ] – Log 288.15 – Log -0.0019812 } = 10^log h = h

Check my math, but It hink that should cover it

finkelitis's avatar

mvgolden’s solution should work. However, there’s a wrinkle with taking log of a negative number—you can’t really take Log(-0.0019812). Your initial formula has you taking a negative root of a negative number as well, which gives a complex answer (i.e. one that involves imaginary numbers), which means you probably have an extra minus sign somewhere in your original formula. It’s also possible that h comes out as a negative number (are you measuring height from the top down?).

If you can deal with that minus sign, then mvgolden’s answer will work.

mvgolden's avatar

finkelitis, you’re right. I missed that. Something looks weird in the original formula

bpeoples's avatar

Yeah, I think there’s a typo there. It is reasonable for h to be negative, since if the pressure exceeds 1013.25 millibar, the “standard atmosphere” says you’re below sea level.

The error in my formula is actually this term: (288.15 * -0.0019812*h) which should be (288 – 0.0019812*h)—it should never go negative, as it’s only valid for 0 < h < 36089

mvgolden's avatar

so you are all set?

bpeoples's avatar

Heh—I think so… Thanks!

Answer this question

Login

or

Join

to answer.

Mobile | Desktop


Send Feedback   

`