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.

8 thoughts on “optocoupler interfacing with avr pic and 8051 microcontroller”

  1. Is the 2nd and 3rd pin of the optocoupler connected to the same ground.? If they are connected to same ground, then how is this circuit isolated. You will have to use two different power supplies to provide proper isolation.

    Reply
  2. Salam,
    Sir can i know. Does optocoupler have any relation in comunicate gsm and pic?? . There some article saying that optocoupler must be put between tx gsm to rx pic

    Reply
    • I dont think so. Couplers are used to provide isolation in the circuit. There is no role of coupler while interfacing with GSM. But it also depend on your application. If you are talking about simple GSM interfacing with pic, then there is no requirement

      Reply
  3. Hi. I dont get something in avr – optoisolator scehem. + goes through from R2 and goes to base of transistor so base open the gate for C and E. So whts the act of optoisolator . I didnt get. Sorry

    Reply

Leave a Comment