Interfacing Relay to MCU

RELAY: A relay is a electromagnetic mechanical ON/OFF switch type. It is used to low power (Voltage or Current) circuit to switch high power drive. It is an electric switch that operates like open and close switch.
This type of relay is not able to connect directly to MCU. Because the MCU can sink is only 15mA while relay needs 100mA
So we need Transistor to interface relay with micro-controller.
Here below given circuits works like a transistor as a electronic switch. When we need more number of relay we can use ULN2003 high voltage and high current darlington transistor array.
each darlinton pari can be operated directly with TTL output or CMOS devices. It operating voltage is maximum 50V and output drive current is 500mA.
uln2003 app
Simple Transistor Drive circuit:
Complete micro controller with ULN2003 8 relay drive circuit given below.
relay to mcu

Simple S program for the above circuit.
#include
sfr out=0xA0;
sfr Switch=0x90;
unsigned int x;
int main ()
{
while(1)
{
if(Switch==0xFE)
{

out=0x01; // lamp switch
for( x=0;x<2000;x++);
}
else if(Switch==0xFD)
{

out=0x02; // motor switch
for( x=0;x<2000;x++);
}
else
out=0x00;
}
}
APPLICATION OF THE ULN2003.
1. It is used for relay drive.
2. Stepper motor application.

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 508

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×