Programmable Window Comparator Uses A Single Reference
Microchip » PIC12F675
Voltage-monitoring circuit is based on Microchip 12F675 MCU
A voltage monitor is a common hardware need. But beyond a simple compare, many systems must provide a tolerance around a specific value. Specifications of 2%, 5%, or 10% typically require a windowed comparator, with a voltage reference and resistive divider components for setting the tolerance. All are available in many forms.
The controller described here, based on the Microchip 12F675, allows the user to dynamically select the window characteristic as a tolerance. The voltage-referenced-based trip at pin 7 is converted by the analog-to-digital converter (ADC) at that input (AN0), and the selected tolerance (determined by a two-bit code at pins 4 and 5) is applied to the converter count (see the figure).
The program calculates and applies the two-bit coded tolerance to this measured count and then uses these limits to compare against the converted signal under test, VIN, at pin 6. (For the code listing) The programming code is simple enough, provided in assembly language, with a table-based tolerance map used to define the limit scaling processes. Coded tolerances in the map provide for a ±2, ±5, ±10, or ±20% window.
Pin 3 outputs a low true for «VIN in tolerance». Pin 2 outputs a low true for «VIN less than the maximum tolerance». Accounting for the converter, algorithm, and reference-based tolerances and variations, the trip error will be less than four or five steps. For this application, using 3.296 V (4.096 V × [4.12/5.12]) at the ADC (AN0) and 2% tolerance, the measured trip errors at ambient temperature were 2 to 5 mV. This is less than two converter steps.
The monitor’s responsiveness reflects its processing base. Using the 4-MHz internal oscillator option, the maximum response is less than 200 µs. For best performance, the voltage-based trip at pin 7 should be at least half the full-scale reference used for the converter, configured in this application to utilize the controller’s VDD pin. This allows the calculated ADC limits, based on the selected tolerance, to include the full resolution that’s available from the converter.
The reference value at pin 7 and tolerance settings at pins 4 and 5 are coded to be monitored and re-applied continuously. This single design, therefore, provides a dynamic multiple-tolerance control for applications that must support multiple characteristics. Also, the 10-bit ADC features of the controller can be reconfigured for other PIC controller products, such as the 12HV615.
News on theme: