PIC12F675 Comparator Code and Proteus Simulation

PIC12F675 Comparator

This post provides the comparator code for PIC12F675 microcontroller. As we know, PIC12F675 microcontroller has one built in op-amp, which can be used as comparator. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

PIC12F675 Comparator

It is assumed that you know how to blink an LED with PIC12F675 microcontroller. If you don’t then please read this page first, before proceeding with this article.

The result of simulating the code in Proteus is shown below[1].

In the above circuit[2], a variable voltage signal of 0 to 5 volts can be applied on Pin6 of PIC12F675 controller. Pin7 and Pin6 are the input pins for the comparator and Pin5 is output pin. In the above circuit shown, Pin6 is attached with the -ve pin of the comparator and on the +ve pin a reference voltage of 2.5v are applied internally. LED attached on the GP5 pin shows the result of the comparator.

So, in the above figure, GP5 pin is high because voltage on Pin6 of PIC12F675 is 2.45v, which is less than 2.5v. If a voltage higher than 2.5v is applied on Pin6, then GP5 will become low.

Comparator schematic

Read more: PIC12F675 Comparator Code and Proteus Simulation

Leave a Comment

Your email address will not be published. Required fields are marked *