Specifications

mikroElektronika | Free Online Book | PIC Microcontrollers | Chapter 7: Analog Modules
Fig. 7-6 Analog Comparator
When the analog voltage at Vin- is higher than the analog voltage at Vin+, the output of the comparator is a digital
low level; and
When the analog voltage at Vin+ is higher than the analog voltage at Vin-, the output of the comparator is a digital
high level.
The PIC16F887 microcontroller has two such voltage comparators whose inputs are connected to I/O pins RA0-RA3,
whereas the outputs are connected to the pins RA4 and RA5. In addition there is also a referent voltage internal source on
chip itself, but it will be discussed later.
These two circuits are under control of the bits stored in the following registers:
CM1CON0 is in control of comparator C1;
CM2CON0 is in control of comparator C2; and
CM2CON1 is in control of comparator C2.
Voltage Reference Internal Source
One of two analog voltages provided on the comparator inputs is usually stable and unchangeable. Because of those
features it is called "voltage reference"(Vref). To generate it, both external and special internal voltage source can be
used. After selecting voltage source, Vref is derived from it by means of ladder network consisting of 16 resistors which
form voltage divider. The voltage source is selectable through both ends of that divider through the VRSS bit of the VRCON
register.
In addition, the voltage fraction provided by resistor ladder network may be selected through the bits VR0-VR3 and used
as voltage reference. See figure below.
http://www.mikroe.com/en/books/picmcubook/ch7/ (7 of 14)5/3/2009 11:34:24 AM