Microchip Technology MA160014 Hoja De Datos

Descargar
Página de 560
PIC18(L)F2X/4XK22
DS41412F-page 324
 2010-2012 Microchip Technology Inc.
19.3
Calibrating the CTMU Module
The CTMU requires calibration for precise
measurements of capacitance and time, as well as for
accurate time delay. If the application only requires
measurement of a relative change in capacitance or
time, calibration is usually not necessary. An example of
this type of application would include a capacitive touch
switch, in which the touch circuit has a baseline
capacitance, and the added capacitance of the human
body changes the overall capacitance of a circuit. 
If actual capacitance or time measurement is required,
two hardware calibrations must take place: the current
source needs calibration to set it to a precise current,
and the circuit being measured needs calibration to
measure and/or nullify all other capacitance other than
that to be measured.
19.3.1
CURRENT SOURCE CALIBRATION
The current source on the CTMU module is trimable.
Therefore, for precise measurements, it is possible to
measure and adjust this current source by placing a
high precision resistor, R
CAL
, onto an unused analog
channel. An example circuit is shown in 
The current source measurement is performed using
the following steps:
1.
Initialize the A/D Converter.
2.
Initialize the CTMU.
3.
Enable the current source by setting EDG1STAT
(CTMUCONL<0>).
4.
Issue settling time delay.
5.
Perform A/D conversion.
6.
Calculate the current source current using
I = V / R
CAL
, where R
CAL
 is a high precision
resistance and V is measured by performing an
A/D conversion.
The CTMU current source may be trimmed with the
trim bits in CTMUICON using an iterative process to get
an exact desired current. Alternatively, the nominal
value without adjustment may be used; it may be
stored by the software for use in all subsequent
capacitive or time measurements.
To calculate the value for R
CAL
, the nominal current
must be chosen, and then the resistance can be
calculated. For example, if the A/D Converter reference
voltage is 3.3V, use 70% of full scale, or 2.31V as the
desired approximate voltage to be read by the A/D
Converter. If the range of the CTMU current source is
selected to be 0.55 
A, the resistor value needed is cal-
culated as R
CAL
= 2.31V/0.55
A, for a value of 4.2 MΩ.
Similarly, if the current source is chosen to be 5.5
A,
R
CAL
  would be 420,000Ω,  and 42,000Ω if the current
source is set to 55
A.
FIGURE 19-2:
CTMU CURRENT SOURCE 
CALIBRATION CIRCUIT
A value of 70% of full-scale voltage is chosen to make
sure that the A/D Converter was in a range that is well
above the noise floor. Keep in mind that if an exact cur-
rent is chosen, that is to incorporate the trimming bits
from CTMUICON, the resistor value of R
CAL
 may need
to be adjusted accordingly. R
CAL
 may also be adjusted
to allow for available resistor values. R
CAL
 should be of
the highest precision available, keeping in mind the
amount of precision needed for the circuit that the
CTMU will be used to measure. A recommended
minimum would be 0.1% tolerance.
The following examples show one typical method for
performing a CTMU current calibration. 
demonstrates how to initialize the A/D Converter and
the CTMU; this routine is typical for applications using
both modules. 
 demonstrates one
method for the actual calibration routine.
PIC18(L)FXXK22 Device
A/D Converter
CTMU
ANx
R
CAL
Current Source
MUX
A/D