The comparator often is the simplest bridge between analog and digital worlds, but crossing this bridge isn't as simple as might be thought. Keep in mind, we are leaving the analog world with an indefinite number of states and entering into a vastly different world with a finite number of possible states.
In the most common configuration, comparator circuits are implemented with positive feedback, with R1 and R2 providing the hysteresis (Fig. 1). The amount of hysteresis affects the comparator's input/output relationship. Also, signals and noise always coexist in the analog world. Additional hysteresis is added to prevent the comparator output from "ringing" when an analog signal with superimposed noise approaches the comparison level.
A common design goal is to make a hysteresis large enough to prevent the ringing while simultaneously keeping it low enough to achieve maximum sensitivity The threshold values are:
VTH+ = R1 × (VCC − VREF)/(R1+R2)
VTH− = R1 × VREF/(R1+R2)
for the signals below and above VREF, respectively. VTH+ is equal to VTH- only when VREF = VCC/2 (Fig. 2b).
As shown in Figures 2a and 2c, as the VREF level approaches either of the supply rails, the asymmetry of the hysteresis switch points is increased. To maintain the required noise immunity for the smaller threshold, the positive feedback needs to be increased, thus causing reduced system sensitivity.
For illustration purposes, let's assume that the noise present required a hysteresis of ±500 mV. For VCC = 5 V and VREF = 2.5 V, values of R1 = 40k and R2 = 10k will perform well. If VREF moves up to 4 V, the new threshold values will be +200 mV and −800 mV, making the upper threshold 2.5 times smaller than required.
To keep the threshold equal to 500 mV, R2 must be changed to 10k. This modification brings VTH+ up to 500 mV, but also increases VTH− to 2 V. The consequences of setting VREF close to the power rails are clear.
The circuit shown in Figure 3 keeps the threshold value symmetrical around VREF practically for any range (using I/O rail-to-rail op amps). X2 outputs the difference between the reference signal and VCC/2. X3 adds the difference to the signal, allowing comparison on X1 with a new constant reference always set to VCC/2.
The performance difference between the two topologies is obvious when we compare Figure 2 with Figure 4, showing the comparator output for reference signals set to 4 V, 2.5 V, and 1 V. In the waveforms shown in Figure 4, the thresholds are constant and symmetrical for any reference value. On the other hand, Figure 2's waveforms are only symmetrical for the 2.5-V case.
The VCC/2 reference (dashed box in Fig. 3) can be implemented several ways. The lowest-cost approach uses a divider with two equal resistors. However, the value of R2 + R1 must be greater than R9 || R10. Otherwise, the threshold values will be symmetrical but less than calculated. For R9 = R10 = 2k, R2 = 10k, and R9 = 40k, the error is less than 2%; for R9 = R10 = 10k, the thresholds are ±450 mV instead of ±500 mV, but the reduction can be corrected by setting R2 = 11k.