Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Embedded Systems
CHAPTER 16
Motor Control: Relay,
PWM, DC and Stepper
Motors
1
RELAYS AND OPTOISOLATORS
3
Electromechanical Relay Symbols
4
Criteria for Choosing a Relay
The contacts can be normally open (NO) or normally
closed (NC).
There can one or more contacts. For example, we
can have SPST (single pole,single throw), SPDT
(single pole, double throw), and DPDT (double pole,
double throw) relays
The voltage and current needed to energize the coil
The maximum DC/AC voltage and current that can
be handled by the contacts
5
Driving a relay
6
Driving a relay
7
Solid-state relay
10
Reed switch
12
Optoisolator
14
Interfacing an optoisolator
15
Interfacing an optoisolator
16
Introduction to Stepper Motor
21
Unipolar Stepper motors
Stepper Motor Selection
30
Step Angle
MOV A,#66H
BACK: MOV P1,A
RR A
ACALL DELAY
SJMP BACK
DELAY: MOV R1,#100
UP1: MOV R2,#50
UP: DJNZ R2,UP
DJNZ R1,UP1
RET
Note: motor to rotate in anticlockwise use instruction RL A instead of RR A
Program:
: A switch is connected to pin P2.7. Write an ALP to monitor the status of the
SW. If SW = 0, motor moves clockwise and if SW = 1, motor moves
anticlockwise.
ORG 0000H
SETB P2.7
MOV A, #66H
MOV P1,A
TURN: JNB P2.7, CW
RL A
ACALL DELAY
MOV P1,A
SJMP TURN
CW: RR A
ACALL DELAY
MOV P1,A
SJMP TURN
Program:
Write an ALP to rotate a motor 90 clockwise. Step angle of motor is 2.
Step angle = 2
Steps per revolution = 180
For 90 rotation the no of steps is 45
ORG 0000H
MOV A, #66H
MOV R0, #45
BACK: RR A
MOV P1, A
ACALL DELAY
DJNZ R0, BACK
END
Programming stepper motor in c
#include <reg51.h>
void main ()
{ while (1)
{
P1=0x66;
MSDELAY (200);
P1=0x33;
MSDELAY (200);
P1=0x99;
MSDELAY (200);
P1=0xCC;
MSDELAY (200);
}
}
Programming stepper motor in c
#include <REG51xD2.H>
void delay(unsigned int x) /* Delay Routine */
{ for(;x>0;x--);}
main(){
unsigned char Val,i;
while(1) {
Val = 0x88;
for(i=0;i<4;i++) {
P0 = Val;
Val = Val>>1;
delay(575); }}}
DC MOTOR INTERFACING AND
PWM
42
Bidirectional control
All the
switches
are
open,
which
does not
allow the
motor to
turn.
43
Bidirectional control
When
switches 1
and 4 are
closed,
current is
allowed to
pass
through
the motor.
44
Bidirectional control
45
Bidirectional control
An invalid
configuration
Current
flows directly
to ground,
creating a
short circuit
46
Bidirectional control
H-Bridge control can be created using relays,
transistors, or a single IC solution such as the L293
When using relays and transistors, it must be
ensured that invalid configurations do not occur
47
Pulse width modulation (PWM)
48
Pulse width modulation (PWM)
49
Pulse width modulation (PWM)
50
DC Motor Connection using a
Darlington Transistor
51