Home

How to interpret the LPS331AP pressure and temperature readings

image

Contents

1. DT0004 ST i Design tip How to interpret the LPS331AP pressure and temperature readings By Tom Bocchino and Boon Nam Poh Main components LPS331AP 260 1260 mbar absolute barometer with digital output Purpose and benefits e Review of two s complement notation for ease of design e How to interpret pressure and temperature values in the LPS331AP Description The LPS331AP is a MEMS sensor which measures absolute pressure 7 and temperature 2 and stores the values in two s complement registers which can be read via the I C or SPI host interface This design tip explains how to interpret the two s complement register values Figure 1 LPS331AP Analog to Digital Data Flow Analog Domain Digital Domain Low Noise Analog to Digital Control Analog Front Digital Signal Processing Conversion DSP Sensors amp and Bias Register Bank TA N Addr h 24 bit Pressure count 28h __ PressureOut_XL LSB Two s complement value 29h _ PressureOut_L__ MIDDLE 2Ah PressureOut_H MSB No 16 bit Temperature count es 2Bh TemperatureOut_L LSB Two s complement value C 2Ch TemperatureOut_H MSB July 2012 DT0004 Rev 1 1 7 ky www st com The LPS331AP stores pressure as a 24 bit word and temperature as a 16 bit word Both values are stored as two s complement integers as illustrated in Figure 1 Why we use two s complement Measuring analog values and storing the
2. Support material Related design support material eMotion Main Board which accepts several MEMS modules including pressure sensor plug in module LPS331 Pressure Module for eMotion Board STEVAL MkKI109V2 STEVAL MKI120V1 Documentation LPS331AP MEMS pressure sensor 260 1260 mbar absolute digital output Datasheet Data brief barometer STEVAL MKI109V2 eMotion ST MEMS adapters motherboard based on the STM32F103RE compatible with all ST MEMS adapters V2 User Manual UM1049 Unico GUI software guide Data brief STEVAL MKI120V1 LPS331AP adapter board for a standard DIL24 socket www st com sensors Revision history Date Version Changes 17 Jul 2012 Initial release July 2012 DT0004 Rev 1 6 7 ky www st com Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at anytime without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express
3. 2 1 0 1 E A 0 J 1110 0000 0111 1100 need to take the 2 s complement 0001 1111 1000 0011 invert 1 add 1 0001 11111000 0100 1F84h 8068 dec counts 8068 counts Temperature in C Offset 42 5 _ 25 7 scale 480 counts C As shown in Temperature example 2 a negative value in the raw count register does not always result in a negative a temperature value in degrees Celsius This is because the offset and scaling factor must be applied to determine the final value in C units When reading the temperature values it is also important to note the byte ordering This is especially true in auto increment mode in which case address 2Bh is read first followed by address 2Ch The designer should assemble the proper 16 bit endian format temperature count 2Ch amp 2Bh The following registers in the device are two s complement All other registers in the device are either unsigned or bitwise representations not negative Table 1 LPS331AP two s complement registers FUNCTION BYTES DESCRIPTION 24 bit absolute pressure data OR this contains PRESS _OUT 2Ah amp 29h amp 28h the difference in pressure between Ref_P and and Press_Out when auto zero mode is used TEMP_OUT 2Bh amp 2Ch_ 16 bit temperature data REF_P OAh amp 09h amp 08h 24 bit absolute pressure in auto zero mode DT0004 Rev 1 5 7 ky www st com
4. a temperature sensor which is used for compensation of the pressure sensor The temperature data is also available for outside applications The temperature raw count is stored in registers Temp_Out_H 2Ch and Temp_Out_L 2Bh The temperature in C can be determined by calculating the two s complement if necessary and perform the scaling An example of a temperature calculation when the sign bit is 0 is shown below Temperature example 1 sign bit is 0 this is a positive value Temp_Out_H 0x2C Temp_Out_L 0x2B Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 2 0 ebekkel elll U 6 A B JL D _A A 0 J Temperature Counts 2Ch amp 2Bh 6BDOh 27600 dec counts 27600 counts Temperature in C Offset 42 5 __ _ 100 scale 480 counts C July 2012 DT0004 Rev 1 4 7 ITA www st com July 2012 Likewise a negative value is indicated when the MSB in the temperature word is equal to 1 To obtain the temperature we first take the two s complement of the complete word and then perform the scaling and offset operation An example of a temperature calculation when the sign bit is 1 is shown below Temperature example 2 sign bit is 1 two s complement Temp_Out_H 0x2C Temp_Out_L 0x2B Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit 15 14 13 12 11 10 9 8 7 6 5 4 3
5. data in a digital domain creates an interesting dilemma How do we represent negative analog values in a digital system How do we handle the number zero A computing system uses two s complement to simplify the processing logic required to handle negative numbers and subtractions A circuit designed for addition can handle negative operands by using two s complement This minimizes the need for additional circuitry capable of subtraction or additional switching circuitry based on the sign Most modern computers MCU s and DSP s use two s complement notation If a register is defined as two s complement typically the most significant bit msb of the most significant byte MSB indicates the sign as shown in Figure 2 If the msb of the register is 1 the number is negative and we use two s complement If the bit is 0 the integer is positive and no translation is necessary Figure 2 Sign bit indicates whether a value is positive or negative PressOut_H 0x2A PressOut_L 0x29 PressOut_XL 0x28 Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit bit bit bit bit 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 41 0 S I G N 0 POS 1 NEG pressure magnitide How to obtain pressure values in mbar The LPS331AP sensor stores the pressure value in raw counts in 3 registers PressOut_H PressOut_L and PressOut_XL The most significant bit of the PressOut_H register indicates th
6. or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVEGRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this do
7. cument shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2012 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com July 2012 DT0004 Rev 1 7 7 ky www st com
8. e PressOut_H 0x2A PressOut_L 0x29 PressOut_XL 0x28 Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit bit bit bit bit 23 22 21 20 19 18 17 16 15 144 13 12 11 10 9 Pressure Counts 2Ah amp 29h amp 28h 3FF58Dh 4191629 dec counts 4191629 counts 1023 3 mbar Scaling factor 4096 counts mbar Pressure millibar In some applications the device may be configured to report a differential pressure value in the PressOut registers by using the auto zero feature In this case the PressOut registers could contain a negative value as illustrated in the second example of a pressure calculation shown below To obtain the pressure in mbar we first take the two s July 2012 DT0004 Rev 1 3 7 ki www st com complement of the complete word and then divide by 4096 Pressure example 2 negative number two s complement PressOut_H 0x2A PressOut_L 0x29 PressOut_XL 0x28 Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit bit bit bit bit 23 22 21 20 19 18 17 16 15 144 13 12 11 10 9 8 7 6 5 4 3 2 1 0 LL re ey a Os Se OE Jo A 4 1111 0010 0001 1110 10100100 need to take the two s complement 0000 1101 1110 0001 0101 1011 invert 1 add1 0000 1101 1110 0001 0101 1100 ODE15Ch 909660 dec ass 909660 counts Pressure in millibar 222 08 mbar 4096 counts mbar How to obtain temperature values in C The LPS331AP also contains
9. e polarity If the sign bit is zero then the value is positive and the pressure in mbar is determined by dividing the decimal value by the scaling factor of 4096 A sign bit of 1 indicates a negative value so we first take the two s complement of the complete word and then divide by 4096 Keep in mind that the sign bit determines whether we should perform the two s complement operation or not The 3 bytes are concatenated to form a 24 bit word and the complete word is represented in two s complement not the single bytes When reading the pressure value it is important to note the byte ordering This is especially important in auto increment mode when the address is incremented automatically The designer should assemble the proper 24 bit endian format pressure count 2Ah amp 29h amp 28h July 2012 DT0004 Rev 1 2 7 ki www st com The device may be configured to report a delta pressure by using the auto zero feature in CTRL_REG2 0x21 When using the auto zero feature the PressOut registers could contain a negative value which is the sum difference between the current pressure and the reference pressure Negative values can also occur when a device is defective Hence it can be used for self test during a boot up operation and when the auto zero feature is not used An example of a pressure calculation when the sign bit is 0 is shown in the following example Pressure example 1 sign bit is 0 this is a positive valu

Download Pdf Manuals

image

Related Search

Related Contents

Engage Agro Corporation 1030 Gordon Street Guelph, Ontario N1G  Manuel - SCS La Boutique  Dados técnicos do InTap4000e/InTap4004e  Mode d'emploi  Manual THERA-Trainer veho  ª - Assembleia da República  Samsung SyncMaster  programme régional d`évaluation spécialisée  Kentron KE5HDMIPLUS  

Copyright © All rights reserved.
Failed to retrieve file