High resolution barometric pressure sensor

From ScienceZero

Revision as of 00:43, 2 April 2009 by Bjoern (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
LPC2103 controller and LCD display

A pressure sensor that uses the HP03D to reach a resolution of 1 Pa and 0.01 °C when averaging 100 readings at a sample rate of 10 Hz.


Contents

Development software used

  • IDE: µVision3 V3.72
  • Compiler: RealView MDK-ARM, version: 3.40


Calibration of the sensor values

The HP03D datasheet is not clear and the formulae are missing important parentheses. The application note with the sample code does not work correctly without floating-point either. This code will work correctly using 32 bit signed integers. The result is multiplied by 10 to get one digit of fractional resolution.

if (D2 >= C5) {
    dUT = (D2 - C5)-(((((D2 - C5) * (D2 - C5)) >> 14) * A) >> C);
} else {
    dUT = (D2 - C5)-(((((D2 - C5) * (D2 - C5)) >> 14) * B) >> C);
}
 
OFF = (C2 << 2 ) + (((C4 - 1024) * dUT) >> 12);
SENS = C1 + ((C3 * dUT) >> 10);
X = ((SENS * (D1 - 7168)) >> 14) - OFF;
 
Pressure = ((X * 10) >> 5) + C7;
Temperature = 250 + (((dUT * C6) >> 16) - (dUT >> D));


LCD interface

The timing is very important, use the hardware timer to make sure the delays are correct. If you use the 4 bit databus you need to read both nibbles, if not you may get the wrong value the next time.


I2C bus

Remember the pull-ups on both the clock and data line. First read the 24C02 EEPROM datasheet and the UM10161 - LPC2101/02/03 User manual carefully. Then read the HP03D datasheet. Clock the bus slowly in the beginning to reduce the chance of any problems. Make sure to differ between a start condition and a repeated start condition.


Reading the EEPROM

This is the bus activity for a random read of the 24C02 EEPROM.

START 0xA0 ACK ADRESS ACK
START 0xA1 ACK DATA NOACK STOP


Reading the A/D

This is the bus activity for reading the A/D. Use 0xF0 for pressure and 0xD0 for temperature.

Set XCLR high
START 0xEE ACK 0xFF ACK (0xF0 | 0xD0) ACK STOP 
Pause 40 ms
START 0xEE ACK 0xFD ACK 
START 0xEF ACK AD-MSB ACK AD-LSB NOACK STOP
Set XCLR low


Parts used

Suitable parts can be found at Futurlec


ET-BASE ARM2103 controller

  • CPU NXP LPC2103
  • RAM 8192 bytes
  • FLASH 32768 bytes
  • Clock rate 59 MHz
  • Supply voltage 5 V
  • Supply current 45 mA


LCD display Optrex 20434

  • 20 x 4 characters
  • 4 bit bus
  • Supply voltage 5 V
  • Supply current 3 mA


Pressure sensor HP03D

  • Pressure range 300-1100 hPa
  • 16 bit A/D
  • I2C Serial interface
  • Accurate to 0.5 hPa
  • Supply voltage: 2.2 - 3.6 V (provided by controller)
  • Supply current 500 µA during A/D conversion


Controller connections

LCD  Direction  LPC2103  Signal
EN     <---     P0.17    Enable (10 kOhm pull-up to 5 V on controller)
RW     <---     P0.18    Direction of data bus						   
RS     <---     P0.19    Data/instruction select
D4     <-->     P0.20    Data 0
D5     <-->     P0.21    Data 1
D6     <-->     P0.22    Data 2
D7     <-->     P0.23    Data 3
HP03D      Direction  LPC2103        Signal
1 - VSS               -              GND
2 - VDD               -              +3.3 V
3 - MCLK     <---     P0.7 - MAT2.0  32768 Hz
4 - XCLR     <---     P0.4 - PIO     Reset (Active low, high during A/D operation)
5 - SDA      <-->     P0.3 - SDA0    I2C data (10 kOhm pull-up to 3.3 V)
6 - SCLK     <---     P0.2 - SCL0    I2C clock (10 kOhm pull-up to 3.3 V)


Source code

Personal tools
Science Zero