Parts
PC817 optocoupler: pinout, CTR ranks, ratings and a worked interface
By Bulan Sarkar
The PC817 pinout is 1 anode, 2 cathode, 3 emitter, 4 collector. With the printing upright and the dot at top left, the LED is on the left pins (1 at the top, 2 below it) and the phototransistor on the right (3 at the bottom, 4 at the top). Nothing inside joins the two sides, which is why you use one.
The letter after the number, A to D, is the CTR rank: how much collector current you get per milliamp of LED current. This page reads Sharp's current PC817X sheet (OP18002EN), explains the ranks and the 5 kV isolation figure, and works through the LED resistor from a 5 V or 3.3 V pin and the pull-up on the output side, sized from the minimum CTR.
Datasheet: Sharp PC817XxNSZ1B Series, sheet OP18002EN (PDF)Ask Datasheet Guru about the PC817C
Pinout by package
Top view, printing upright, the dot (anode mark) at top left: pin 1 top left, pin 2 below it, pin 3 bottom right, pin 4 top right.
The LED is on pins 1 and 2, the transistor on 3 and 4. Nothing inside joins the two sides.
Source: Sharp PC817XxNSZ1B Series, sheet OP18002EN, p. 2 (internal connection diagram: 1 anode, 2 cathode, 3 emitter, 4 collector); Sharp PC817XxNSZ1B Series, sheet OP18002EN, p. 2 (through-hole and SMT gullwing outlines with the anode mark, rank mark and date code)
Which one do you have?
The top carries PC817, a rank letter, a factory mark and a three-digit date code, with a dot over pin 1. The rank letter is the part you need: A, B, C or D, or nothing for an unsorted part. Sharp sells the through-hole DIP-4 and an SMT gullwing version with the same pins.
Sharp's current sheet covers the PC817X series and rates it 80 V collector to emitter. Older PC817 documents and the many 817-numbered parts from other makers do not all carry the same ratings, and we could not read their sheets on the makers' own sites for this page. If your part is unbranded or old stock, do not assume 80 V; find the sheet for the exact maker, or keep the output side well under the lowest rating you can confirm.
Absolute maximum ratings
On the LED side: 50 mA forward current and only 6 V in reverse. On the transistor side: 80 V and 50 mA, with 150 mW of dissipation and 200 mW for the whole package. Sharp derates the LED current above 55 °C and the collector power above 25 °C (its Fig. 1 and Fig. 3).
| Parameter | PC817DIP-4 |
|---|---|
| LED forward current IF | 50 mA |
| LED peak forward current IFMpulse ≤ 100 µs, duty 0.001 | 1 A |
| LED reverse voltage VR | 6 V |
| LED power dissipation P | 70 mW |
| Collector-emitter voltage VCEO | 80 V |
| Emitter-collector voltage VECO | 6 V |
| Collector current IC | 50 mA |
| Collector power dissipation PC | 150 mW |
| Total power dissipation Ptot | 200 mW |
| Isolation voltage Viso(rms)AC for 1 minute, 40 to 60 % RH | 5 kV |
| Operating temperature Topr | −30 to +100 °C |
| Soldering temperature Tsolfor 10 s | 270 °C |
The 5 kV is an isolation test: 5 kV rms between the two sides for one minute, in 40 to 60 % humidity. It is not a working voltage, and the sheet gives no continuous one. What sets the safe working voltage on a real board is the gap and creepage between the traces under the part, and mains work belongs in a design that a qualified person has checked.
CTR ranks and the other characteristics
| Parameter | PC817DIP-4 |
|---|---|
| LED forward voltage VFIF = 20 mA | 1.2 V typ, 1.4 V max |
| LED reverse current, max IRVR = 4 V | 10 µA |
| Dark current, max ICEOVCE = 50 V, IF = 0 | 100 nA |
| Collector-emitter breakdown, min BVCEOIC = 0.1 mA, IF = 0 | 80 V |
| Collector current (no rank letter) ICIF = 5 mA, VCE = 5 V | 2.5 to 30 mA (CTR 50 to 600 %) |
| Saturation voltage VCE(sat)IF = 20 mA, IC = 1 mA | 0.1 V typ, 0.2 V max |
| Isolation resistance RISODC 500 V, 40 to 60 % RH | 5 × 10¹⁰ Ω min |
| Floating capacitance CfV = 0, f = 1 MHz | 0.6 pF typ, 1.0 pF max |
| Cut-off frequency, typical fCVCE = 5 V, IC = 2 mA, RL = 100 Ω, −3 dB | 80 kHz |
| Rise / fall time tr / tfVCE = 2 V, IC = 2 mA, RL = 100 Ω | 4 / 3 µs typ, 18 µs max |
CTR, the current transfer ratio, is collector current divided by LED current. Sharp grades every part at 5 mA of LED current and 5 V across the transistor. An unsorted part gives anywhere from 2.5 to 30 mA there, a CTR of 50 to 600 %. The four ranks narrow it, as Figure 1 shows. The first page of the sheet sums the range up as 50 to 400 %, but its own rank table runs to 30 mA, or 600 %; design to the table.
Two things move CTR after you buy the part. It falls as the package warms: Sharp's Fig. 9 shows about 82 % of the room-temperature value at 60 °C, at 5 mA. And the LED ages: Sharp's design notes tell you to allow for 50 % degradation over five years. The sheet also warns that CTR varies more below 1 mA of LED current, so keep the LED at a few milliamps.
What it is good for
- Passing a logic signal between circuits with separate grounds: a 24 V PLC input into a 5 V microcontroller, or a microcontroller pin into a separately powered driver board.
- Breaking a ground loop between two boards, or keeping a noisy motor supply's ground away from a sensor's.
- Slow signals: switches, alarms, enable lines and serial links up to a few thousand bits per second. It is too slow for fast serial or PWM above a few kHz.
For switching mains loads, a triac-output optocoupler or a solid-state relay is the part; see the solid-state relay.
Worked example: from a microcontroller pin to an isolated 5 V input
A microcontroller pin lights the LED, and the transistor pulls an input on another board low. The output side has its own 5 V supply and its own ground. We design for the worst part we could be sent: unranked, five years old, in a warm box.
1. LED current. Aim for 5 mA, the current every rank is graded at. Take the forward voltage between 1 V (Sharp's Fig. 6, a hot part at a few mA) and 1.4 V (the table maximum, given at 20 mA).
2. LED resistor from a 5 V pin. R ≤ (5 − 1.4) V / 5 mA = 720 Ω. The next E12 value down is 680 Ω, giving 5.29 mA to 5.88 mA. From a 3.3 V pin: R ≤ 380 Ω, so 330 Ω, giving 5.76 mA to 6.97 mA. Both are far under the 50 mA rating and within what an Arduino or ESP32 pin can supply.
3. Collector current you can count on. Lowest LED current × minimum CTR × ageing × heat: 5.29 mA × 50 % × 0.5 × 0.82 = 1.09 mA.
4. Smallest pull-up. To pull the output down to VCE(sat) (0.2 V), the pull-up must ask for no more than that: R ≥ (5 − 0.2) V / 1.09 mA = 4.42 kΩ. The next E12 value up is 4.7 kΩ, with almost no margin left. We use 10 kΩ: it asks for 0.48 mA, and the part can sink 2.3 times that. For a 3.3 V output side the floor drops to 2.86 kΩ.
5. What a small pull-up does. With 1 kΩ the same worn, warm, unranked part can only sink 1.09 mA, so the output falls to about 3.9 V and stays a logic high. It may work on the bench with a fresh part and fail in the field.
6. The price of a large pull-up. Sharp's Fig. 13 gives typical switching times against load resistance: about 9 µs at 1 kΩ and about 26 µs at 10 kΩ, for each edge. With 10 kΩ the output can follow a 9600 baud serial line (104 µs per bit) but not 115200 baud (8.7 µs per bit).
Worked example in numbers
- LED resistor, 5 V pin
- 680 Ω
- LED resistor, 3.3 V pin
- 330 Ω
- Current to count on
- 1.09 mA
- Smallest pull-up
- 4.42 kΩ
Tips and checks
- Buy a ranked part (PC817C or PC817B) when you can. Their guaranteed minimum is 2.6 or 4 times the unranked one, which allows a smaller, faster pull-up.
- Keep the two grounds apart. A single wire between them, often through a USB cable or a shared supply, undoes the isolation without anyone noticing.
- The LED takes only 6 V in reverse. If the input can swing negative, put a small diode across it, cathode to pin 1.
- If an output is slow or never quite reaches 0 V, measure the LED current first, then halve the pull-up only if the rank allows it.
- Leave room on the board between the input and output traces. The isolation depends on that gap as well as on the package.
Substitutes
Within Sharp's range, any ranked part replaces an unranked one, and the SMT version replaces the DIP. We could not read another maker's 817 sheet on its own site for this page, so other numbers are not listed; compare their pinout, VCEO and CTR table against the Sharp figures before you swap.
| Part | Pins | Verdict |
|---|---|---|
| PC817 with a rank letter (A, B, C or D) | A-K-E-C (pins 1 to 4) | Same part, sorted. Every rank has a higher guaranteed minimum than the unranked 50 %, so a ranked part always works where an unranked one did.Sharp PC817XxNSZ1B Series, sheet OP18002EN, p. 5 |
| PC817 SMT gullwing (PC817XNNIP1B) | A-K-E-C (pins 1 to 4) | The surface-mount lead form: same pins, same ranks and ratings, on 2,000-piece reels.Sharp PC817XxNSZ1B Series, sheet OP18002EN, p. 2; Sharp PC817XxNSZ1B Series, sheet OP18002EN, p. 5 |
Checking one on the bench
- Meter on diode test, red on pin 1, black on pin 2: the LED reads about 1 V. Reversed, open.
- Pins 3 and 4 should read open both ways with the LED dark.
- Wire up the example: 680 Ω from 5 V into pin 1, pin 2 to ground, and 10 kΩ from a second 5 V supply to pin 4 with pin 3 on that supply's ground. Pin 4 should sit near 5 V, and drop under 0.2 V when the LED is lit.
- Check the isolation last: with nothing connected, the meter on its highest resistance range should read open between any input pin and any output pin.
The phototransistor and optocoupler lesson covers what happens inside, and continuity and diode test explains the meter.
What we'd do
Drive the LED at about 5 mA (680 Ω from 5 V, 330 Ω from 3.3 V), buy rank B or C, and size the pull-up from the minimum CTR halved for ageing. For an unranked part on a 5 V output, that means 10 kΩ and signals slower than a few kHz. If you need more speed, use a higher rank and a smaller pull-up, or a logic-output optocoupler.
Questions people ask
What is the PC817 pinout?
Pin 1 anode, pin 2 cathode, pin 3 emitter, pin 4 collector. Pin 1 has the dot; the LED is on pins 1 and 2, the transistor on 3 and 4.
What do A, B, C and D mean on a PC817?
The CTR rank at 5 mA of LED current: A is 80 to 160 %, B 130 to 260 %, C 200 to 400 % and D 300 to 600 %. No letter means anything from 50 to 600 %.
What resistor do I need for a PC817 on Arduino?
680 Ω from a 5 V pin gives about 5 to 6 mA of LED current. From a 3.3 V pin use 330 Ω.
What pull-up should I use on the output?
For an unranked part on 5 V, at least 4.42 kΩ by our derating; 10 kΩ gives margin. A ranked part lets you go lower, which also makes it faster.
How fast is a PC817?
Slow. Sharp gives 18 µs maximum for each edge at a 100 Ω load, and a cut-off of about 80 kHz typical. With a 10 kΩ pull-up expect about 26 µs per edge, fine for switches and 9600 baud, too slow for 115200.
Buying the PC817 in India
PC817s are sold loose and on small breakout boards by most Indian electronics shops. Ask for the rank letter and the maker; a bag of unmarked or unranked 817s needs the unranked design above. Our guide to buying electronic components in India compares ten online sellers and covers how to spot fakes.
One email a month from the bench
New circuits, lessons, part guides and calculators, on the first Sunday of each month.
Used in these lessons
Lessons that go deeper
Datasheets this page was checked against
- Sharp, PC817XxNSZ1B Series, sheet OP18002EN (DATE Jan.15.2018)
Makers revise datasheets. If the copy you download has a newer revision and a number here disagrees with it, the datasheet wins, and we would like to hear about it.