You are on page 1of 20

Interfacing with

relay , buzzer
and motors.
Contents
Relay working , application.

Interfacing with 8051.

Programming of relay.

Programming of buzzer.

About motors.

Programming of motors.
Relays
An Electromechanical device

Relay operates on +5v


switches to +12v or 220 v state

Wide variety applications such


as in telephone exchanges,
digital computers and
automation systems
Inside Relay
Relay Operation
When there is no voltage applied on coil, switch is open.
When a voltage is applied on coil , magnetic field is
produced.
It attracts the armature towards the 2nd pin closing the
switch.
Relay application
Bulb is ON , when voltage is applied on relay input(coil).

Bulb is OFF , when no voltage is applied on relay


input(coil).
OPTOCOUPLERS:
Optocoupler are the devices , which tends current to
flow in one direction.
And are used between controller and relay section ,
to prevent controller from high voltage.

One way direction of current


RELAY SECTION

+12V
+12v

IR LED
1

2
5
LED 4148 3 2 3PIN BASE
V c c 2 Q B C 5 4 37 R
4
3

1
1
1 6 4.7K 2
560 E R
MCT2E R ELAY SPD T
2 5
4.7K 2
1

1
3 4 Q BC547
input from P3.3 560E
3

0
//Program to ON and OFF relay //

# include<reg51.h>

Sbit relay1=P1^2;
Sbit relay2=P1^3; while(1)
{
void delay() relay1=1; // Relay1 ON
{ relay2=1; // Relay2 ON
int i; delay();
for(i=0;i<=30000;i++); relay1=0; // Relay1 OFF
} relay2=0; // Relay2 OFF
delay();
void main() }
{ }}
Buzzer Interfacing

A buzzer is an audio signaling


device, which may be
mechanical, electromechanical or
electronic.

Typical uses of buzzers include


alarms, timers and confirmation of
user input such as a mouse click
or keystroke.
While interfacing it uses single bit of controller.

BC547 transistor is used to provide switching of


buzzer.
//Program to ON and OFF buzzer //

# include<reg51.h>

Sbit buzzer=P1^4;
while(1)
void delay() {
{ buzzer=1; // Buzzer ON
int i; delay();
for(i=0;i<=30000;i++); buzzer=0; // Buzzer OFF
} delay();
}
void main() }
{ }
DC Motors
• The most common actuator in mobile
robotics
• simple, cheap, and easy to use.
• come in a great variety of sizes, to
accommodate different robots and tasks.
Principles of Operation
• DC motors convert electrical into mechanical
energy.
• They consist of permanent magnets and loops of
wire inside.
• When current is applied, the wire loops generate
a magnetic field, which reacts against the outside
field of the static magnets.
• The interaction of the fields produces the
movement of the shaft/armature.
• Thus, electromagnetic energy becomes motion.
Pulse Width Modulation
• Pulse width modulation is a technique for
reducing the amount of power delivered to a
DC motor.
• Instead of reducing the voltage operating the
motor (which would reduce its power), the
motor's power supply is rapidly switched on
and off.
• The percentage of time that the power is on
determines the percentage of full operating
power that is accomplished.
PWM

75

50

25
/***Program to run dc motor with 50% duty cycle***/

#include<reg51.h>

Sbit motor = P0^0;

void delay()
{ While(1)
int a; {
for(a=0;a<=1200;a++); motor=1; // motor ON
} delay();
motor=0; // motor OFF
void main() delay();
{ }
}
Stepper motor
A stepper motor is an electromechanical device
which converts electrical pulses into discrete
mechanical movements.
Working
/********Program to run stepper motor in
clockwise**********/

#include<reg51.h>

void delay()
{
P0=0x66;
int a;
delay();
for(a=0;a<=1200;a++);
P0=0xcc;
}
delay();
P0=0x99;
void main()
delay();
{
P0=0x33;
delay();
}

You might also like