• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microcontroller Tips

Microcontroller engineering resources, new microcontroller products and electronics engineering news

  • Products
    • 8-bit
    • 16-bit
    • 32-bit
    • 64-bit
  • Applications
    • 5G
    • Automotive
    • Connectivity
    • Consumer Electronics
    • EV Engineering
    • Industrial
    • IoT
    • Medical
    • Security
    • Telecommunications
    • Wearables
    • Wireless
  • Learn
    • eBooks / Tech Tips
    • EE Training Days
    • FAQs
    • Learning Center
    • Tech Toolboxes
    • Webinars/Digital Events
  • Resources
    • Design Guide Library
    • DesignFast
    • LEAP Awards
    • Podcasts
    • White Papers
  • Videos
    • EE Videos & Interviews
    • Teardown Videos
  • EE Forums
    • EDABoard.com
    • Electro-Tech-Online.com
  • Engineering Training Days
  • Advertise
  • Subscribe

Protecting an MCU: Build your own optocoupler

January 21, 2019 By Scott Thornton Leave a Comment

Microcontrollers are widely used for controlling transistors and relays. Transistors and relays are used for actuating or (energizing) equipment with a higher voltage than an MCU can handle. For example, fans, lights, television, door locks, furnaces, and appliances can be automated using an MCU. However, most operate at higher voltages than the voltage tolerances designated in an MCU’s Input/Output (I/O) specification. Several board manufacturers use microcontrollers that usually operate in the range of 3 V DC to -5 V DC. When high voltage equipment is controlled by (and electrically connected to) an MCU, the high voltage equipment produces back EMF headed towards the MCU’s circuit and adds noise to the signals. These noisy signals can cause circuits to malfunction or cause permanent damage.

Another major challenge is protecting sensitive circuits from the risk of receiving electrical surges. High voltage equipment, powered by a high voltage source, can initiate an electrical surge. If a sensitive circuit is exposed to an electrical surge, the components can burn up immediately. This means an electrical surge can “let out the magic smoke in engineering slang.”

To reject back EMF, noise, and electrical surges from entering an MCU circuit, optocouplers are often used. Optocouplers create a safe connection between high voltage equipment and microcontrollers with complete electrical insulation. Suppose the high voltage circuit induces an electrical surge. In that case, the surge remains only on the output side of the optocoupler, and the circuit at the input side remains safe and unaffected, as both sides are electrically isolated. Optocouplers are also called photodiodes, optoisolators, photocouplers, photo relays, and optical isolators.

Internal view of a phototransistor-based optocoupler

Phototransistor-based optocouplers contain Infrared Emitting Diodes (IRED) on the input side and a phototransistor on the output side. Both sides are optically connected, and there is no electrical connection between the input and output sides. The IRED turns on when a voltage signal is passed on the input side. The light that the IRED emits then falls on the receiving phototransistor, resulting in current flow through the phototransistor’s collector and emitter.

Figure 1: Internal connection diagram of a phototransistor-based optocoupler consisting of an IRED at left and a phototransistor on the right. (Source: sharp-world.com)

How to make optocouplers at home

Although many optocouplers are relatively cheap and readily available online, they can be developed at home using an LED, a light-dependent resistor, and an opaque tube, perhaps made with duct tape.

Figure 2: Basic components for making an optocoupler at home. (Source: Author)

The phototransistor and LED are inserted inside the tube, facing each other. Tightly enclose the tube so that an external light source cannot affect the phototransistor. It is recommended to use an internally reflective tube, however, as a non-reflective tube might absorb LED light, affecting the efficiency of the optocoupler. This simple design can be used in hobby projects, functioning quite well as a standard optocoupler.

 

References
http://www.cel.com/pdf/appnotes/an3020.pdf
https://www.autodesk.com/products/eagle/blog/how-an-optocoupler-works/

 

Filed Under: FAQ, Featured, microcontroller Tagged With: basics, FAQ

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured Contributions

Five challenges for developing next-generation ADAS and autonomous vehicles

Securing IoT devices against quantum computing risks

RISC-V implementation strategies for certification of safety-critical systems

What’s new with Matter: how Matter 1.4 is reshaping interoperability and energy management

Edge AI: Revolutionizing real-time data processing and automation

More Featured Contributions

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center

EE ENGINEERING TRAINING DAYS

engineering
“bills
“microcontroller
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

RSS Current EDABoard.com discussions

  • Elektronik devre
  • Powering a USB hub: safely distributing current from a shared power supply
  • RF-DC rectifier impedance matching
  • How can I get the frequency please help!
  • 12VAC to 12VDC 5A on 250ft 12AWG

RSS Current Electro-Tech-Online.com Discussions

  • 100uF bypass Caps?
  • Fuel Auto Shutoff
  • Actin group needed for effective PCB software tutorials
  • how to work on pcbs that are thick
  • compatible eth ports for laptop

DesignFast

Design Fast Logo
Component Selection Made Simple.

Try it Today
design fast globle

Footer

Microcontroller Tips

EE World Online Network

  • 5G Technology World
  • EE World Online
  • Engineers Garage
  • Analog IC Tips
  • Battery Power Tips
  • Connector Tips
  • DesignFast
  • EDA Board Forums
  • Electro Tech Online Forums
  • EV Engineering
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips

Microcontroller Tips

  • Subscribe to our newsletter
  • Advertise with us
  • Contact us
  • About us

Copyright © 2025 · WTWH Media LLC and its licensors. All rights reserved.
The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media.

Privacy Policy