An Informative Guide to the PicMicro Comparator
An Informative Guide to the PicMicro® Comparator
One company worthy of the word ‘innovative’ is Microchip, as they deliver ground-breaking products that can make technology faster, compact, dependable and easy-to-use. One of their most revolutionary products in recent years is the PicMicro® microcontroller, because the flash-based technology can be incorporated into a variety of everyday technology items used within the home or automotive, industrial and healthcare industries.
For those unfamiliar with the PIC12F/16F family of devices, you should know it features on-chip voltage comparators that offer a combination of the PICmicro® MCU architecture, the flexibility of the Flash program memory and the voltage comparator’s mixed signal nature. The unique amalgamation can therefore provide a more affordable fusion of the digital/analog block with the flexibility and power to perform in the analog world. We are therefore offering informative advice on how the PicMicro® comparator can be applied to a range of microcontroller applications, so a product designer or engineer can utilize the most discrete voltage comparators.
Low Battery Detection
It is helpful for a circuit to be able to identify when a battery is experiencing an insufficient charge, which will prevent its operations. This is often determined by a comparator-based circuit, which is comparable to the Programmable Low Voltage Detect peripheral. If the peripheral is not featured within the microcontroller, it is possible to implement a similar circuit from a comparator and additional components.
Rapid Change Detection
As well as knowing what a charge is, it is also essential to know when the change occurs when monitoring a sensor. The traditional method has been to store a copy of the output and intermittently compare the held value to the actual output, which can control the change. However, it is often much faster to use a single comparator within a microcontroller to use a comparator interrupt flag, which indicates when a change has taken place. Fortunately, if it impossible to use the interrupt flag or two comparators are sharing the same interrupt flag, there is always the option of the comparator output polarity bit.
External noise and switching noise within the microcontroller can result in the comparator output to “chatter”, which occurs when a comparator’s input voltages are almost equal. An engineer will more than likely want to avoid the chatter, which is why it is possible to feed back some of the comparator output voltage to the non-inverting input of the comparator, which will create hysteresis – which is responsible for raising the comparator threshold when it is below the threshold, and vice versa. It is important for the input to overshoot the threshold, which will result in a change to the comparator output, because the comparator output will not produce a chatter if the overshoot is much higher than the input’s noise. To do so, it is recommended you calculate the resistor values required, which you can do by determining the high and low threshold values (VTH and VTL).
Measure the Pulse Width
The PicMicro® comparator can be combined with the Timer1 and Timer1 Gate input option to effectively measure the incoming analog signal’s high or low pulse width. The purpose of Timer1 Gate is to serve as a count enable for Timer1. When the input is low, it is Timer1’s responsibility to count, but if the T1G indicates the input is high, Timer1 will not count. An engineer should therefore add the T1G with the comparator to successfully measure the time between the high-to-low output change, in addition to the low-to-high output change. To effectively measure a transition, set the CINV bit within the comparator CMCON register to invert the comparator output. However, it is important to note that only comparators with the ability to synchronize an output with Timer1 should be utilized, and the C2SYNCE must also be set. Should the on-chip comparator be unable to synchronize the output to the Timer1 Clock, it is possible to synchronize the output externally with a D flip-flop.
The Window Comparison
A designer or engineer may find it helpful to identify why a signal has moved away from the safe operating range of values or the window or operation. A window comparator features a circuit within the alarm, which identifies when a signal has moved above or below the established safety limits, whilst ignoring minor fluxes. If you wish to install a window comparator, you will require two voltage comparators and three resistors (R1, R2 and R3).
Please note, the above recommendations are provided as a suggestion only, and are subject to change due to technology updates.
Disclosure: This is a collaborative post and the author's views here do not necessarily reflect those of the blog owner.