I am using a NPN type and PNP type inductive proximity and optical sensors in my project.
The sensor connections will be given at the customer end. Even after documentation and legend in PCB, I am afraid if the customers giving the wrong connection. Say example: Power of sensor to signal in PCB likewise...
I want to ensure even if they wrongly connect it should not harm the control board.
If the sensor is burst/malfunctioning then i dont want to have the impact to the micro controller. Hence i optically isolated the micro controller from the external circuitry.
PC817: You didn´t optically isolate them, because both sides have the same GND.
The same level of protection can be made cheaper without optocouplers. A simple bjt, or a current limiting circuit. The OPTO is useless.
***
Diode:
* either in series with the current.
* or inverse parallel to the optocoupler LED
Hello Murugesh_89,
I suspect you have D2 in circuit to prevent accidental reverse polarity connection from your PSU?
If so, you need to place your 12V rail onto the cathode side if D2. Otherwise it will only be protecting the 7805 voltage regulator.
Regards,
Relayer