You are currently viewing How to Interface Relay with 8051 Advanced Development Board

How to Interface Relay with 8051 Advanced Development Board

Spread the love

8051 Advanced Development Board

The 8051 Advanced Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Advanced Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

Relay

Relays are devices which allow low power circuits to switch a relatively high Current/Voltage ON/OFF. A relay circuit is typically a smaller switch or device which drives (opens/closes) an electric switch that is capable of carrying much larger current amounts.

Interfacing Relays

Fig. 1 shows how to interface the Relay to microcontroller. There are 2 input channels. Each input is connected to the triggering coil of the respective relay. There are 2 output channels that each correspond to an input. When the input is energized, the relay turns on and the ‘+’ output is connected to +12v. When the relay is off, the ‘+’ output is connected to Ground. The ‘-‘ output is permanently wired to Ground.

Interfacing Relay with 8051

In ADB Board two no. Of SPDT relays are used. Both the relays operate on 5V DC. The outputs of both the terminals of the relay are taken out on the connecter to connect the external circuitry. The relay can be connected to the Microcontroller through any of the selected port (P0.4 & P0.5) or (P1.4 & P1.5) or (P2.4 & P2.5) by using the FRC connecter.

Pin Assignment with 8051

Circuit Diagram to Interface Relay with 8051

Source Code

The Interfacing Relay with 8051 program is very simple and straight forward, which control the relays in 8051 Advanced Development Board. The relay is working that uses a delay procedure loop based software delay. The C programs are developed in Keil software.

C Program to control Relay in 8051

#include 

//Define 8051 registers

#include

sbit relay1 = P0^4;

sbit relay2 = P0^5;

void DelayMs(unsigned int);

//Delay function

//----------------------------------

//Main Program

//----------------------------------

void main (void)

{

P2 = 0;

//Initialize Port while(1)

//Loop Forever

{

relay1 = 1;

//Relay1 - ON relay2 = 0;

//Relay2 - Off DelayMs(200);

//Delay 20msec relay1 = 0;

//Relay1 - Off relay2 = 1;

//Relay2 - ON DelayMs(200);

//Delay 20msec

}

}

//---------------------------------

//Delay Function

//---------------------------------

void DelayMs(unsigned int n)

{

unsigned int i,j;

for(j=0;j<n;j++)

{

for(i=0;i<1000;i++);

}

}

Leave a Reply

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