Sizing a Resistor for a PC817 OptoCoupler

Hi there!

I'm using an optocoupler to sense when a couple of signals in my car are high. I'm struggling though to understand how big a resistor I should put on the input to drive the LED.

I have a couple of working voltages, one at car running voltage ~14.4v and one at 5v. Looking at this datasheet, there are a number of versions of the PC817: https://www.farnell.com/datasheets/73758.pdf

It seems only the X1 is currently available on component sites, so assuming this version of the component, what amount of power should I need to drive it for each voltage case?

Thanks!

5 mA would be plenty for the LED in the coupler. Given the voltage drop of the LED at 1.2 V, for 5 V, then 4V divided by 5 mA is 800 Ohms, a common value is 820 Ohms (and there is no requirement whatever for precision).

for 14.4 V, you are looking at 13.2 V across the resistor, divided by the 5 mA that makes 2.64k, the common value is 2.7k. The resistor will dissipate only 65 mW so a one-eighth Watt resistor would be fine.

Now the CTR for this device is specified at 0.5 (50%) absolute minimum, so at 5 mA, you should get at least 2.5 mA through the transistor. If you are using an Arduino, you connect the transistor between an input pin and ground and use INPUT_PULLUP in pinMode; this will work perfectly as long as the coupler is close to the Arduino to avoid any possible leakage currents.

The internal pull-up current is actually about 100 µA so the transistor easily switches it. An external 4k7 pullup would work just as well, drawing 1 mA.

1 Like

Amazing, thanks very much Paul that's an excellent explanation!