# Op-amp voltage comparator

I am using an op-amp (LF353P) for my voltage comparator circuit. The supply voltage for the op-amp is +12 V and -12 V. The input voltage for the inverting pin (Vref) is 1.1 V. The input voltage for the non-inverting pin (Vin) is a PWM signal from an ESP32 (1 kHz square wave, 10% duty cycle, Vmax = 2.82 V, Vmin = -318 mV).

The output I got from this is a square wave signal with the same duty cycle as a PWM signal from the ESP32 and a maximum voltage of 23 V and a minimum voltage of -1.60 V.

The output I want is a square wave signal with the same duty cycle as the PWM signal from the ESP32 and a maximum voltage of 12 V and a minimum voltage of -12 V.

I changed my 10 kΩ that connects to the 3.3 V to 20 kΩ for 1.1 V (Vref). If I understand correctly, if Vin > Vref, Vo is equal approximately to +12 V, and if Vin < Vref, Vo is equal to approximately -12 V.

If I misunderstood, could you explain how it works or how I can get the output I want?

This is the waveform that I get from the op-amp: • Show waveforms. where is ground on your oscilloscope ? Is it DC coupled or AC coupled ? Aug 15, 2022 at 5:10
• What are you using as the reference, or zero potential node, to read those voltages? Does your opamp +/- 12 V power supply share its 0 V node with the GND symbol on your schematic? Aug 15, 2022 at 5:10
• My opamp +/- 12V power supply is IA1212S and I connected its ground to the ground from esp32. I am using the same ground for my oscilloscope. Aug 15, 2022 at 6:08
• > a maximum voltage of 23 volts and a minimum voltage of -1.60 volts.< ... Why 23 Volts? Aug 15, 2022 at 7:53
• I don't know. I thought it should be +/- 12 volt because my supply voltage is +12V and -12V from IA1212S. Aug 15, 2022 at 7:58

The output I got from this is a square wave signal with the same duty cycle as a PWM signal from the ESP32 and a maximum voltage of 23 V and a minimum voltage of -1.60 V.

Yes, this is normal, the scope is set to AC mode so "0V" on the display corresponds to the average voltage of the waveform. In this case the duty cycle is low, so it spends a lot of time near -12V, so the average is close to -12V, which is why the waveform is shifted up by almost 12V (10.4V in this case).

If you want to measure DC levels, set the scope to DC.

What you should see is something like this ... If you see the wave shifted by 12 V, you used probably -12V of IA1212S as your ground scope, or used AC input in place of DC.

• Thank you. It was my fault that I used the AC couple instead of the DC couple. Aug 15, 2022 at 9:00