How to work with inbuilt Analog Comparators of PIC18F4550
Summary
Analog comparator is an electronic device which compares the two voltage signals and provides TTL logic output to indicate the larger signal. The analog comparator is used in various applications where two inputs signals need to be compared. IR sensor is a very common example where analog comparator is used.
Description
PIC18F4550 consists of two analog comparators and these comparators can be used in eight different modes. The analog comparators’ I/O pins are multiplexed with PortA pins (RA0 - RA5) pins of the controller. The register CMCON is configured to set the mode of the comparator in a PIC microcontroller. The bits of CMCON register are explained below.
Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
C2OUT | C1OUT | C2INV | C1INV | CIS | CM2 | CM1 | CM0 |
CM2:CM0 | Mode | Description |
000 | Comparators Reset | The comparators remain reset and the output is read as zero |
001 | One Independent Comparator with Output | Comparator 1 is active with external output at RA4/C1OUT pin |
010 | Two Independent Comparators | Both comparators work separately with output changes at C1OUT and C2OUT bits respectively |
011 | Two Independent Comparators with Outputs | Both comparators work separately with external outputs at RA4/C1OUT and RA5/C2OUT pins respectively |
100 | Two Common Reference Comparators | The comparators works separately having common reference voltage on positive reference pins of the comparators with output changes at C1OUT and C2OUT bits respectively |
101 | Two Common Reference Comparators with Outputs | The comparators work separately having common reference voltage on positive reference pins of the comparators with external outputs at RA4/C1OUT and RA5/C2OUT pins respectively |
110 | Four Inputs Multiplexed to Two Comparators | Both comparators have multiplexed input at negative reference pin of the comparator. The common reference voltage at positive reference voltage pin comes from internal voltage reference module with output changes at C1OUT and C2OUT bits respectively |
111 | Comparators Off | Both comparators remain off |
Video
Code
This Code is only visible to Registered users. Please Login/Register
Components
|
LED Light emitting diodes (LEDs) are semiconductor light sources. The light emitted... |
|
Infrared LED An IR LED, also known as IR transmitter, is a special purpose LED that transmits infrared rays in the range of 760 nm wavelength. Suc... |
|
PIC18F4550 PIC18F4550 is an 8-bit microcontroller of PIC18 family. PIC18F family is based on 16-bit instruction set architecture. PIC18F4550 consists of 32 KB flash memory, 2 KB SRAM... |
- 8510 reads
