Electronic – Why such analog comparator input setup

analogcircuit analysiscomparatormicrocontrolleroperational-amplifier

My understanding of an analog comparator is that you have a fixed reference voltage applied to one input and an AC signal to the other input, when the signal's voltage > reference voltage, the output of the comparator will be logic high, else logic low.

enter image description here

I was looking at the input stage of one of the MCU's analog comparators. Signal applied at AIN0, reference is applied at AIN1, pin5 toggles between Vcc and 0 to shift AIN1 by +- ~0.04V.

But what I don't understand is it has a 100k resistor (R2) connecting both inputs. What's the purpose of that? Wouldn't that make the reference vary as well?

Any suggestions are greatly appreciated, thanks.

Best Answer

The junction of R3 and R4 can be (should be) regarded as producing a fixed DC voltage of Vcc/2. C2 smooths any AC ripple on this voltage keeping it free from variations injected by the input signal via the 100 k resistor (R2).

But what I don't understand is it has a 100k resistor (R2) connecting both inputs. What's the purpose of that?

No, R2 just takes the Vcc/2 bias and applies that DC level to pin 7 so as to roughly centre pin 7 in the middle part of the range of the comparator's input.

R5 also couples Vcc/2 to pin 6 thus biasing pin 6 at Vcc/2 BUT pin 5 can modify that bias point via the 1 Mohms resistor R6.

I don't know where the circuit is used or for what but it looks like some kind of data decoder where the unknown data enters as the "signal input" and pin 5 is used (possibly at a high frequency toggle rate) to adjust the comparator trigger point.

If you can supply more details then I'm happy to fill in other gaps.