# Protect PC817 Optocoupler Anode from High Voltage

Voltage at IN3 will vary from 10V to 28V, How can I protect the optocoupler from getting damaged due to high voltage.

What is the maximum voltage and Minimum voltage should be given at anode (Pin 1) to sense LOW properly on GPIO.

Is there any external pull up needed at Pin 4 connected to GPIO of MCU.?

EDIT :

I am doing few calculations based on the comments, let me know if they are right

First of all the Optocoupler forward voltage is 1.2V and the maximum forward current for LED is 60mA.

The value for resistor R13 should be

We will take LED current as 10mA

R = (Vin - Vf)/I

R = (12-1.2)/0.01

R = 1080 ohm ~ 1K resistance

If Voltage is increased upto 28V,

I = (28-1.2)/1000
= 26mA


This is well below the maximum LED current i.e 60mA. So there should be no issue with the high voltage and the 1K resistor is fine.

Now coming to collector load resistor value which is not mentioned in the image,

in data sheet the Vce saturation voltage is 0.1~0.2V

Ic = (Vcc-Vce)/R
= (5-0.1)/10000
= 0.49 mA


This value is also well below the maximum collector current which is 50mA.

So I think based on above calculation, Input resistor of 1K will work fine and collector Load resistor has to be added of value 10K. • Did you read the datasheet?? farnell.com/datasheets/73758.pdf Sep 24 '17 at 17:30
• why common gnd .. that defeats isolation.. like any OC logic pullup and min max current *CTR min/max defines margin with Vc= Vcc-IcRc thus indeterminate without Rc. Sep 24 '17 at 17:38
• @LearnerLearner: Tony is trying to say a few things: (1) Usually opto-isolators are used to provide complete isolation between one circuit and another. You have both sides sharing a common ground, therefore they're not isolated, therefore why do you need the opto-isolator? (2) Opto-isolators have a current transfer ratio. e.g., At 5 mA of LED current you can get a maximum transistor collector current. Since we don't know your collector resistor $R_C$ we can't finish the calculations. Sep 24 '17 at 18:02
• (3) "Margin" is a safety factor after you've done your calculations. e.g., If 5 mA should work on the input then set it to 7 or 8 mA for safety and deterioration of the LED over time. Sep 24 '17 at 18:02
• @TonyStewart.EEsince'75: You contribute a lot to the site but I think that you go over the head of the OPs quite often using acronyms, initialisations and electronic concepts that the users may not have come across. An extra few moments writing complete English sentences (subject - verb - object) would help too. This is just friendly feedback. Sep 24 '17 at 18:17