I have a simple drawing of ZCD by using potential divider to stepdown the voltage feeding to the inverting and non-inverting input of LM358N.
The simulation result as below
In practical, I connect my AC cord to the transformer as below that stepdown 230VAC to 12VAC. The model of the transformer as below. The AC cord I connected to 230 and 0V at the transformer input while transformer output, I connected 12 and 0V to feed to the 6K ohm resistor as the 1st circuit diagram above. The opamp is power by a 5V adapeter. When the AC cord connected to transformer and adapter are power on, the measured output waveform as shown below. I cannot even get a slightest glimpse on what going on in the circuit and why it differ so much from my understanding. For my current understanding, imagine the output of the transformer at the pin 12V function like a sine wave with 12sinwt. When wt=0, the noninverting input and the zero reference ground is 0, hence output is 0. when wt>0, non-inverting is bigger then the inverting reading which have 0 reference hence the waveform should be positive. When wt=180 degree, the difference is again 0 with reference to ground. When wt>180, the non-inverting input is negative value as compare to inverting input with 0 ground reference at transformer according to formula $$V_o=A(V^+ - V^-)$$. Hence output is negative value, but since the supply source is 5V to 0V, the output should be clipped at 0V since not able to go to negative value but why practical result shown entirely different result. The Opamp output should be zero at the negative half cycle but oscilloscope shown it as positive value?