Freescale Semiconductor Application Note AN1979 Rev 3, 11/2006 Altimeter and Barometer System by: Michelle Clifford and Fernando Gonzalez Sensor Products Division, Tempe, AZ INTRODUCTION With smaller packages and lower costs, pressure sensors can be designed into more consumer applications. This document describes a reference design for a digital barometer and altimeter using the MPXM2102A pressure sensor in the low cost MPAK package, a quad op-amp, and the MC68HC908QT4 microcontroller. This system continuously monitors the barometric pressure and compares it to previous pressure readings to update altitude and weather predictions. This reference design enables the user to evaluate a Freescale Semiconductor, Inc. pressure sensor for barometer, personal weather station and altimeter applications. This reference design also allows customers to evaluate barometer pressure readings obtainable from the MPXM2102A sensor for watches or GPS systems with this feature. In addition, many systems require barometric pressure data to correct system response errors. This application note describes the reliability and accuracy that our sensors can provide in this system. SYSTEM DESIGN Pressure Sensor The barometer/altimeter system requires a pressure sensor that has a pressure range of 64 kPa to 105 kPa. Freescale Semiconductor, Inc. has a broad portfolio of silicon piezo-resistive pressure sensors. They provide a very accurate and linear voltage output directly proportional to the applied pressure. By evaluating the application design and cost, the right pressure sensor can be selected from our portfolio. measures changes in ambient pressure, we need a known pressure reference. Therefore, an absolute pressure sensor was selected. Freescale offers three levels of integration: uncompensated, compensated, and integrated. Since there can be large temperature changes from one elevation to another the sensor for this reference design needs to be offset calibrated and temperature compensated. Therefore a compensated sensor was selected requiring external amplification circuitry. However, integrated solutions such as the MPXM5100A, can also be considered, thereby eliminating the need for the external amplification circuitry. Knowing the range of pressure, the type of pressure measurement, and the level of integration required for this application, the MPXM2102A sensor was selected. The sensor has both temperature compensation and calibration circuitry on the silicon and is capable of producing a linear output voltage in the range of 0 to 100 kPa, but can be pushed further up to 105 kPa with linear results. The characteristics of this sensor are described in greater detail in Table 2. A 5-volt supply was used throughout the circuit to power the components. Since the MPXM2102A is ratio metric, meaning the output voltage changes linearly with the supply voltage, the sensor will have a full scale span of 20 mV instead of the specified 40 mV at a 10 V supply. The calculation of the full scale span is shown below: (VS actual/VS spec) x VOUT full-scale spec = VOUT full-scale (5.0 V/ 10 V) x 40 mV = 20 mV One of the most important decisions for a pressure application is the packaging. Freescale has a large offering of pressure packaging options. To minimize the space of a final application, the MPAK package was selected. A non-ported MPAK is the ideal pressure sensor package for hand held GPS units or altimeter watches due to its small size. However, a ported MPAK package can also be selected, allowing a tube to be attached to the port for testing and demonstration purposes. Figure 1. Pressure Sensor There are three types of pressure measurements: gauge, absolute, and differential. Since this reference design © Freescale Semiconductor, Inc., 2006. All rights reserved. Figure 2. MPXM2102A Case 1320A-02 Table 1. MPXM2102A Operating Characteristics Characteristic Symbol Min Typ Max Unit Pressure Range POP 0 — 100 kPa Supply Voltage VS — 10 15 Vdc Supply Current IO — 6.0 — mAdc Full Scale Span VFSS 38.5 40 41.5 mV Voff -1.0 -2.0 — — 1.0 2.0 mV — 0.4 — MV/kPa -0.6 -1.0 — — 0.4 1.0 %VFSS Offset Sensitivity Linearity MPX2102D Series MPX2102A Series ∆V/∆P MPX2102D Series MPX2102A Series — — Amplifier Selection and Amplifier Induced Errors The main goal of the signal conditioning circuit is to convert the MPX2102A differential output to a single-ended, groundreferenced output. The differential output is extremely small for the MCU to process so a conditioning circuit also needs to provide amplification. This reference design has a barometric pressure range of 64 kPa to 105 kPa. The output of the sensor is ratiometric to the supply voltage and the supply voltage is 5.0 V, the FSS, Sensitivity, and Offset are 5.0 V/10 V, or half, of the specified values at a 10 V supply. Using these calculated sensitivity and offset ranges, the lowest and highest possible values were calculated. VOUT = (Applied Pressure * Sensitivity) ± Offset VOUT at 64 kPa = 64 kPa * 0.2 mV/kPa — 1 mV = 11.32 mV VOUT at 105 kPa = 105 kPa * 0.2 mV/kPa + 1 mV = 21.0 mV each of the sensor outputs, then uses a differential amplification as shown in Figure 2. After the first stage of amplification, the output of op-amp A is: VA = (1+R8/R6) x V4 – (R8/R6) x VS(1) = (1+10/4.42k) x V4 – (10/4.42k) x 5.0 V = (1+10/4.42k) x V4 – 11.3 mV and the output of op-amp B is: VB = (1+R7 / R5) x V2 – (R7 / R5) x VS(2) = (1+10/4.42 k) x V2 – (10/4.42 k) x 0 V = (1+10/4.42 k) x V2 – 0 The second stage of amplification connects these two outputs to a common differential amplifier (op-amp C) also shown in Figure 3. With some algebraic manipulation, the output voltage (VOUT) of the entire amplification circuit is These values were found to be 11.32 mV to 22.79 mV differential output from the sensor. VC = (R12/R11) x [(1+R8/R6) x (V2 - V4) – (R8/R6) x VS](3) Two-Stage Design = (412) x [(1.002) x (V2 - V4) – 11.3 mV] This two-stage design level shifts the differential output voltage of the sensor by subtracting an offset voltage from = 412 x (V2 - V4) –11.3 mV = (412K/1 k) x [(1+10/4.42 K) x (V2 - V4) – (10/4.42 K) * 5 V] AN1979 Sensors Freescale Semiconductor 2 R8 10 Ω R6 4.42 K V4 sensor 3 1 6 5 R12 412 K – 7 VA VCC + 4 R11 1K 2 MPXM2102A R5 4.42 K V2 sensor 2 3 – 13 12 R7 10 Ω VCC C5 0.1 µf R9 1K 9 – – + 4 14 VC 10 8 + 11 R10 412 K 1 VB + Figure 3. Amplification Scheme The range of the A/D converter is 0 to 255 counts. However, the A/D values that the system can achieve are dependent on the maximum and minimum system output values: Count = (VOUT – VRL) / (VRH – VRL) x 255(4) where VXdcr = Transducer Output Voltage VRH = Maximum A/D voltage VLH = Minimum A/D voltage Count (64 kPa) = (0.03 – 0.0) / (5.0 – 0.0) x 255 = 2 Count (105 kPa) = (4.85 – 0.0) / (5.0 – 0.0) x 255 = 247 Total # counts = 247 – 2 = 245 counts. The resolution of the system is determined by the barometric pressure represented by each A/D count. As calculated above, the system has a span of 247 counts to represent a pressure from 64 kPa to 105 kPa. Therefore, the resolution is: Resolution = (System Pressure Range) / Total # counts (5) = (105 kPa — 64 kPa)/245 counts = 0.17 kPa per A/D count Microprocessor To provide the signal processing for pressure values, a microprocessor is needed. The MCU chosen for this application is the MC68HC908QT4. This MCU is perfect for appliance applications due to its low cost, small eight-pin package, and other on-chip resources. The MC68HC908QT4 provide: a four-channel, eight-bit A/D, a 16-bit timer, a trimmable internal timer, and in-system FLASH programming. The central processing unit is based on the high performance M68HC08 CPU core and it can address 64 Kbytes of memory space. The MC68HC908QT4 provides 4096 bytes of user FLASH and 128 bytes of random access memory (RAM) for ease of software development and maintenance. There are five bi-directional input/output lines and one input line that are shared with other pin features. The MCU is available in eight-pin as well as 16-pin packages in both PDIP and SOIC. For this application, the eight-pin PDIP was selected. The eight-pin PDIP was chosen for a small package, eventually to be designed into applications as the eight-pin SOIC. If added circuitry for programming the microcontroller is added, a cyclone could be used to program an SOIC on the PCB. If your design requires software updates, consult the MC68HC908QT4 handbook for adding this option. IMPROVEMENTS The resolution of this design is limited by the eight-bit A/D converter on the microcontroller. Theoretically, the accuracy achieved by this device should produce an output when altitude change differs by about 41.54 feet (∆Z). This occurs at approximately 1000 feet below sea level. Due to the logarithmic relationship between pressure and elevation, the accuracy of the results decreases as the device is elevated. At 12,000 feet above sea level, the device should recognize a change of about 65.53 feet (∆Z) as shown in Table 3. A 10-bit, 12-bit or even a 16-bit A/D converter could be implemented in order to increase the resolution of this reference design. AN1979 3 Sensors Freescale Semiconductor Table 2. Microcontroller Accuracy Comparisons Z (ft) P (kPa) V (mV) Amp scheme Vamp (mV) Vamp – 1 bit P0 Px ∆Z (m) ∆Z (ft) Micro (Vx–12.8)*650 4852.3 4832.6 20.265 20.235 12.66 41.54 8 bits 33.8 14.2 12.852 12.822 19.97 65.53 8 bits 4852.3 4847.4 20.265 20.257 3.15 10.35 10 bits 33.8 28.9 12.852 12.844 4.97 16.32 10 bits 4852.3 4851 20.265 20.263 0.79 2.59 12 bits 33.8 32.6 12.852 12.85 1.24 4.08 12 bits 4852.3 4852.2 20.265 20.265 0.05 0.16 16 bits 33.8 33.7 12.852 12.852 0.08 0.25 16 bits -1000 105 20.265 12000 64.259 12.852 -1000 105 20.265 12000 64.259 12.852 -1000 105 20.265 12000 64.259 12.852 -1000 105 20.265 12000 64.259 12.852 (Vx–12.8)*650 (Vx–12.8)*650 (Vx–12.8)*650 Table 2 shows the theoretical maximum resolution that this reference design can achieve. However, factors such as noise within the circuit, sensitivity of the sensor, and voltage offsets in the amplification scheme should be taken into consideration. Accommodating for these factors in the software can filter out some of these factors. Further testing is required to determine the accuracy of the reference design without the limiting A/D converter. DISPLAY The display of the barometric pressure, barometric pressure history, current calculated altitude, and a simple weather prediction is displayed on a 16x2 LCD. Barometric Pressure History Barometric Pressure 101.3kPam -----_----- -----_ _------steady +1170 ft Simple Weather Prediction Altitude (must calibrate) FREESCALE SEL Select Button ENT Enter Button Figure 4. Barometric Display Due to the limited number of bi-directional data pins on the microcontroller, a system was designed to serially buffer the display data. Using a shift register to hold display data, the LCD is driven with only three lines of output from the microcontroller: an enable line, a data line, and a clock signal while the two LEDs are multiplexed with the data line and clock signal. PTA3 PTA4 EN RS HC908QT4 PTA5 R2 1K R3 1K A B RW CLK D80 D81 D82 D83 D84 D85 D86 D87 LCD HC164 VEE Figure 5. Multiplexed LCD Circuit AN1979 Sensors Freescale Semiconductor 4 Multiplexing of the microcontroller output pins allows communication of the LCD to be accomplished with three pins instead of eight or 11 I/O pins usually required. With an eightbit shift register, we are able to manually clock in eight bits of data. The enable line, EN, is manually enabled when eight bytes have been shifted in, telling the LCD the data on the data bus is available to execute. The LCD will only be written to and the contrast can be held at a constant brightness, allowing the read/write and the VEE bits to be held low, also minimizing additional I/O lines. Table 3. Parts List Ref Qty. Description Value Vendor Part No. U3 1 Pressure Sensor 1.0 Freescale MPXM2102A C1 1 VCC Cap 0.1 µF Generic C2 1 Op-Amp Cap 0.1 µF Generic C3 1 Shift Register Cap 0.1 µF Generic D1 1 Red LED — Generic D2 1 Green LED — Generic S2, S3 1 Push buttons — Generic U1 1 Microcontroller 8-Pin Freescale MC68HC908QT4 U2 1 16x2 B&W LCD 16x2 Seiko L168200J000 U4 1 Shift Register — Texas 74HC164 U5 1 Voltage Regulator 5.0 V Fairchild LM78L05ACH AD8544 U6 1 Quad Op-Amp — ADI R1, R4 1 1/4 W Resistor 10 K Generic R2, R3 2 1/4 W Resistor 1.0 K Generic R5, R6 2 1/4 W Resistor 3.65 K Generic R7, R8 2 1/4 W Resistor 10 K Generic R9, R11 2 1/4 W Resistor 1.0 K Generic R10, R12 2 1/4 W Resistor 200 K Generic OTHER This system is designed to run on a 9.0 V battery. It contains a 5.0 V Regulator to provide a 5.0 V supply to the pressure sensor, microcontroller, and LCD. The battery is mounted on the back of the board using a space saving spring battery clip. ALTIMETER/BAROMETER SOFTWARE This application note describes the software version that was available during publication. However updated software versions may be available with further functionality and menu selections. Check our website update for updates to Sensor Products Reference designs. Software User Instructions When the system is turned on or reset, the microcontroller will flash the select LED and display the program title on the LCD for five seconds or until the select (SEL) button is pushed. Then the menu screen is displayed. Using the select (SEL) push button, the user can scroll through the menu options for a software program. To run the altimeter program, use the (SEL) select button to high-light the “Alti/Barometer” option, then press the enter (ENT) push button. The Altimeter program will display current barometric pressure reading, the calculated altitude in feet, a message displaying a simple weather prediction such as “sunny”, “rainy”, “steady” without a pressure change, and “history” before enough history is collected to make a prediction. In the top right corner of the display, a scrolling graphical history displays data points representing the past forty pressure readings. Calibration and Calibration Software There are two forms of calibration for this system. The first calibration is used for the barometer part of the system. This calibration was already done before you received the reference design and only needs to be done once per system. To calibrate the barometer module, a two-point calibration is performed using a highly accurate pressure generator. The system takes a calibration point at 64 kPa and another at 105 kPa. Holding down both the SEL and ENT buttons on system power-up will put the system into calibration mode. At this point, the calibration menu will be displayed with the previously sampled offset voltage. To recalibrate the system, apply a pressure of 64 kPa and press the SEL button (PB1). This A/D value is then saved to a location in the microcontroller memory. To obtain the second calibration point, using the accurate pressure generator apply a pressure of 105 kPa directly to the sensor. Then press the ENT button (PB2). This signal is similarly sampled, averaged and saved to AN1979 5 Sensors Freescale Semiconductor OUTPUT (mVDC) a location in FLASH. To exit the calibration mode, press the SEL (PB1) button. The second calibration is done for the altimeter. The Altimeter requires a one-point calibration where a known altitude is entered with a known pressure. This ensures that changes in atmospheric pressure are due to increases or decreases in altitude and not changes in barometric pressure. By returning to the main menu, and selecting the “Set Elevation”, the user can select an elevation by pressing the SEL button to cycle through the Elevation options from 0 to 12000 feet in 100-foot increments. Once the selection has been made the elevation is flashed into the microcontroller and the user is brought to the Altimeter/Barometer function. Calibration is required for each use of the altimeter module. kPa PSI 40 35 30 25 20 15 10 5 0 –5 VS = 10 VDC TA = 25°C P1 > P2 MAX these known pressures are saved in the flash memory of the microcontroller. ATD = (Po – P64kPa)/(P105kPa - P64kPa) x 255 By algebraic manipulation, the following equation is reached to find the barometric pressure: Po = (ATD/255) x (P105kPa - P64kPa) + P64kPa Converting Pressure to Altitude The method of determining altitude for this reference design is measuring the changes in barometric pressure. The relationship of pressure vs. altitude is not linear. As pressure decreases, altitude increases, but the higher the altitude gets the less pressure changes. The equation that was used for this reference design is: P = (P0) e^[-(g/(RT)) x (Z — Z0), TYP where P = pressure at an unknown altitude, SPAN RANGE (TYP) P0 = pressure at a known altitude, e = a constant, MIN g = gravitational constant 9.8 (m/s^2), 0 25 3.62 50 7.25 75 10.87 100 14.5 OFFSET (TYP) Figure 6. Analog Output to Pressure CONVERTING ANALOG OUTPUT TO PRESSURE Freescale pressure sensors have an extremely linear analog voltage output that is proportional to the pressure input. Since the sensor output is linear, the pressure can be calculated by using the equation of a line, y = mx + b, where y is the output voltage, the slope, m, is the Sensitivity, and the y intercept, b, is the Offset: VOUT = Sensitivity x Pressure + Offset With algebraic manipulation, pressure can be determined by: Pressure = (VOUT – Offset)/Sensitivity Below is an example of determining the pressure from the analog output of 9.5 mV using the Sensitivity and Offset of the MPX2102a sensor specified in the datasheet: Pressure = (VOUT – Offset)/Sensitivity = (9.5 mV – 0.5 mV) / 0.1 mV/kPa = (9.0)/0.1 mV/kPa = 90 kPa where 0.5 mV is the typical offset for the MPX2102 and 0.1 mV/kPa is the sensitivity with a 5.0 V supply This system uses additional amplifiers and an A/D converter that all add additional offset and gain errors; however, the translation function was corrected with the twopoint calibration. The known pressure values that are used for calibration are the maximum and minimum pressures for the system, 105 kPa and 64 kPa respectively. The A/D values for R = dry air constant 287 J/(kg x K), T = temperature at unknown elevation in Kelvin, Z = unknown altitude in meters, and Z0 = known altitude also in meters. This equation originates from the hydrostatic equation: dP = -ρgdZ in conjunction with the ideal gas law: P = ρRT After some algebraic manipulation, plugging in constant values and converting meters to feet, the following equation was generated: Z = Z0 — 27,887 in (P/P0), where Z = unknown altitude in feet, Z0 = known altitude also in feet, P = known pressure at unknown altitude, and P0 = known pressure at known altitude. For this system to calculate an altitude, Z, at a known pressure P, the user must enter a known pressure, P0, and its corresponding altitude, Z0. To accommodate for changes in barometric conditions, the known pressure and altitude data must be re-entered during each use to ensure accuracy. Simple Weather Prediction Atmospheric pressure at the Earth’s surface is one of the measurements used to make weather predictions. Air in a high-pressure area compresses and warms as it descends. The warming air inhibits the formation of clouds. Therefore, the sky is normally sunny in high-pressure areas with a small chance of haze or fog. However, in an area of low atmospheric pressure, the air rises and cools. With enough humidity in the AN1979 Sensors Freescale Semiconductor 6 CONCLUSION air, the rising air will cool, the air will condense forming clouds and precipitation in the form of rain or snow. This reference design saves the current pressure reading and compares it to past pressure measurements. It determines if there was a pressure drop or a pressure increase. Using this information, it makes a simple weather prediction by sending a message of ‘sunny’ for a pressure increase, ‘rainy for a pressure drop, and ‘steady’ for no significant change in pressure.1 . The Altimeter is one of many applications for the MPXM2102AS pressure sensor. This reference design can be used as a reference for developing more integrated barometer applications such as hand-held weather stations, altimeter features for camera or GPS systems, as well as barometric pressure monitoring systems for industrial systems. The MPXM2102AS is an excellent pressure sensor for this application since it is calibrated and temperature compensated. By having these features available on-chip, there is a large savings in PCB real estate in addition to savings in cost for external components Table 4. Elevation Pressure and Temperature Changes Altitude Above Sea Level Temperature Barometer Atmospheric Pressure Feet Meters F C mm * Hg psi kPa -1000 -305 63 17 787.9 15.23 105.0 -500 -153 61 16 773.9 14.96 103.1 0 0 59 15 760.0 14.69 101.33 500 153 57 14 746.3 14.43 99.49 1000 305 55 13 733.0 14.16 97.63 1500 458 54 12 719.6 13.91 95.91 2000 610 52 11 706.6 13.66 94.19 2500 763 50 10 693.9 13.41 92.46 3000 915 48 9 681.2 13.17 90.81 3500 1068 47 8 668.8 12.93 89.15 4000 1220 45 7 656.3 12.69 87.49 4500 1373 43 6 644.4 12.46 85.91 5000 1526 41 5 632.5 12.23 84.33 6000 1831 38 3 609.3 11.78 81.22 7000 2136 34 1 586.7 11.34 78.19 9000 2441 31 -1 564.6 10.91 75.22 9000 2746 27 -3 543.3 10.5 72.40 10,000 3050 23 -5 522.7 10.1 69.64 15,000 4577 6 -14 429.0 8.29 57.16 1. This information was found from the USA Today Weather Book from USAToday.com. AN1979 7 Sensors Freescale Semiconductor Start A/D converter is set up and enabled and variables initialized PB1 and PB2 pressed Start in Calibration Mode? PB1 and PB2 not pressed Display Calibration Message Display Welcome Message Apply 64 kPa Pressure Average 256 Readings PB1 pressed Display Altitude or Set Elevation? Apply 105 kPa Pressure Average 256 Readings “Select Elevation” Menu Displayed Cycle through 0 to 12000ft selections PB2 pressed Read 256 A/D values Average 256 Convert digital reading to history graph Convert A/D Values to Pressure (kPa) Calculate Altitude in Feet Display Barometric Pressure, Altitude and History Figure 7. Altimeter/Barometer Software Flow Diagram REFERENCES Williams, Jack. (2001). Understanding Air Pressure. The Weather Book, 5, 117–123. Retrieved April 4, 2003, from http://www.usatoday.com/weather/wfront.htm AN1979 Sensors Freescale Semiconductor 8 NOTES AN1979 Sensors Freescale Semiconductor 9 How to Reach Us: Home Page: www.freescale.com Web Support: http://www.freescale.com/support USA/Europe or Locations Not Listed: Freescale Semiconductor, Inc. Technical Information Center, EL516 2100 East Elliot Road Tempe, Arizona 85284 +1-800-521-6274 or +1-480-768-2130 www.freescale.com/support Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) www.freescale.com/support Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 [email protected] Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 [email protected] For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 [email protected] AN1979 Rev. 3 11/2006 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2006. All rights reserved.