Optocoupler Node is Floating error

Hello everyone,
I am designing for a Project a circuit to detect zero-crossing using a microcontroller. I want to use an optocoupler for isolation between the high voltage (coming from 3 phase) and the microcontroller. I have a transformer to reduce the voltage, a diode bridge rectifier and a comparator (as op-amp). I tried putting the optocoupler just before the comparator (in parallel to rectifier output); I got:
One of the nodes of the optocoupler (connected to comparator) is floating.
What to do to solve the issue? Please if I can get help.
Thank youu

please post a screenshot or your schematic.

hard to see what is going on without these

Thank you for your reply @Albert_Dunford
I think I connected the transistor wrong. What to do to correct?

This gave the needed result, but with a DC offset of 4-5 V. Could the pic16f877 detect rising edges?

Yes, the first schematic has control elements on the output stage, there needs to be a resistor over here as the output is generating a current.


In your second image you are using a resistor. Please have a look at the example circuit:
image Opto_Synchro.psimsch (31.5 KB)

So my second circuit is correct? And I something more: my Vout_min = 4V. How to make it 0 V?
-Edit- Now I changed the high output of the comparator to 5 V in the first circuit (with optocoupler removed) and fixed!
In the second circuit I added the same comparator and an inverter and fixed! Thank youu