Zero crossing detector inconsistency
If you want to monitor the output of the bridge rectifier, put your optoisolator in parallel with the power supply, not in series with it. Note that this requires an extra blocking diode (D6) in order to prevent the power supply input capacitor from driving the optoisolator LED.







simulate this circuit &ndash; Schematic created using CircuitLab

Better still, put the optoisolator upstream of the bridge rectifier. Then every rising and falling edge at its output represents a zero crossing of the AC voltage.







simulate this circuit