Embedded System
Why we use Optocoupler in relay switching?
Kitflix · 2020-06-24

Optocoupler, a tiny IC which is basically an LED triggered transistor can be live saving in many project situation. This is a short story about one such incident in project development and am sure it'll help you if you face such issues in your microcontroller projects
Last week we were working on an Industrial project. It wasn't something that I had designed but had been called upon for troubleshooting the issue which was coming in. The project was simple, it had below mentioned interfaces
Now as you can see, there is fly back diode present, there is the RC Snubber present, additionally such snubber was also connected across the com and NO of relay. But still it didn't helped
whenever the relay was turned On by controller signal, the controller Hang.
Now there are several reasons for such thing to happen, but primarily, the reason is NOISE. And if you can't seem to solve such thing, then its better and much better if at the time of design itself, you incorporate optocoupler.
What is optocoupler? If you ask me, its a life saver 😎😎
Its basically a replacement to transistorized switch but this time, the switching happens just by emitting light using the atmega signal and hence, the noise induced in controller side is at minimum. You can also NOT REQUIRED TO MAKE COMMON GROUND when using optocoupler. Means the 24v ground and +5v ground need not to be made common.
Finally below is the arrangement which solved all issues with the system
as you can see, the optocoupler provides complete electrical isolation between 24v side and +5v side hence this arrangement worked perfectly for the system
The optocoupler used was MCT2E, however you can use any optocoupler you may have like PC817
If there is a base Pin to your optocoupler, simple keep it open or Not connected to anything. Its just there to give a manual trigger instead of the light trigger that comes off from LED and can keep it open while using the LED inside optocoupler.
Whether your project is based on Arduino or Atmega or PIC or STM32 or Raspberry Pi, this tip will help in every situation where ever you need to trigger relays in your system, particularly when what you're switching is a high current device
So keep this thing in mind next time when you're debugging your relay based microcontroller project.
- Ultrasonic Sensor
- Microcontroller(atmega328p)
- LCD
- Relay x 2
- DC Motor x 2
Now as you can see, there is fly back diode present, there is the RC Snubber present, additionally such snubber was also connected across the com and NO of relay. But still it didn't helped
whenever the relay was turned On by controller signal, the controller Hang.
Now there are several reasons for such thing to happen, but primarily, the reason is NOISE. And if you can't seem to solve such thing, then its better and much better if at the time of design itself, you incorporate optocoupler.
What is optocoupler? If you ask me, its a life saver 😎😎
Its basically a replacement to transistorized switch but this time, the switching happens just by emitting light using the atmega signal and hence, the noise induced in controller side is at minimum. You can also NOT REQUIRED TO MAKE COMMON GROUND when using optocoupler. Means the 24v ground and +5v ground need not to be made common.
Finally below is the arrangement which solved all issues with the system
as you can see, the optocoupler provides complete electrical isolation between 24v side and +5v side hence this arrangement worked perfectly for the system
The optocoupler used was MCT2E, however you can use any optocoupler you may have like PC817
If there is a base Pin to your optocoupler, simple keep it open or Not connected to anything. Its just there to give a manual trigger instead of the light trigger that comes off from LED and can keep it open while using the LED inside optocoupler.
Whether your project is based on Arduino or Atmega or PIC or STM32 or Raspberry Pi, this tip will help in every situation where ever you need to trigger relays in your system, particularly when what you're switching is a high current device
So keep this thing in mind next time when you're debugging your relay based microcontroller project.
