MICROCHIP TECHNOLOGY’S MICROSOLUTIONS eNEWSLETTER - November 2005
High Resolution A/D Conversion with PIC ? Microcontrollers
the V DD /2 reference voltage, it is possible
to create this reference using the PIC
Introduction
There are several features on newer Flash-based PIC ? microcontrollers that make
the creation of a delta-sigma Analog-to-Digital Converter (ADC) very simple to
implement. These features are: (1) the Timer1 gate input and (2) the internal comparator
synchronized to the Timer1 clock source. Before discussing how these features make
creating a delta-sigma ADC easy, let’s review how such a converter works.
How a Delta-Sigma ADC Works
Figure 1 shows the circuit diagram for a typical comparator based delta-sigma ADC.
Two resistors are used to create a reference voltage of V DD /2 at the positive input of
the comparator. The negative input of the comparator is tied to the analog input via a
resistor. Another resistor of the same value connects the negative input to the output
of the comparator via software. A capacitor, C1, connects the negative input of the
comparator to ground.
Figure 1: Delta-Sigma Converter Using a Standard Microcontroller
The output of the comparator is sampled at a constant frequency. When the comparator
output is high, the pin driving the negative input of the comparator (C IN -) is driven high
in the software. This causes the voltage at C IN - to increase until it is above V DD /2. At
this point, the comparator output becomes low and the pin driving C IN - is driven low in
the software. Now the voltage at C IN - will fall until it is below V DD /2. This cycle continues
to repeat itself. During this process, two things are measured — the total number of
samples and the number of samples that the comparator output is low by. The ratio of
low samples to total samples gives the ADC result. A very high resolution is possible
because the resolution is directly related to the number of times the output is sampled.
This method requires software to sample the comparator output and then mirror this
output on the pin driving C IN -. A connection directly from the comparator output to
C IN - is not possible because the pin can only change when the comparator output
is sampled. In addition, software is used to count the total number of samples and
the number of samples that are low. Though a PIC microcontroller is very capable of
performing this task, special care must be taken when creating the software to ensure
the comparator is sampled at a set time interval. Furthermore, the PIC microcontroller is
limited in which tasks it is capable of performing while the conversion is taking place.
How a PIC ? Microcontroller Simplifies the Conversion
Two features on newer Flash-based PIC microcontrollers allow this task to be accomplished with
fewer processor resources and with greater speed. These features are the Timer1 gate input and
the option to synchronize the comparator output changes to the Timer1 clock source.
The comparator can be configured to change only on the falling edge of the clock source for
Timer1. This makes it possible to tie the comparator output directly to CIN- via a resistor because
the output will only change with the Timer1 clock source. Software is no longer required to
sample the comparator output and mirror it on the pin driving CIN-.
Synchronizing the comparator output with the Timer1 clock source ensures the comparator is
sampled at constant intervals. The Timer1 gate function can be used to count the number of
times that the comparator output is low. With the Timer1 gate functionality enabled, Timer1 is only
incremented when the gate is active. (Note the Timer1 clock source continues to run regardless
of the Timer1 gate input.) The Timer1 gate can be tied to either the output of the comparator or
an external pin. The ability to gate Timer1 with the comparator output simplifies the delta-sigma
ADC conversion. Figure 2 shows the circuit with Timer1 gated by the comparator output and the
comparator synchronized to the Timer1 clock source.
Timer1 is used to count the number of
times the comparator output is low. Since
Timer0 uses the same clock source as
Timer1, the total number of samples can
be counted using Timer0. Timer0 is an
8-bit timer, whereas Timer1 is a 16-bit
timer. To complete a 16-bit conversion,
the prescaler for Timer0 can be set to
1:256 so that Timer0 will interrupt after
65536 (2 16 ) samples. Assuming the
microcontroller is a PIC12F683 clocked by
the internal 8 MHz RC oscillator, a 16-bit
ADC conversion will take approximately
33 ms. Note also that instead of using a
resistor divider circuit on C IN+ to generate
Figure 2: Delta-Sigma Converter Using the PIC12F683
Conclusion microcontroller ’s internal V REF circuit.
The Timer1 gate and comparator synchronization features are found on many of Microchip’s
newer Flash-based PIC microcontrollers. These features allow a 16-bit delta-sigma ADC to be
implemented entirely in hardware. Not only does this allow for faster conversion times, but the
PIC microcontroller is free to process other tasks while the conversion takes place.
Authors: Reston A. Condit, Senior Applications Engineer, Security, Microcontroller & Technology Division,
Microchip Technology Inc . Justin Milks, Applications Engineer, Security, Microcontroller & Technology
Division Microchip Technology Inc.
Microcontrollers ? Digital Signal Controllers ? Analog ? Serial EEPROMs
4
相关PDF资料
MA180021 MODULE PLUG-IN 18F87J50 FS USB
MA180024 MODULE PLUG-IN 18F46J50 FS USB
MA180028 MOD PLUG-IN PIC18F87K22 PIM
MA2-4-34-625-2-A32-7C CIRCUIT BREAKER MAG 25A PANEL MT
MA240013 MODULE PLUG-IN PIC24 44-PIN
MA240017 MODULE PLUG-IN PIC24F16KA102 PIM
MA240021 MOD PLUG-IN PIC24FJ256GB210
MA240025-1 MOD PIM PIC24EP512GU810 GP
相关代理商/技术参数
MA160012 功能描述:子卡和OEM板 PIC16F193x 44P PIM For PIC18 Explorer RoHS:否 制造商:BeagleBoard by CircuitCo 产品:BeagleBone LCD4 Boards 用于:BeagleBone - BB-Bone - Open Source Development Kit
MA160012 制造商:Microchip Technology Inc 功能描述:PIC16F1937 Plug-in Module for PICDEM PIC
MA160014 功能描述:子卡和OEM板 PIC18LF45K22 Plug-In Module RoHS:否 制造商:BeagleBoard by CircuitCo 产品:BeagleBone LCD4 Boards 用于:BeagleBone - BB-Bone - Open Source Development Kit
MA160015 功能描述:子卡和OEM板 PIC16LF1947 PIM RoHS:否 制造商:BeagleBoard by CircuitCo 产品:BeagleBone LCD4 Boards 用于:BeagleBone - BB-Bone - Open Source Development Kit
MA160016 功能描述:子卡和OEM板 PIC16F1947 PIM RoHS:否 制造商:BeagleBoard by CircuitCo 产品:BeagleBone LCD4 Boards 用于:BeagleBone - BB-Bone - Open Source Development Kit
MA161 制造商:Panasonic Industrial Company 功能描述:DIODE
MA16101BAN 制造商:MURATA 制造商全称:Murata Manufacturing Co., Ltd. 功能描述:HIGH FREQUENCY CERAMIC CAPACITORS
MA16101BBN 制造商:MURATA 制造商全称:Murata Manufacturing Co., Ltd. 功能描述:HIGH FREQUENCY CERAMIC CAPACITORS