I designed the following zero crossing detector using an FOD819S optocoupler (U5):
The source of the optocoupler is connected to a MB6F full-bridge rectifier (D2) which is supplied by a 9V transformer connected to 220V AC/50Hz. The 3.3V regulator (U8) supplies power to an ESP32 microcontroller and a segment display (not shown in schematic).
I probed the circuit in T1 (in blue, relative to GND) and it works as expected most of the time. For reference, I connected another probe to T2 (in yellow) before the full-bridge rectifier.
However, when cutting and re-applying AC to the transformer, it sometimes shows some odd behavior:
Or it simply stays at 0V:
Another issue is that the detected frequency is ~10% above 100Hz (not stable) which is also what I detect from a microcontroller using an interrupt on falling edge. It might be a consequence of the slow rise time.
What is wrong with this circuit? Should I add a constant load before the regulator?
Here is the signal when using the first circuit from Dave Tweed (with a pull-down resistor):