Microchip Technology

user Occupation hasn't been added

 Microchip


  • Interfacing Relay with PIC Microcontroller

  • Created: Nov 12, 2014

    • view1880
    • comment1
    • bookmark1
    • fork3

Description

No description available.

Summary

This circuit is an example of interfacing a relay with a microcontroller using a transistor. Technically, a relay is an electromagnetic switch that is commonly used to switch high voltage or current using low power circuits. The device isolates low power circuits from high power circuits by energizing a coil wounded on a soft iron core. It uses PIC16F887 microcontroller, a CMOS FLASH-based 8-bit microcontroller with precision internal oscillator that is reprogrammable under software control. However, it should not be directly connected to a relay since it could not supply the current required to drive the relay. Its maximum current is 25mA while a relay needs about 50 – 100mA current. In addition, since energizing its coil activates a relay, the microcontroller may stop working by the negative voltages produced in the relay due to its back emf.


A relay can be easily interfaced with microcontroller using a transistor. In the circuit provided, the transistor is wired as a switch, which carries the current required for operation of the relay. When the pin RB7 of the PIC microcontroller goes high, the transistor BC547 turns ON and current flows through the relay. The diode D1 is used to protect transistor and the microcontroller from Back EMF generated in the relays coil. Normally, 1N4148 is preferred as it is a fast switching diode having a peak forward current of 450mA. This diode is also known as freewheeling diode.


Some electronic devices needed switching to control high voltages or high currents to optimize maximum performance. With that, a relay may be used which essentially amplifies signal, switching a large amount of power with a small operating power. Relays have various applications such as used in modems, audio amplifiers, a starter solenoid of an automobile or can be a telegraph relay, repeating a weak signal received at the end of a long wire. Furthermore, this can be a protection relay that can be noticed in circuit breakers.

1 Comment


Onurhan

Great, thank you!

Posted: Mar 23, 2015