Friday, November 8, 2013

Barometric altimeter application

A precedent article introduced some math about atmospheric models, within this post I will show an Arduino based implementation.
Used absolute pressure sensor is a SCP1000, you can download the datasheet here , this sensor have a digital SPI interface and a range of 30 kPa-120 kPa
This sensor can be incorporated in a ground station, it have an embedded temperature sensor that, accuracy apart, can be useful to experiment with compensation procedures.

This BarometerPDEr2.ino sketch file for Arduino IDE contains all the software needed for altimeter operation.

Hardware is composed by an 3,3 V Arduino Pro running at 8 Mhz and an 3,3V SCP1000 breakout board.
Wiring is straightforward, refer to the next figures.

Figure P21.1 BreadBoard Fritzing file here
Figure P21.1b Wiring Scheme
Figure P21.2 Direct wiring, with serial ftdi interface at 3,3V

The barometer altimeter measures the geopotential altitude, our objective is to measure the geometric altitude. The two values are strictly correlated, denoted \(H\) as Geometric altitude, \(h\) as geopotential altitude and \(RE\) as the local radius of earth hence, according to Warren F.PHILLIPS, 2009, Mechanics of Flight Second edition, Chap 1.2,
$$ h= \frac{REH}{RE+H}$$
hence
$$H=\frac{hRE}{RE-h}$$
Of course for low altitudes the values are numerically very close, many people neglect this conversion.
Another aspect to consider is the calculation of altitude from barometric altitude formula,
the structure of the formula is
$$P=P_0 e^ {-Kh}$$
hence for exact equation solution it is necessary to calculate
$$ln(P/P_{0})=-Kh$$
It's not possible to calculate directly a natural logarithm with Arduino, hence a closed form solution based on power calculation is used. The “correctedaltitude” function in BarometerPDEr2.ino  shows two implementations, one to be used with imperial units and the other with SI.
Supplied sketch will continuously output three different altitude readings in a pleonastic verbose format through the comport. The first kind of reading is the altitude calculated using the standard day conditions of 15° and 101325 Pa at sea level. Second altitude is calculated using sea level pressure from an external source, as weather service, Metar or AWOS, likely in DIY application you can get this information from a ground station at the airfield; this altitude can be referred as compensated for local sea level pressure deviations; in the source code the sea level pressure is stored in “base_pascal” variable. The last altitude type  relies on the fact that the airfield elevation and air temperature are known, an initial calibration routine calculates the value of sea level pressure for best altitude fit; in the source code the current airfield altitude is stored in “FIELD_ALTITUDE” constant.

After the initialization phase the sketch will report the calculated temperature, the calculated pressure at sea level and the sea pressure level value copied, for example, from the weather service. Look the following table for an example output.

<<
Initialization sea level Temperature C 16,2
Initialization sea level pressure Pa 99802
Sea level pressure from weather service Pa 99700
>>
Table P20.1 Arduino sketch output during initialization
This two values are quite similar if you have a good weather report and goods pressure measurements. Pressure information is available through METAR,a network used also by full size planes, here you find a short explanation. For Italy you can consult this site.

During normal operation you will get the following output, in my case fieldaltitude=53 m.
Output recording after some minute of operation.
<<
Raw pressure Pa 99188
Filtered pressure Pa 99185
Temperature C 15
Barometric altitude according, ISA m 185.1039733886
Barometric altitude corrected for pressure at sea level, m 43.8402595520
Barometric altitude corrected, current altitude and temperature known m 53.0040588378
Raw pressure Pa 99181
Filtered pressure Pa 99182
Temperature C 15
Barometric altitude according, ISA m 185.3742523193
Barometric altitude corrected for pressure at sea level, m 44.0986099243
Barometric altitude corrected, current altitude and temperature known m 53.2686004638
Raw pressure Pa 99185
Filtered pressure Pa 99183
>>
Table P21.1 Continuous sampling loop output

For each iteration you get the last reading, the data output from the moving average filter and the three different altitudes.

By inspection of the above table you can appreciate how are different the reported altitudes. It makes no sense to log data without compensation. If you don't dispose of a local landmark you can check your calibration against a geodetic network referral point.

The Arduino based circuit can be conveniently boxed for a better usability, as per the following figure, do non forget to drill slots to allow correct ventilation.
Figure P21.3 Arduino altimeter ready to be connected to a ground station PC
In the case you want to minimize overall dimensions and weight then you can use an Arduino pro mini directly soldered to your sensor, look to the below figure for a size comparison.
Figure P21.4 Arduino pro mini vs SCP1000 breakboard dimensions
Atmospheric model assumptions are strong and it's not easy to check for deviations from the model itself, nevertheless it's possible to evaluate how the sensor uncertainty will impact on the calculated altitude. The SCP1000 is setup to run in the high speed mode, a 15 bit resolution is expected;this resolution corrresponds to 2.1Pa. Let's pretend our error probability function is rectangular symmetric(uniform)  then, using the resolution value as optimistic error bound, is possible to calculate the deviation  \(\sigma_{P}=\frac{3,6}{\sqrt{3}}=2,1 Pa\).  For a detailed description have a look to this document page 13 example 1.
Using the uncertainty propagation formula
$$\sigma_{h}=\sqrt{(\frac{dh}{dP})^2\sigma_{P}^2}$$
$$\frac{dh}{dP}=-0,190255P^{-1,190255}101325^{0,190255}(T_{0}+273,15)/0,0065$$
With a pressure reading of 100000Pa and in standard day conditions then
\(\sigma_{h}=0,17m   k=1\)
Widening the coverage \(\sigma_h=0,51m  k=3\).
A complete tools suite for altitude measurement has been introduced, some compensation methods have been tested. This introduction evidentiates how a good instrument initialization can impact on measure
Let me know if you have some problem with your own altimeter.
Post a Comment