Microchip Technology ARD00385 数据表
PIC18F87K90 FAMILY
DS39957D-page 418
2009-2011 Microchip Technology Inc.
27.5
Measuring Capacitance with the
CTMU
CTMU
There are two ways to measure capacitance with the
CTMU. The absolute method measures the actual
capacitance value. The relative method only measures
for any change in the capacitance.
CTMU. The absolute method measures the actual
capacitance value. The relative method only measures
for any change in the capacitance.
27.5.1
ABSOLUTE CAPACITANCE
MEASUREMENT
MEASUREMENT
For absolute capacitance measurements, both the
current and capacitance calibration steps, found in
current and capacitance calibration steps, found in
should be followed.
To perform these measurements:
1.
To perform these measurements:
1.
Initialize the A/D Converter.
2.
Initialize the CTMU.
3.
Set EDG1STAT.
4.
Wait for a fixed delay, T.
5.
Clear EDG1STAT.
6.
Perform an A/D conversion.
7.
Calculate the total capacitance, C
TOTAL
= (I * T)/V,
where:
• I is known from the current source
• I is known from the current source
measurement step (
• T is a fixed delay
• V is measured by performing an A/D
• V is measured by performing an A/D
conversion
8.
Subtract the stray and A/D capacitance
(C
(C
OFFSET
from
) from C
TOTAL
to determine the
measured capacitance.
27.5.2
RELATIVE CHARGE
MEASUREMENT
MEASUREMENT
Not all applications require precise capacitance
measurements. When detecting a valid press of a
capacitance-based switch, only a relative change of
capacitance needs to be detected.
In such an application, when the switch is open (or not
touched), the total capacitance is the capacitance of the
combination of the board traces, the A/D Converter and
other elements. A larger voltage will be measured by the
A/D Converter. When the switch is closed (or touched),
the total capacitance is larger due to the addition of the
capacitance of the human body to the above listed
capacitances and a smaller voltage will be measured by
the A/D Converter.
To detect capacitance changes simply:
1.
measurements. When detecting a valid press of a
capacitance-based switch, only a relative change of
capacitance needs to be detected.
In such an application, when the switch is open (or not
touched), the total capacitance is the capacitance of the
combination of the board traces, the A/D Converter and
other elements. A larger voltage will be measured by the
A/D Converter. When the switch is closed (or touched),
the total capacitance is larger due to the addition of the
capacitance of the human body to the above listed
capacitances and a smaller voltage will be measured by
the A/D Converter.
To detect capacitance changes simply:
1.
Initialize the A/D Converter and the CTMU.
2.
Set EDG1STAT.
3.
Wait for a fixed delay.
4.
Clear EDG1STAT.
5.
Perform an A/D conversion.
The voltage measured by performing the A/D conver-
sion is an indication of the relative capacitance. In this
case, no calibration of the current source or circuit
capacitance measurement is needed. (For a sample
software routine for a capacitive touch switch, see
sion is an indication of the relative capacitance. In this
case, no calibration of the current source or circuit
capacitance measurement is needed. (For a sample
software routine for a capacitive touch switch, see
.)