optocoupler interfacing with avr pic and 8051 microcontroller



In this article you will learn how to interface optocoupler with microcontroller? How to interface optocoupler with avr, pic and 8051 microcontroller? What is optocoupler? Basic of optocoupler? It have many application in power electronics project like firing angle control circuits and ac power control circuitsoptocouplers also have many applications in communication based projects. similarly they also have application in microcontroller based projects.  They are interfaced with microcontrollers like a led interacing with microcontroller. I will explain it in later part of this article.



What is optocoupler

optocoupler is also called optoisolator, photocoupler and optical isolator. It is used to provide isolation between two electrical circuits. It is a electrical component which is used to transmit input signal by using light energy signals.  It provides electrical coupling between input and output through light waves.  Its main purpose is to avoid changing in voltages at output side to appearing at input side. Higher voltage fluctuations may damage input side electrical components.

optocoupler working

optocoupler consists of a LED which converts input electrical signal into light energy signal. Photo transistor at the output side detects light signal and turned on when LED light falls on it. In this way its output becomes low and high according to input signal and LED lights as shown in figure below:



optocoupler

optocoupler

types of optocouplers

Many types of optocouplers are available in market according to their rating and design like fast optical isolator, analog optoisolator and linear.Rating depends on output voltage drive capacity of optoisolator.  The mostly used optoisolator for maximum output voltage are 30 volt, 70 volt and 80 volt. You can purchase from market according to your requirement.  They can easily operate between temperature range of 70°C to 150°C.  Name of mostly used optocouplers are given below:

  • 4N25, 4N26
  • PC817 and many others

So there are many types of optocouplers available. It is impossible for me to show you how interface all the these optical isolators with microcontrollers. I will choose one and show you how to interface it with microcontroller. Procedure for all others will remain same. Like if you know how to interface lcd with avr microcontroller, you can also easily interface it with pic, 8051 and arm controller .

Applications of optoisolator

In some applications we use it to separate to electronics circuits. For example dc motor produce back emf with sudden change in input voltages. They are used to remove such effect. They are also widely used in communication devices likes modems etc.

In this article, i will show how to use PC817 optocoupler. because it is most popular among engineering students and easily available in market.

PC817 optocoupler

It consists of an LED and photo transistor. It comes in 4 pin DIP package. It can provide input/output voltage isolation uputo 5KV. Input current is 5mA and collector to emitter voltage can be 80 volt. It can be used for input output isolation of controllers. PC817 interfacing circuits diagram are shown below.

PC817 optocoupler  interfacing with pic

Interfacing circuit diagram is shown below. All the connections are self explanatory. But if you still feel any issue le me know with your comments. 24 volt dc motor is used as a load. PC817 is used to provide isolation between 5 volt and 24 volt circuit. Pin number 5 of port is used as output pin as a control signal.

PC817 optocoupler  interfacing with pic microcontroller

PC817 optocoupler interfacing with pic

PC817 optocoupler  interfacing with avr

PC817 optocoupler  interfacing with avr microcontroller

PC817 optocoupler interfacing with avr microcontroller

PC817 optocoupler  interfacing with 8051

PC817 optocoupler  interfacing with 8051 microcontroller

PC817 optocoupler interfacing with 8051 microcontroller

If you feel any issue after reading this article, you are welcome to comment on this post.



6 Comments

  1. erika August 9, 2015
  2. Abhinav June 16, 2016
  3. Ibnu August 2, 2016
    • Abhinav August 13, 2016
  4. Abdelkader October 8, 2017
  5. Stan October 21, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,391 other subscribers