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.?


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

if Load Resistor is 10K
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.


enter image description here

  • \$\begingroup\$ Did you read the datasheet?? farnell.com/datasheets/73758.pdf \$\endgroup\$ Sep 24, 2017 at 17:30
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ Sep 24, 2017 at 17:38
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – Transistor
    Sep 24, 2017 at 18:02
  • 1
    \$\begingroup\$ (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. \$\endgroup\$
    – Transistor
    Sep 24, 2017 at 18:02
  • 2
    \$\begingroup\$ @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. \$\endgroup\$
    – Transistor
    Sep 24, 2017 at 18:17

1 Answer 1


Like a 'normal' LED, the LED of an optocoupler is not controlled by voltage but by current.

With the 1 kΩ resistor as shown, and with a LED forward voltage of about 1 V, the current through the LED would be between approximately 9 mA and 27 mA; the absolute maximum rating of the PC817 is 50 mA, so this would still be allowed.

However, that's still a lot of current, and might load the output connected to IN3 too much. Consider increasing R13 to 2.2 kΩ or 4.7 kΩ. (It would also be possible to replace R13 with a constant current source.)

You need a pull-up resistor at pin 4. This can be either an external one, or an internal one in the µC. The value of the pull-up is determined by the CTR of the optocoupler; in the worst case, this is 50 % at the specified input current of 5 mA, and less at other LED currents. So assuming that less than 1 mA comes through the optocoupler's output, and that the µC runs at 5 V, the pull-up should be at least 10 kΩ.

  • \$\begingroup\$ Can you check my calculation based on your response as well as based on response in the comment section. \$\endgroup\$ Sep 25, 2017 at 4:32
  • \$\begingroup\$ These calculations look OK. \$\endgroup\$
    – CL.
    Sep 25, 2017 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.