Interfacing Relays

Relays allow us to control the high power circuits or instruments using low power circuits and voltage levels such as output of microcontrollers. Interfacing relays to 8051 or any other microcontroller is just simple as controlling a LED.

A relay consists of a coil which is driven by low power circuits such as microcontrollers in order to control high power ac circuits through output switches. Normally there are two types of switches in a relay, they are Normally Open (NO) and Normally Closed (NC) contacts. ‘NO’ contacts are open when relay is not activated where as the ‘NC’ contacts are closed, when relay is activated by supplying power to the input coil, the ‘NO’ contacts are now closed and the ‘NC’ contacts are open.

The circuit diagram for interfacing relay to a 8051 microcontroller is shown below.

The assembly program for interfacing relay is given below.

;Program: Interfacing relay
;Author: Srikanth
;Description: Relay turns ON when the switch
;connected to P1.0 and turns OFF when pressed

relay equ P0.0
sw equ P1.0

org 0000h

Main:clr relay        ;Configure inp and outp
setb sw
up:  jnb sw,on        ;wait for switch to be pressed
clr relay
acall delay
sjmp up
on:  setb relay       ;Turn ON relay
acall delay
acall delay
here:jb sw,here       ;wait for switch to be released
clr relay        Turn OFF relay
acall delay
acall delay
sjmp up          ;Loop

delay:mov r7,#0ffh    ;delay subroutine
again:mov r6,#0ffh
djnz r6,$
djnz r7,again



April 11, 2010 - Posted by | Microcontroller Interfacing |

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: