กลับไปหน้ารวมไฟล์
all-about-pc817-optocoupler-08b14f-en.md

An Optocoupler also known as Photocoupler or Optical Isolator is a component that transfers electrical signals between two isolated circuits using light. It physically and electrically separates a low-voltage control circuit (like a microcontroller) from a high-voltage or noisy power circuit (like a motor or AC mains). It is basically a solid-state relay that optically interconnects two electrically isolated circuits.

In this tutorial, I am going to talk about the PC817 Optocoupler which is one of the most common and inexpensive 4-pin optocouplers.

Video: https://youtu.be/Rj9H0beMQq8

Pin Configuration and Functions

undefined

The PC817 optocouplers are key components in modern electronics and are designed for "signal isolation" and "transmission" in a circuits. It consists of two main parts inside a small, black, 4-pin DIP package:

- An Infrared LED on the input side

- And a Phototransistor on the output side

The two components face each other but are physically separated by a transparent, insulating barrier, providing complete electrical isolation between the two sides. The device uses a combination of infrared LED and phototransistor to not only protect sensitive electronic components from "high voltages" and "electrical noise" but also to maintain signal integrity and accuracy in a variety of applications.

Starting from the side with the notch or the dot and going anticlockwise:

Pin 1: Anode of the internal LED (+)

Pin 2: Cathode of the internal LED (-)

Pin 3: Emitter of the phototransistor (-)

Pin 4: Collector of the phototransistor (+)

Dissecting the Optoisolator Chip

The PC817 looks like a standard black 4-pin microchip, but it is actually two separate components living in a dark box.

  1. Side A (The Input): Inside the chip, pins 1 and 2 are just a tiny Infrared (IR) LED.
  2. Side B (The Output): Inside the chip, pins 3 and 4 are a Phototransistor (a switch that turns on only when struck by light).
  3. The Magic Gap: There is no copper wire connecting Side A to Side B. There is a physical gap of plastic. The two circuits are "Galvanically Isolated".

How Optocoupler Works

undefined

To fully understand the optocoupler's working principle, we will explore it from four different perspectives, each highlighting a unique method of circuit isolation. The main aim is to enable one circuit to activate another while maintaining complete electrical isolation between them.

Setup 1

The initial configuration consists of two circuits assembled on a breadboard.

Circuit1 and Circuit2 are electrically isolated, meaning the operation of one has no effect on the other. When powered, the LED on Circuit2 illuminates immediately. In contrast, the LED on Circuit1 is controlled by a switch and only illuminates when activated. Activating the switch in Circuit1 illuminates its LED, while the LED in Circuit2 always remains illuminated, unaffected by the circuit on the left.

Setup 2

undefined

To control the right circuit's LED using the left circuit, we can connect them with a "transistor".

Activating switch on the left side sends a current to the transistor's base, enabling current flow from collector to emitter illuminating the LED on the right side. Deactivating the switch cuts off the base current, and turns off the LED.

However, this setup requires both circuits to operate at the same potential (e.g., both at 5V) with a common ground. And hence, it cannot be used for voltage level shifting or to control a circuit with a higher voltage.

Setup 3

undefined

In the next setup, I'm using an IR LED and an IR Receiver to create my own optoisolator. Circuit1 (on the left) contains the IR transmitter and a switch, and Circuit2 (on the right) holds the IR receiver and an indicator LED that lights up upon IR signal detection. Flipping the switch turns on the IR LED. The IR receiver then detects this signal and responds by illuminating its indicator LED. While it is possible to design the infrared circuit manually, the PC817 optocoupler offers a fully pre-engineered solution with a compact built-in integrated circuit.

Setup 4

undefined

In the final setup, we are going to use the inexpensive PC817 Optoisolator to "optically interconnect" and "electrically isolated" the two circuits.

When we apply a sufficient voltage higher than the forward voltage (1.25v) across Pins 1 & 2 with a current-limiting resistor, the internal IR LED turns on and emits infrared light. This light then passes through the insulating barrier. As you can see, there is no electrical connection between the input and output. The infrared light hits the base of the phototransistor, causing it to turn on and conduct current between its Collector (Pin 4) and Emitter (Pin 3). So, we can control a secondary circuit just by using a beam of light.

The input side mandates a current-limiting resistor for the optocoupler. Without it, the LED would try to draw as much current as the power supply can provide, quickly exceeding its maximum rating and burning out. The closest standard value would be around 330Ω or 470Ω.

A resistor on the output side (the collector side) is not for protection but for operation. It "pulls up" the voltage and converts the phototransistor's variable conductivity into a variable voltage that your microcontroller or next circuit can read.

Unless exposed to light, the phototransistor acts as an insulator, blocking the flow of current. So, when the Phototransistor is OFF, the LED is off and when the Phototransistor is ON the LED is on.

Because of this setup, voltage spikes and noise on one circuit will not destroy or disrupt the other circuit. So, our circuits are protected. The two circuits can therefore use different voltages and currents because of the separation. We can expand the capabilities of this device by adding other components such as a transistor to the output of Circuit2, allowing it to control even higher voltages and currents.

Please Note: The grounds on the input side and output side must be kept separate to maintain the isolation. This is the entire point of using an optocoupler.

Another critical parameter to consider when utilizing an Optocoupler is the rise time (tr) and fall time (tf). The output does not transition instantaneously as the input logic changes states.

One of the PC817's outstanding features is its strong electrical isolation capabilities, with voltage ratings up to "5KV". By creating this barrier, it safeguards expensive microprocessors and logic circuits by making the entire system much safer and more reliable.

Wiring for Safe Input Reading

Imagine you want the Arduino to know when a 24V industrial bell has rung. You cannot connect 24V to an Uno!

  • You wire the 24V line (through an appropriate reducing resistor like 2.2K) into Pin 1 of the PC817.
  • When the 24V bell rings, the invisible IR LED inside the chip lights up.
  • You wire the Arduino 5V and a digital input pin to Side B of the PC817.
  • The light hits the phototransistor, snapping it closed. The Arduino pin reads HIGH!
  • The Arduino successfully read a 24V industrial signal without any electrical path between them!

Technical Specifications

undefined

Now let's have a look at the technical specifications of the optocoupler.

Packaging: PC817 comprises of four pins and is available in SMT and DIP packages.

Forward Voltage (Vf): The forward voltage of the PC817 optocoupler input diode is specified to be 1.25V. This parameter determines the minimum voltage required for the infrared LED to operate properly.

Forward Current (If): Absolute max 50mA, typical use 5-20mA. Forward Current (IF) is the amount of electric current flowing through a semiconductor (like a diode or LED) when it is forward-biased and conducting.

Collector-Emitter Voltage (Vceo): The maximum allowed collector-emitter voltage of the PC817 is 80V. This specification applies to safe operation in high-pressure environments to avoid electrical failure or damage to the optocoupler.

Current Transfer Ratio (CTR): CTR is the ratio of output current to input current (Ic / If). A CTR of 50% is common. If you put 20mA into the LED, you can get up to ~10mA out of the transistor.

Input Current: Typically limited to under 20mA for safe operation

Isolation: input and output are internally protected with 5kV electrical isolation.

Operating Temperature is between -30°C~100°C

Optocoupler's Temperature Range during Soldering: 260 degrees. It is crucial to note that exceeding the specified temperature during soldering can damage the IC.

Switching: The PC817 has a total response time (including rise and fall times) of 18 microseconds. This fast response capability is especially beneficial for applications requiring fast switching, such as pulse signal processing or high-speed switching circuits.

Internal Resistance: PC817 has an internal resistance of 100 ohms and a maximum power consumption of 200mW. These factors manage the energy efficiency and heat load of the equipment.

Reverse Current: PC817 comes with internal protection from reverse current. Due to the one-way current flow nature of IR, the PC817 protects the IR from any reverse current.

For more detailed information, please consult the datasheet available here: https://github.com/tarantula3/PC817-Optocoupler/blob/main/PC817A%20Datasheet.PDF

PC817 Applications

undefined

The PC817 optocoupler is commonly used in the following applications:

Signal isolation and transmission

Electrical isolation circuits, capable of withstanding up to 5kV

Isolation of digital from analog circuits

Level Shifting: It allows a 5V circuit to control a 12V, 24V, etc., circuit

Microcontroller I/O switching circuits, effectively maintaining circuit continuity without disconnection

Noise coupling circuits to keep the circuit in use without any interruption

It helps in breaking ground loops

Switching and zero cross: In AC/DC power control circuits the Optocoupler regulates AC loads by introducing frequency-induced pulses, enabling precise control within a defined range

Driving relays, controlling motors or AC power switches

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "tarantula3"
category: "Basic Electronics"
components:
  - "1x PC817"
description: "The wall of light! Learn how to utilize optoisolators to electrically sever the connection between your fragile Arduino and high-voltage AC mains logic, ensuring absolute hardware safety."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://github.com/tarantula3/PC817-Optocoupler/tree/main?tab=readme-ov-file"
encryptedPayload: "U2FsdGVkX1+ekA+kXtr0hyj9/rUr7GkYS2qUxtziIaPRYgib675poBEQtG5QecAaURd3TL7n0jisRGm26B6P2wSPSoxFFNSQSyLeM/I2sK4="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/all-about-pc817-optocoupler-08b14f_cover.jpg"
lang: "en"
likes: 0
passwordHash: "f503c49b1767ac7907ccc4fa77d3f0d6f085825d33c6914f4b4e5868eb7e0616"
price: 79
seoDescription: "Learn all about the PC817 Optocoupler, a popular and inexpensive 4-pin optocoupler for your electronics and Arduino projects."
tags:
  - "Environmental Sensing"
  - "Home Automation"
  - "Tools"
  - "Embedded"
title: "All About PC817 Optocoupler"
tools: []
videoLinks:
  - "https://www.youtube.com/watch?v=Rj9H0beMQq8"
  - "https://www.youtube.com/watch?v=Rj9H0beMQq8"
views: 14