In this circuit, if i connect the pwm (mcu output) to the pwm_output directly ( without optocouper) everything is fine but whenever i use optocoupler opamp is never triggering. Can anyone help ?
You need, at a minimum, a pull-down resistor to ground from the emitter of the optocoupler. Then you will also need a resistor and capacitor low pass filter to turn the pulses into DC.
the op amp input is "high impedance"
so if you connect the transistor part of the opto to the op amp input
"zero" or about that current flows,
as @DickCappels says, put resistors on the output of the opto, and you give some where for the current to flow, so the opto can control the current..
The opto output pulls the op amp input signal up to 5V, but there is nothing to pull it down to 0V.
When the opto is off the output is an open circuit, and an open circuit is not necessarily 0V.
With the characteristics of that op amp input (PNP transistors) it likely just stays near 5V.