# Interface optocouper with wide voltage range

I need to interface optocopuler with my GPIO (3V Max) to detect presence of a wide voltage range in the optocopuer input (5V - 30V). After searching all different parts I have come up with this parts and circuit. Please let me know if it is a correct.

simulate this circuit – Schematic created using CircuitLab

Datasheet of VOD207T http://www.mouser.com/ds/2/427/vod205t-537247.pdf

Note. Edits on the question's schematics were performed when I was typing the answer. I will strikeout those considerations that are no more valid.

The circuit is fine except these considerations:

• (Minor) You wrote +4V on the logic side: I guess you meant 3V.
• (Critical) You're correctly using the 317 as current generator. However, with that resistors (R1 and R2 at 24 Ohm), the current is set to about 50mA, which is larger than the absolute maximum continuous forward current (30mA). The VOD207T works also with 10mA. You might need to adjust the resistor to 120 Ohm. EDIT: now the current is 5mA. Maybe too low, see later.
• (Major) The output resistors are quite low (100 Ohm) , especially if you change the driving current. EDIT: with a 5mA current and 100 Ohm, you can't have a 3V swing, as the minimum CTR (current transfer ratio) is 100%. If you don't need a very high switching speed, you should consider to increase it to something about 330-470 Ohm (the larger, the better the low level, but the slower the switching speed). (EDIT: these values is calculated for 10mA current drive). Still, 100 Ohm will be too low, because the CTR min of that optocupler is 100%. With 10mA-input, you get a 10mA output, which corresponds to about only 1V-swing @100 Ohm.
• (Major) Be aware of power dissipation. At 30V, 1.2V falls in R1/R2, and about 1.2V on the LED of the optocoupler. This means that there are about 28V on the LM317L. It's thermal resistance Juction-to-Air is 160-180°C/W in TO92 package, i.e. quite high. At 10mA, the increase of the temperature between junction and air is 50°C. If you set a 20-mA current you have a 100-°C difference.
• Thank you for the detailed description. I am lost now.. Trying to build a cost effective PCB, but this part of the design is driving me crazy.. Any alternate idea where I can do the same with a cheaper way.. BTW that +4V is not logic, that's my main voltage of the circuit and MCU is also driven with that voltage. Moreover I'll detect Logic LOW at the MCU. So, when the phototransistor is off, the GPIO is pulled up by R3 and when it is on, my GPIO will be low (Correct me if I am wrong). Now the power dissipation is really something to be worried about.. I am lost there :( – Rakesh Mehta Sep 4 '17 at 17:08
• Do you need fast switching speed? – next-hack Sep 4 '17 at 17:10
• Not really. Speed does not matter.. I just want to be alerted when the external supply is on or off.. – Rakesh Mehta Sep 4 '17 at 17:11
• Yes then my though is correct, about 8-9 milivolt according to my calculation.. So this circuit will definitely come within 1 dollar :) which is good enough for me.. Thank you very much for all of your guidance! I have just started with circuits and thus such silly questions. – Rakesh Mehta Sep 4 '17 at 17:45
• BTW, I am going to use 120 ohms with LM317 to increase the current and replace that 100 ohms with 10K – Rakesh Mehta Sep 4 '17 at 18:04