Converting Pressure to Water Level
Hydrostatic pressure being measured is the pressure at the
bottom of a column of fluid caused by the weight of the fluid
and the pressure of the air above the fluid. Therefore, the
hydrostatic pressure depends on the air pressure, the fluid
density and the height of the column of fluid.
P= Pa + ρ g ? h
where P = pressure
Pa = pressure
ρ = mass density of fluid
g = 9.8066 m/s^2
h = height of fluid column
To calculate the water height, we can use the measured
pressure with the following equation, assuming the
atmospheric pressure is already compensated for by the
selection of the pressure sensor being gauge:
? h = P ρ g
Software Function Descriptions
Main Function
The main function calls an initialization function Allinit calls
a warm-up function, Warmup, to allow extra time for the LCD
to initialize, then checks if buttons PB1 and PB2 are
depressed. If they are depressed concurrently, it calls a
calibration function Calib . If they are not both pressed, it
enters the main function loop. The main loop displays the
menu, moves the cursor when the PB1 is pressed and
enters the function corresponding to the highlighted menu
option when PB2 is depressed.
Calibration Function
The calibration function is used to obtain two calibration
points. The first calibration point is taken when the head tube
is not placed in water to obtain the pressure for 0 mm of water.
The second calibration point is obtained when the head tube
is placed at the bottom of a container with a height of 160 mm.
When the calibration function starts, a message appears
displaying the A/D values for the corresponding calibration
points currently stored in the flash. To program new calibration
points, press PB1 to take 256 A/D readings at 0 mm of water.
The average is calculated and stored in a page of flash. Then
the user has the option to press PB1 to exit the calibration
function or obtain the second calibration point. To obtain the
second calibration point, the head tube should be placed in
160 mm of water, before depressing PB2 to take 256 A/D
readings. The average is taken and stored in a page of flash.
Once the two readings are taken, averaged, and stored in the
flash, a message displays the two A/D values stored.
Level Function
The Level function initializes the graphics characters. Once
this is complete, it continues looping to obtain an average A/D
reading, displaying the Water Level, the Water Flow, and a
Graphical History until simultaneously depressing both PB1
and PB2 to return to the main function.
The function first clears the 40 pressure readings it updates
for the Graphical History. The history then enters the loop first
displaying eight special characters, each containing five data
points of water level history. The function adcbyta is called to
obtain the current averaged A/D value. The function LfNx is
called to convert the A/D value to a water level. It is then
compared to the calibration points, the maximum and
minimum points, to determine if the container is full or empty.
If true, then it displays the corresponding message. The
current water level is compared to the previous read and
displays the message filling if it has increased, emptying if it
has decreased, and steady if it has not changed.
The water level calculation has to be converted to decimal
in order to display it in the LCD. To convert the water level
calculation to decimal, the value is continually divided with the
remainder displayed to the screen for each decimal place. To
display the Rate of Water Flow, the sign of the value is first
determined. If the value is negative, the one's complement is
taken, a negative sign is displayed, and then the value is
continually divided to display each decimal place. If the
number is positive, a plus sign.
Level Function
The Level function initializes the graphics characters. Once
this is complete, it continues looping to obtain an
average A/D reading, displaying the Water Level, the Water
Flow, and a Graphical History until simultaneously depressing
both PB1 and PB2 to return to the main function.
The function first clears the 40 pressure readings it updates
for the Graphical History. The history then enters the loop first
displaying eight special characters, each containing five data
points of water level history. The function adcbyta is called to
obtain the current averaged A/D value. The function LfNx is
called to convert the A/D value to a water level. It is then
compared to the calibration points, the maximum and
minimum points, to determine if the container is full or empty.
If true, then it displays the corresponding message. The
current water level is compared to the previous read and
displays the message filling if it has increased, emptying if it
has decreased, and steady if it has not changed.
The water level calculation has to be converted to decimal
in order to display it in the LCD. To convert the water level
calculation to decimal, the value is continually divided with the
remainder displayed to the screen for each decimal place. To
display the Rate of Water Flow, the sign of the value is first
determined. If the value is negative, the one's complement is
taken, a negative sign is displayed, and then the value is
continually divided to display each decimal place. If the
number is positive, a plus sign is displayed to maintain the
display alignment and the value is continually divided to
display each decimal place.
The most complicated part of this function is updating the
graphics history display. The characters for the 16x2 LCD
chosen for this reference design are 8x5 pixels by default.
Therefore, each special character that is created will be able
to display five water level readings. Since the height of the
special character is eight pixels, each vertical pixel position
will represent a water level in increments of 20 mm.
Resolution = (H1 – H0) / D
AN1950
Sensors
Freescale Semiconductor
5
相关PDF资料
KN500B1/4 SWITCH KNOB STRAIGHT .50" BLACK
KN5700B1/4 SWITCH KNOB STRAIGHT .75" BLACK
KN700B1/4 SWITCH KNOB STRAIGHT .75" BLACK
KS-100 PROTECTIVE COVER FOR RELAYS
KTKK-0500 CONN HEAT SHRINK TUBE SZ 8 STR
KTKK-0674 CONN HEAT SHRINK TUBE SZ E STR
KTKK-1123 CONN HEAT SHRINK TUBE SZ D ANG
KTR10EZPJ302 RES 3.0K OHM 1/8W 5% 0805 SMD
相关代理商/技术参数
KITMPXA6115AEVB 功能描述:压力传感器开发工具 Sensor Toolbx Pressu Sensor Developmt brd RoHS:否 制造商:Freescale Semiconductor 工具用于评估:MPL3115A2 接口类型:USB 最大工作温度:
KITMPXSHOWEVK 功能描述:压力传感器开发工具 PRESSURE SHOWBOARD RoHS:否 制造商:Freescale Semiconductor 工具用于评估:MPL3115A2 接口类型:USB 最大工作温度:
KITMPXV5004DPEVB 功能描述:压力传感器开发工具 MPXV5004 Dev Kit RoHS:否 制造商:Freescale Semiconductor 工具用于评估:MPL3115A2 接口类型:USB 最大工作温度:
KITMS05051 功能描述:电容套件 0.2pF-1.0pF 0505 10 EA-8 VALUES RoHS:否 制造商:Nichicon 电容范围:10 uF to 680 uF 公差范围: 电压范围:6.3 V to 25 V 产品:Aluminum Organic Polymer Capacitor Kit
KITMS05052 功能描述:电容套件 1.5pF-22pF 0505 10 EA-8 VALUES RoHS:否 制造商:Nichicon 电容范围:10 uF to 680 uF 公差范围: 电压范围:6.3 V to 25 V 产品:Aluminum Organic Polymer Capacitor Kit
KITMS05053 功能描述:电容套件 27pF-330pF 0505 10 EA-8 VALUES RoHS:否 制造商:Nichicon 电容范围:10 uF to 680 uF 公差范围: 电压范围:6.3 V to 25 V 产品:Aluminum Organic Polymer Capacitor Kit
KITMS06031 功能描述:电容套件 0.1pF-1.0pF 0603 10 EA-8 VALUES RoHS:否 制造商:Nichicon 电容范围:10 uF to 680 uF 公差范围: 电压范围:6.3 V to 25 V 产品:Aluminum Organic Polymer Capacitor Kit
KITMS06032 功能描述:电容套件 1.5pF-22pF 0603 10 EA-8 VALUES RoHS:否 制造商:Nichicon 电容范围:10 uF to 680 uF 公差范围: 电压范围:6.3 V to 25 V 产品:Aluminum Organic Polymer Capacitor Kit