# Understanding this comparator circuit for AC voltage protection

The circuit shown below is taken from this whole design. I understand the main idea. They want to measure some voltage condition and trigger something else with the comparator. R39 and C38 form a low pass filter. R37 is the pull-up resistor as the comparator's output is open collector. D19 and D20 are protection diodes as the input goes positive and negative. What I don't understand is the arrangement of the resistors R36, R38, R35, and R40. Why are R36 and R38 referenced to ground in the midpoint? How is the comparison process achieved? According to the reference design, the input AC voltage is 230 VAC 50/60 Hz.

The design appears to assume that L and N can be swapped. This is a common problem in countries with reversible mains plugs. The circuit, therefore, needs to accommodate live on either pin.

Let's ignore D19, 20 and C37 for a now.

With the junction of R36 and R38 earthed one of the comparator inputs will be grounded. Remember that the neutral is so called because one of the supply wires has been earthed or 'neutralised' at the supply transformer so its voltage will be close to zero. As drawn, 'AC_N' will be at zero volts and since the top of R38 is at zero volts the junction between them will be at zero volts. The comparator '+' input will now also be at zero volts. Any time AC_L goes negative the comparator output will switch high. The result is a squarewave which goes high when AC_L is negative and low when positive.

Reversing the input polarity inverts the result.

D19 does two things when AC_L goes positive:

• It limits the voltage on IN- to one diode drop above that on IN+.
• It causes the voltage on IN+ to rise above zero somewhat. This is probably a good thing as it gets the inputs away from operating at 0 V (although the chosen device will work down to zero on the inputs.)

simulate this circuit – Schematic created using CircuitLab

Figure 1. Equivalent circuit while AC_L is positive.

You can work out what happens on the negative half cycle or when the live and neutral are reversed.

• Nice explanation. But regarding 'AC_N' will be at zero volts ...with respect to what? AC_N can be 50V with respect to earth. Jul 15, 2019 at 19:40
• I wouldn't call that 'neutral' then! The circuit should accommodate that, I think. Jul 15, 2019 at 19:44
• Thank you both. I guess I need to study these kind of circuits more often for me to fully understand it. Honestly, I will read your comments again and again until I understand it because I haven't. So, this circuit is just to detect a zero cross needed for the PFC stage software? ZC_IN goes straight to a MCU pin.
– user115094
Jul 15, 2019 at 19:47
• @Blue_Electronx It is the MCU that does the PFC (PFC_PWM to control the boost converter), etc Jul 15, 2019 at 19:52
• I wanted to do some math, but I don't know the values of R35, and R36. The BOM list has a mistake regarding them. So, let's say input voltage is 230VAC, the voltage at the -IN would be dependent on the ratio of R35, R36, right?
– user115094
Jul 15, 2019 at 20:29

Note that the whole shown circuit (so, +3.3V, +12V, ZC_IN, etc) should be considered live and thus dangerous).

The shown picture has cut off the name of the output that gives an important hint: ZC_IN, which stands for Zero Crossing in.

D19 and D20 clamp the floating line voltage to a floating 0.7V volt, where R35 and R40 limit the current through D19 or D20. I mean floating with respect to the circuit's ground. R36 and R38 'align' this floating 0.7V with respect to ground. So, the comparator will see a sine wave which matches the line voltage at the zero crossing, but will be clamped between -0.35V and 0.35V.

This zero crossing is required to make a good PFC.

Below a picture of the (clamped) voltages the comparator sees at its input terminals.

• What resistors values did you use in your simulation?
– user115094
Jul 16, 2019 at 20:12
• @Blue_Electronx I don't remember exactly. I think I used something "standard" like R35=R40=10k and R36=R38=1k and D19=D20=1N4148. What components are being used in the real STEVAL-CTM010V1? Jul 17, 2019 at 6:30
• The published BOM list has a mistake regarding those resistors, so I haven't figured them out.
– user115094
Jul 17, 2019 at 13:06

The depicted ground is not a chassis ground, it is a floating ground. R36 and R38 are bleeding resistors and they set this floating ground potential at mean voltage between N and L.

The chassis ground, which is also conencted to PE wire is depicted differently: