We detect you are using an unsupported browser. For the best experience, please visit the site using Chrome, Firefox, Safari, or Edge. X
Maximize Your Experience: Reap the Personalized Advantages by Completing Your Profile to Its Fullest! Update Here
Stay in the loop with the latest from Microchip! Update your profile while you are at it. Update Here
Complete your profile to access more resources.Update Here!
Item Qty
Your cart is empty.

What is a Comparator?


A comparator simply turns an analog voltage level into a digital low or high output. We offer both stand-alone and on-chip comparators. PIC® and AVR® microcontrollers (MCUs) have integrated, on-chip comparators to provide flexibility, intelligent control and lower power consumption to your design.

Why Use a Comparator?


The on-chip comparator is a combination of intelligence and flexibility. It also can work independently from the MCU’s core, which adds low-power options to your design. Here are some benefits of using an on-chip comparator:

High-speed Response with Low Power Consumption

Offering a fast response time along with low power consumption, the on-chip comparators on 8-bit PIC and AVR MCUs provide reliable feedback about the signal input of your design.

Easy-to-Use Intelligence

The comparator provides multiple dynamic voltage references such as the supply voltage (VDD), Fixed Voltage Reference (FVR) and output from the internal Digital-to-Analog Converter (DAC). You can use the DAC to set the voltage reference at any level within the range of your supply voltage and change the value on the fly. If your input signal has a lot of noise, you can configure the comparator to use hysteresis, or you can choose not to use hysteresis to achieve a more sensitive response.

Flexible Outputs

The comparator’s outputs can be programmed to perform a number of functions. They can be used to trigger an interrupt, as input signals for other peripherals, or to connect to the Configurable Logic Cell (CLC) on a PIC MCU or the Event System on an AVR MCU. They can also output externally to an I/O pin.

Core-Independent Operation

The on-chip comparator can operate completely independently from the core for power savings. The core can be in sleep mode when the comparator is operating and be awakened by an interrupt. The internal routing capability provided by the CLC and Event System enables the core to stay in sleep mode all the time, which is a huge benefit for battery-powered applications.

8-bit Microcontrollers with a Comparator Peripheral


Microchip Minutes - Episode 6 - Basic Comparator Setup

In this video we are demonstrating how easy it is to configure peripherals on a PIC® Microcontroller, using the graphical code generation tool MPLAB® Code Configurator. By setting up a comparator to compare the voltage from a potentiometer and an internal fixed voltage reference, we can drive an output such as turning on or off an LED based on the comparison result. This entire setup can be done with MCC without any user written code. In this example we are using Curiosity HPC board with PIC16F18875 MCU and the MPLAB X IDE.

Documentation


Title
AVR128: Setup and Use of the AVR Analog Comparator Download
Core Independent Voltage Window Signal Detection Using a Single Comparator Download