Hardware Reference
In-Depth Information
Example 12.10
▼
Construct a humidity measurement system that consists of an HCS12, an IH-3605 humid-
ity sensor, and an LCD. The E-clock frequency of the HCS12 is 24 MHz.
Solution:
Since the output of the IH-3605 is between 0.8 and 3.9 V with a 5-V power supply, it
would be beneficial to use a circuit to translate and then scale it to between 0 and 5 V so that
the best accuracy can be achieved. The circuit connection is shown in Figure 12.20. A set of
resistor values and V
1
voltage are given in Figure 12.20. A low-pass filter that consists of a 1-k
Ω
resistor and a 0.16-
F capacitor is added to meet the requirement.
To translate from the conversion result to the relative humidity, divide the conversion re-
sult by 10.23. Since the HCS12 MCU does not support floating-point operation directly, we can
multiply the conversion result by 100 (or 10) and then divide the product by 1023 (or 102). The
C program that configures the A/D module, starts the A/D conversion, translates the conver-
sion result to the relative humidity, converts the humidity into an ASCII string, and displays
the string on the LCD is as follows:
μ
V
S
(= 5 V)
R
0
R
f
R
0
+12 V
1 k
Ω
V
OUT
+12 V
-
R
1
-
0.16
μ
F
74 1
IH-3605
74 1
+
V
OUT
+
GND
R
2
- 12 V
- 12 V
V
1
R
0
=
R
1
= 10 k
Ω
HCS12
R
2
= 62 k
Ω
R
f
= 16 k
Ω
V
1
= 5 V
AN7
Figure 12.20
■
Relative humidity measurement circuit
#include “c:\cwHCS12\include\hcs12.h”
#include “c:\cwHCS12\include\delay.c”
#include “c:\cwHCS12\include\convert.c”
#include “c:\cwHCS12\include\lcd_util_dragon12.c”
void openAD0(void);
char buf[10];
char *msg1
5
“humidity
5
”;
char *blanks
5
“ ”;
void main (void)
{
Search WWH ::
Custom Search