A phototransistor optocoupler provides galvanic isolation between two circuits by transmitting a signal via light. Inside the standard 4-pin or 6-pin DIP package, an infrared LED shines across a tiny gap onto a silicon phototransistor. When the LED is forward-biased and emits light, the phototransistor conducts, allowing current to flow through the output circuit without any direct electrical connection. This blocks high-voltage transients, eliminates ground loops, and protects sensitive low-voltage microcontrollers from noisy industrial environments.

The Phototransistor Optocoupler: Pinout, Symbol, and Safe Defaults

The standard schematic symbol for a phototransistor optocoupler shows an LED on the input side and an NPN bipolar junction transistor (BJT) on the output side, enclosed in a dashed box to indicate optical coupling. Unlike a standard BJT, the base connection is often left unconnected internally, as the base current is generated by incident photons rather than an external electrical bias.

Standard 4-Pin DIP Pinout

  • Pin 1 (Anode): Input LED positive terminal.
  • Pin 2 (Cathode): Input LED negative terminal (connects to control ground).
  • Pin 3 (Emitter): Output transistor emitter (connects to load ground).
  • Pin 4 (Collector): Output transistor collector (connects to the load or pull-up resistor).

Note: 6-pin variants (like the 4N25) include Pin 6 as the phototransistor Base. Leaving Pin 6 floating is standard practice; tying it to a resistor network can improve switching speed at the cost of sensitivity.

Safe Default Part Numbers and Ratings

When selecting a component for general-purpose isolation, these three part numbers cover 95% of bench and jobsite requirements:

  • PC817 (Sharp/Lite-On): The undisputed workhorse. VCEO = 35V, Max IF = 50mA, Max IC = 50mA. Current Transfer Ratio (CTR) typically 80% to 160%. Available in CTR bins (PC817A, PC817B) for tighter tolerance.
  • 4N25 (Vishay/ON Semi): The legacy 6-pin standard. VCEO = 30V, Max IF = 60mA. Lower CTR (20% to 50%), meaning it requires more input current to drive the same output load. Excellent for educational troubleshooting due to the accessible base pin.
  • 4N35 (Vishay/Lite-On): Similar to the 4N25 but with a slightly higher CTR and faster switching characteristics. VCEO = 30V, typical CTR 50% to 100%.

Biasing and Application Circuit: Isolating an ESP32 from a 12V PLC

A common failure mode in DIY automation is frying a 3.3V microcontroller by accidentally back-feeding voltage from a 12V or 24V industrial load. Here is a complete, verified circuit to isolate an ESP32 GPIO output from a 12V Programmable Logic Controller (PLC) digital input using a PC817.

Design Note: Logic Inversion
Optocouplers in a pull-up configuration act as low-side switches. When the ESP32 GPIO goes HIGH, the optocoupler turns ON, pulling the PLC input LOW. Your firmware must invert the logic state (write LOW to turn the load ON).

Component Values and Wiring Steps

  1. Input LED Resistor (R1): The PC817 internal LED has a forward voltage (VF) of ~1.2V and requires a minimum forward current (IF) of 5mA to guarantee switching. We will target 10mA for a solid margin.
    Calculation: R = (VGPIO - VF) / IF = (3.3V - 1.2V) / 0.010A = 210Ω. Use a standard 220Ω resistor.
  2. Wire the Input: Connect ESP32 GPIO pin to R1 (220Ω). Connect the other side of R1 to PC817 Pin 1 (Anode). Connect PC817 Pin 2 (Cathode) to ESP32 GND.
  3. Output Pull-Up Resistor (R2): The PLC input requires a clean 12V HIGH and a near-0V LOW. We use a 4.7kΩ pull-up resistor to limit the collector current (IC) to a safe ~2.5mA (12V / 4700Ω), well below the PC817's 50mA maximum.
  4. Wire the Output: Connect 12V PLC VCC to R2 (4.7kΩ). Connect the other side of R2 to PC817 Pin 4 (Collector). Connect PC817 Pin 3 (Emitter) to the PLC GND. Wire the junction of R2 and Pin 4 to the PLC Digital Input terminal.

For a deeper theoretical breakdown of optical isolation boundaries, refer to the semiconductor chapter on opto-isolators at All About Circuits.

Operation Regions and Spec-Sheet Realities

Unlike a standard BJT where base current is strictly controlled, a phototransistor's base current is dictated by the LED's photon emission and the device's Current Transfer Ratio (CTR). CTR is defined as (IC / IF) * 100. If your PC817 has a CTR of 100%, an IF of 10mA will yield a maximum available IC of 10mA.

PC817 Operation Regions (Assuming 12V Pull-Up and 100% CTR)
Region Input (IF) Output (VCE) Output (IC) Circuit State
Cutoff 0 mA 12.0V < 1 µA (leakage) PLC reads HIGH (12V)
Active (Linear) 2 mA ~6.0V ~2 mA Invalid logic level (avoid)
Saturation 10 mA 0.2V (VCE(sat)) 2.5 mA PLC reads LOW (< 1V)
Warning: CTR Degradation
The CTR of a phototransistor optocoupler degrades over time and drops significantly at high temperatures. A Texas Instruments application report on digital isolators notes that optocoupler LEDs suffer from wear-out mechanisms that can halve the CTR over a decade of continuous use. Always design your input IF to be at least 2x higher than the absolute minimum required to saturate the output when the device is brand new.

Failure Modes and Multimeter Testing

Phototransistor optocouplers generally fail in two ways: the input LED burns out (open circuit) due to overcurrent, or the output transistor suffers a short due to voltage spikes exceeding VCEO. You can diagnose a suspected bad optocoupler on the bench using a standard digital multimeter (DMM).

Step-by-Step DMM Diagnostic

  1. Remove Power: De-energize the circuit and isolate the optocoupler. Testing in-circuit will yield false readings due to parallel pull-up resistors and microcontroller GPIO protection diodes.
  2. Test the Input LED: Set your DMM to Diode Test mode. Place the red probe on Pin 1 (Anode) and the black probe on Pin 2 (Cathode). A healthy PC817 will read between 1.10V and 1.30V. Swap the probes; the meter should read 'OL' (Open Loop).
  3. Test the Output Transistor: Keep the DMM in Diode Test mode. Place the red probe on Pin 4 (Collector) and the black probe on Pin 3 (Emitter). It should read 'OL'. Swap the probes; it should still read 'OL'. If you read a short (0.00V) or a low voltage drop in either direction, the output silicon has ruptured.
  4. Active Verification (Optional): To prove the optical coupling works, set the DMM to continuity or resistance mode across Pins 3 and 4. While monitoring the meter, use a 9V battery and a 470Ω resistor to momentarily forward-bias Pins 1 and 2. The DMM should show the resistance drop from 'OL' to a few hundred ohms as the phototransistor conducts.

Frequently Asked Questions

Why is my phototransistor optocoupler switching too slowly?

Speed issues in phototransistor optocouplers are almost always caused by the Miller effect and deep saturation. When the phototransistor is driven hard into saturation, excess charge carriers accumulate in the base region. When the LED turns off, these carriers must recombine before the transistor can stop conducting, causing a delayed turn-off time (toff). To fix this, increase the value of your output pull-up resistor to reduce IC, preventing deep saturation, or add a small speed-up capacitor (100pF - 1nF) in parallel with the input LED resistor to provide a sharp current spike during transitions.

Can I use a phototransistor optocoupler for AC zero-cross detection?

No. A standard phototransistor optocoupler is unidirectional and will only conduct during one half of the AC sine wave, resulting in a pulsating DC output that is useless for precise zero-cross timing. For AC zero-cross detection and phase-angle control, you must use a specialized optocoupler with a photodarlington or integrated logic output designed for AC mains, such as the H11AA1 (which features back-to-back LEDs) or a phototriac driver like the MOC3063, which includes built-in zero-crossing detection circuitry.

What is the difference between a phototransistor and a photodarlington optocoupler?

A photodarlington optocoupler (like the 4N32 or PC851) uses a Darlington pair configuration on the output side. This provides a massive Current Transfer Ratio (CTR often 200% to 600%), allowing you to drive heavier loads directly from a weak microcontroller GPIO without an external MOSFET. The trade-off is speed and saturation voltage. A photodarlington has a much higher VCE(sat) (typically 1.0V compared to 0.2V for a standard phototransistor) and switches significantly slower, making them unsuitable for high-speed digital communication like UART or SPI isolation, but excellent for slow-switching relay drivers.