How to control relay with microcontroller?

How to control relay with microcontroller?

A relay can be easily interfaced with microcontroller using a transistor as shown below. 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.

How does the microcontroller energize de energize the relay?

A microcontroller can activate the relay through any of its output pins, with a circuit as shown in the diagram below. The relay coil is energized by means of a transistor which acts as a current amplifier and has its base connected to the output of the microcontroller, in this case, RA0.

Can a microcontroller be connected to a relay?

A relay should not be connected directly to a microcontroller due to following reasons.. A microcontroller is not able to supply current required for the working of a relay. The maximum current that a PIC Microcontroller can source or sink is 25mA while a relay needs about 50 – 100mA current.

What kind of current does a PIC microcontroller need?

The maximum current that a PIC Microcontroller can source or sink is 25mA while a relay needs about 50 – 100mA current. A relay is activated by energizing its coil. Microcontroller may stop working by the negative voltages produced in the relay due to its back emf.

What is the maximum output current of a microcontroller?

Microcontrollers have internal pull up resistors hence when a port pin is HIGH the output current flows through this internal pull up resistor. 8051 microcontrollers have an internal pull up of 10KΩ. Hence the maximum output current will be 5v/10k = 0.5ma. This current is not sufficient to drive the transistor into saturation and turn ON the relay.

What kind of transistors are used in microcontrollers?

If you want to use more relays, using transistors will be difficult. In these cases you may use ULN2003 or ULN2803. These are monolithic IC s consists of High Voltage High Current Darlington transistor arrays. You can connect seven relays using ULN2003 and eight relays using ULN2803.