where H1 and H2 are the maximum and minimum water levels
respectively and D is the possible datapoints available per
character.
Resolution = (160mm– 0mm) / 8.0 = 20 mm / data point.
The graphical history is displayed using the eight special
characters. To update the graphics, all the characters have to
be updated. The characters are updated by first positioning a
pixel for the most recent water level reading in the first column
of the first character. Then the four right columns of the first
character are shifted to the right. The pixel in the last column
of that character is carried to the first column of the next
character. This column shifting is continued until all 40 data
points have been updated in the eight special characters.
LfNx Function
The LfNx function calculates the water level from the
current A/D pressure reading. The A/D Pressure value is
stored in Register A before this function is called. Using the
A/D value and the calibration values stored in the flash, the
water level is calculated from the following function:
RBRA: = (NX –N1) * 160 / (N2 – N1),
where NX is the current A/D Value
N1 is the A/D Value at 0 mm H20
N2 is the A/D Value at 160 mm H20
To simplify the calculation, the multiplication is done first.
Then the function NdivD is called to divide the values.
NdivD Function
The NdivD function performs a division by counting
successive subtractions of the denominator from the
numerator to determine the quotient. The denominator is
subtracted from the numerator until the result is zero. If there
is an overflow, the remainder from the last subtraction is the
remainder of the division.
wrflash and ersflsh Functions
The wrflash and ersflsh functions are used to write to and
erase values from the flash. For more information regarding
flash functionality, refer to Section Four, Flash Memory from
the MC68HC908QY4/D Databook.
ALLINIT Function
The Allinit function disables the COP for this version of
software, sets the data direction bits, and disables the data to
the LCD and turns off the LCD enable line. It also sets up the
microcontroller's internal clock to half the speed of the bus
clock. See Section 15, Computer Operating Properly, of the
MC68908QT4 datasheet for information on utilizing the COP
bintasc Function
The binasc function converts a binary value to its ascii
representation.
A/D Functions
The A/D functions are used to input the amplified voltage
from the pressure sensor from channel 0 of the A/D converter.
The function adcbyti will set the A/D control register, wait for
the A/D reading and load the data from the A/D data register
into the accumulator. The function adcbyta is used to obtain an
averaged A/D reading by calling adcbyti 256 times and
returning the resulting average in the accumulator.
LCD Functions
The LCD hardware is set up for multiplexing three pins from
the microcontroller using an eight-bit shift register. Channels
three, four, and five are used on port A for the LCD enable (E),
the LCD reset (RS), and the shift register clock bit,
respectively. The clock bit is used to manually clock data from
channel four into the eight-bit shift register. This is the same
line as the LCD RS bit because the MSB of the data is low for
a command and high for data. The RS bit prepares the LCD
for instructions or data with the same bit convention. When the
eight bits of data are available on the output pins of the shift
register, the LCD enable (E) is toggled to receive the data.
The LCD functions consist of an initialization function lcdinit
which is used once when the system is started and five output
functions. The functions lcdcmdo and lcdchro both send a
byte of data. The function shiftA is called by both lcdcmdo and
lcdchro to manually shift eight bits of data into the shift register.
The function lcdnibo converts the data to binary before
displaying. The lcdnibo displays a byte of data by calling
lcdnibo for each nibble of data. The function lcdnibo enables
strings to be easily added to the software for display. The
function accepts a comma- delimited string of data consisting
of 1–2 commands for clearing the screen and positioning the
cursor. It then continues to output characters from the string
until the @ symbol is found, signally the end of the string.
CONCLUSION
The water level reference design uses a MPXM2010GS
pressure sensor in the low cost MPAK package, the low cost,
eight-pin microcontroller, and a quad op-amp to amplify the
sensor output voltage. This system uses very few
components, reducing the overall system cost. This allows for
a solution to compete with a mechanical switch for water level
detection but also offer additional applications such as
monitoring water flow for leak detection, and the other
applications for smart washing machines.
module to help software recover from runaway code.
WARMUP Function
The Warmup function alternates the blinking of the two
LEDs ten times. This gives the LCD some time to warm up.
Then the function warmup calls the LCD initialization function,
lcdinit .
AN1950
Sensors
6
Freescale Semiconductor
相关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