# Comparator circuit with rail to rail opamp

In the comparator circuit below, when we select the operational amplifier as "rail to rail input" type, the reference voltage falling on the non-inverting pin is a square wave.

Why do we see a square wave on the non-inverting pin?

What are the differences between "Rail to rail input", "Rail to rail output" and "Rail to rail input/output" operational amplifiers?

What are the differences between "Rail to rail input", "Rail to rail output" and "Rail to rail input/output" operational amplifiers?

• "Rail to rail input" means that the op-amp will work fine with voltages at the inputs close to the rails. For example, between 0 and 5V in your circuit.
• "Rail to rail output" means that the output voltage can go close to the rails (or almost).
• "Rail to rail input/output", both of the above.

You can check it in the datasheet: Input Voltage Range and Output Voltage swing/range or high/low

What you see is not a square wave, it's the reaction of the comparator's input stage.

The amount of change is not much, only a fraction of a mV.

The input stage of the IC appears to be a complex circuit. See the block diagram on p.16 of the datasheet.

You feed the reference voltage from a voltage divider. This effectively means applying the divider's output voltage through a resistor:

simulate this circuit – Schematic created using CircuitLab

If you check the characteristics on p.10 of the datasheet, you'll see that the input bias currents (the currents drawn from or flowing out of the input pins) change with the differential input voltage. In your application, the differential input voltage will vary with the rectified sinewave.

Since the input bias current will be drawn from your divider (see the Vth source in the right-hand-side circuit above), the effective voltage on the pin will change accordingly. For example, a bias current of 2 μA makes a change of ~1 mV, hence the so-called pulsating voltage you observe on non-inverting input.