In PV grid connected inverter, in order to inject the current at unity power factor we need to know the polarity of the grid . To do so various solutions exists. Among these solutions is the use of optocoupler. I have verified the use of 4N26/4N37 for the said purpose. The circuit is very simple and its working is given below.