Difference between revisions of "High resolution barometric pressure sensor"

From ScienceZero
Jump to: navigation, search
(Source code)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
[[image:pressure.jpg|thumb|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.
 +
 +
 
== Development software used ==
 
== Development software used ==
 
* IDE: µVision3 V3.72
 
* IDE: µVision3 V3.72
 
* Compiler: RealView MDK-ARM, version: 3.40
 
* Compiler: RealView MDK-ARM, version: 3.40
  
== Calibration of th esensor values ==
+
 
The HP03D datasheet is not clear and the formulaes are missing important parantheses. The application note with the sample code is not really correct either. This code will work correctly using 32 bit signed integers. The result is multiplied by 10 to get one digit of fractional resolution.
+
== 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 [[integer|integers]]. The result is multiplied by 10 to get one digit of fractional resolution.
  
 
  if (D2 >= C5) {
 
  if (D2 >= C5) {
Line 22: Line 28:
 
== LCD interface ==
 
== 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.
 
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.
 +
  
 
== I<sup>2</sup>C bus ==
 
== I<sup>2</sup>C 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.
+
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 ==
 
== Parts used ==
 
Suitable parts can be found at Futurlec
 
Suitable parts can be found at Futurlec
 +
  
 
=== ET-BASE ARM2103 controller ===
 
=== ET-BASE ARM2103 controller ===
Line 36: Line 63:
 
* Supply voltage 5 V
 
* Supply voltage 5 V
 
* Supply current 45 mA
 
* Supply current 45 mA
 +
  
 
=== LCD display Optrex 20434 ===
 
=== LCD display Optrex 20434 ===
Line 42: Line 70:
 
* Supply voltage 5 V
 
* Supply voltage 5 V
 
* Supply current 3 mA
 
* Supply current 3 mA
 +
  
 
=== Pressure sensor HP03D ===
 
=== Pressure sensor HP03D ===
Line 49: Line 78:
 
* Accurate to 0.5 hPa
 
* Accurate to 0.5 hPa
 
* Supply voltage: 2.2 - 3.6 V (provided by controller)
 
* Supply voltage: 2.2 - 3.6 V (provided by controller)
* Supply current 500 uA during A/D conversion
+
* Supply current 500 µA during A/D conversion
 +
 
 
   
 
   
 
== Controller connections ==
 
== Controller connections ==
Line 57: Line 87:
 
  RS    <---    P0.19    Data/instruction select
 
  RS    <---    P0.19    Data/instruction select
 
  D4    <-->    P0.20    Data 0
 
  D4    <-->    P0.20    Data 0
  D5    <-->    P0.21   Data 1
+
  D5    <-->    P0.21   Data 1
  D6    <-->    P0.22   Data 2
+
  D6    <-->    P0.22   Data 2
  D7    <-->    P0.23   Data 3
+
  D7    <-->    P0.23   Data 3
  
 
  HP03D      Direction  LPC2103        Signal
 
  HP03D      Direction  LPC2103        Signal
Line 70: Line 100:
  
  
 +
== Source code ==
 +
*http://www.sciencezero.4hv.org/electronics/download/pressuresensor.c
  
 
[[Category:Electronics]]
 
[[Category:Electronics]]

Latest revision as of 23:16, 5 April 2022

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.


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