Analog To Digital Conversion Using A Pic16c54

Microchip Technology Inc.

view the full application circuits
appnote circuit ,Schematic
AN513
Analog to Digital Conversion Using a PIC16C54
Author:
Doug Cox
Microchip Technology Inc.
FIGURE 1:
1
4
S1
13
5
S2
2
3
VOLTMETER A/D CONVERTER
5
6
8
4066
U1
INTRODUCTION
This application note describes a method for
implementing analog to digital (A/D) conversion on the
PIC16C5X series of Microcontrollers The converter
requires only five external components and is software
and hardware configurable for conversion resolutions
from 6-bits up to 10-bits and conversion times of 250
µ
s
or longer. The method is usable for both voltage and
current conversion and uses a software calibration
technique that compensates for time and temperature
drift as well as component errors. PIC16C5X microcon-
trollers are ideal for simple analog applications
because:
• Very low cost
• Few external components required
• Fully programmable. PIC16C5X Microcontrollers
are offered as One-Time-Programmable (OTP)
EPROM devices.
• Available off the shelf from distributors
• Calibration in software for improved measurement
accuracy
• Power savings using Sleep mode
• Output pins have large, current source/sink capa-
bility to drive LED’s directly
6
S3
9
3
10
12 S4
17
11
T0CKI
R
C
R
100Ω
RA0
FIGURE 2:
VOLTMETER MEASUREMENT
CYCLE
V
V
O
V
I
C
R
I
THEORY OF OPERATION
The application uses a capacitive charging circuit
(Figure 1) to convert the input voltage to time, which
can be easily measured using a Microcontroller First,
the reference voltage is applied to the input voltage to
the current converter (U1). The equivalent circuit is
shown in Figure 2. This circuit provides a linearly vari-
able current as a function of input voltage. The logarith-
mic characteristic that would occur if the input voltage
was applied directly to an RC is not present. The capac-
itor C is charged up until the threshold on the chip input
trips. This generates a software calibration value that is
used to calibrate out most circuit errors, including;
inaccuracies in the Resistor and Capacitor changes in
the input threshold voltage, and temperature variations.
After the software calibration value is measured, the
Capacitor is discharged (Figure 3), and the input volt-
age is connected to V
IN
. The time to the trip threshold
is measured for the input voltage and compared to the
calibration value to determine the actual input voltage.
FIGURE 3:
VOLTMETER DISCHARGE
CYCLE
V
V
O
V
C
R
I
©
1997 Microchip Technology Inc.
DS00513D-page 1