Professional Documents
Culture Documents
relay , buzzer
and motors.
Contents
Relay working , application.
Programming of relay.
Programming of buzzer.
About motors.
Programming of motors.
Relays
An Electromechanical device
+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
# 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>
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();
}