motor control relay, pwm, dc and stepper motors
DESCRIPTION
In this presentation, a brief introduction of relay, optoisolaters, interfacing and working of stepper motor and DC motor is given. The contents are referred from the book of mazidi.TRANSCRIPT
![Page 1: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/1.jpg)
1
The 8051 Microcontroller and Embedded Systems
CHAPTER 16Motor Control: Relay, PWM, DC and Stepper Motors
![Page 2: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/2.jpg)
2
RELAYS AND OPTOISOLATORS
A relay is an electrically controllable switch widely used in industrial controls, automobiles, and appliances
It allows the isolation of two separate sections of a system with two different voltage sources
For example, a +5V system can be isolated from a 120V system by placing a relay between them
![Page 3: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/3.jpg)
3
One such relay is called an electromechanical (or electromagnetic) relay
The EMRs have three components: the coil, spring, and contacts
When current flows through the coil, a magnetic field is created around the coil (the coil is energized), which causes the armature to be attracted to the coil
RELAYS AND OPTOISOLATORS
![Page 4: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/4.jpg)
4
Electromechanical Relay Symbols
![Page 5: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/5.jpg)
5
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
![Page 6: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/6.jpg)
6
Driving a relay
Digital systems and microcontroller pins lack sufficient current to drive the relay
While the relay’s coil needs around 10 mA to be energized, the microcontroller’s pin can provide a maximum of 1-2 mA current
For this reason, a driver is placed, such as the ULN2803, or a power transistor between the microcontroller and the relay
![Page 7: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/7.jpg)
7
Driving a relay
![Page 8: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/8.jpg)
8
Solid-state relay
In this relay, there is no coil, spring, or mechanical contact switch
The entire relay is made out of semiconductor materials
These relays have switching response time much faster than that of electromechanical relays
The life cycle for the electromechanical relay can vary from a few hundred thousands to few million operations
![Page 9: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/9.jpg)
9
Wear and tear on the contact points can cause the relay to malfunction after a while
Solid-state relays have no such limitations Extremely low input current and small
packaging make solid-state relays ideal for microprocessor and logic control switching
They are widely used in controlling pumps, solenoids, alarms, and other power applications
Solid-state relay
![Page 10: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/10.jpg)
10
Solid-state relay
![Page 11: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/11.jpg)
11
Reed switch
When the reed switch is placed in a magnetic field, the contact is closed
When the magnetic field is removed, the contact is forced open by its spring
The reed switch is ideal for moist and marine environments where it can be submerged in fuel or water
They are also widely used in dirty and dusty atmospheres since they are tightly sealed
![Page 12: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/12.jpg)
12
Reed switch
![Page 13: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/13.jpg)
13
Optoisolator
Optoisolator (also called optocoupler) are used to isolate two parts of a system
An optoisolator has an LED (light-emitting diode) transmitter and a photosensor receiver, separated from each other by a gap
When current flows through the diode, it transmits a signal light across the gap and the receiver produces the same signal with the same phase but a different current and amplitude
![Page 14: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/14.jpg)
14
Optoisolator
![Page 15: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/15.jpg)
15
Interfacing an optoisolator
The optoisolator comes in a small IC package with four or more pins
When placing an optoisolator between two circuits, we must use two separate voltage sources, one for each side
Unlike relays, no drivers need to be placed between the microcontroller/digital output and the optoisolators
![Page 16: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/16.jpg)
16
Interfacing an optoisolator
![Page 17: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/17.jpg)
17
Introduction to Stepper Motor
Stepper motor is a widely used device that translates electrical pulses into mechanical movement
Stepper motor is used in applications such as disk drives dot matrix printer robotics etc.
Stepper motors commonly have a permanent magnet rotor (shaft) surrounded by a stator
![Page 18: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/18.jpg)
Stepper Motor Diagram
![Page 19: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/19.jpg)
Construction of Stepper Motor
![Page 20: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/20.jpg)
Commonly used stepper motors have four stator windings that are paired with a center – tapped common. Such motors are called as four-phase or unipolar stepper motor.
It has a permanent magnet rotor which is surrounded by a stator.
A practical PM stepper motor will have 1.8 degrees step angle and 50 tooth on its rotor.
There are 8 main poles on the stator, each having 5 tooth in the pole face
Construction of Stepper Motor
![Page 21: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/21.jpg)
21
Construction of Stepper Motor
![Page 22: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/22.jpg)
Unipolar Stepper motors
![Page 27: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/27.jpg)
Stepper Motor Selection
Permanent Magnet / Variable Reluctance Unipolar vs. Bipolar Number of Stacks Number of Phases Degrees Per Step Microstepping Pull-In/Pull-Out Torque Detent Torque
![Page 28: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/28.jpg)
Most common stepper motors have 4 stator windings that are paired with a center-tapped common as shown in the fig
This type of stepper motor is commonly referred to as a four phase or unipolar stepper motor
The center tap allows a change of current direction in each of two coils when a winding is grounded, there by resulting in a polarity change of the stator
Stepper Motor Selection
![Page 29: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/29.jpg)
Working of Stepper Motor
The stator is a magnet over which the electric coil is wound
One end of the coil is connected commonly either to ground or +5V
The other end is provided with a fixed sequence such that the motor rotates in a particular direction
Stepper motor shaft moves in a fixed repeatable increment, which allows one to move it to a precise position
![Page 30: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/30.jpg)
30
Working of Stepper Motor
Direction of the rotation is dictated by the stator poles
Stator poles are determined by the current sent through the wire coils
![Page 31: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/31.jpg)
Step Angle
Step angle is defined as the minimum degree of rotation with a single step.
No of steps per revolution = 360° / step angle Steps per second = (rpm x steps per
revolution) / 60 Example: step angle = 2° No of steps per revolution = 180
![Page 32: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/32.jpg)
One Phase on(Wave drive four step sequence)
(Normal four step sequence)
![Page 33: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/33.jpg)
8051 connection to stepper motor
![Page 34: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/34.jpg)
Program:
Write an ALP to rotate the stepper motor clockwise / anticlockwise continuously with full step sequence.
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
![Page 35: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/35.jpg)
: 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:
![Page 36: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/36.jpg)
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
Program:
![Page 37: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/37.jpg)
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); } }
![Page 38: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/38.jpg)
#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); }}}
Programming stepper motor in ‘c’
![Page 39: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/39.jpg)
39
DC MOTOR INTERFACING AND PWM
A direct current (DC) motor is another widely used device that translates electrical pulses into mechanical movement
The DC motor has only + and – leads Connecting them to a DC voltage source
moves the motor in one direction By reversing the polarity, the DC motor will
move in the opposite direction
![Page 40: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/40.jpg)
40
Small fans used in many motherboards to cool the CPU are run by DC motors
While a stepper motor moves in steps of 1 to 15 degrees, the DC motor moves continuously
The DC motor has two rpms: no-load and loaded
The manufacturer’s data sheet gives the no-load rpm
DC MOTOR INTERFACING AND PWM
![Page 41: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/41.jpg)
41
![Page 42: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/42.jpg)
42
The DC motor has rotation for clockwise (CW) and counterclockwise (CCW) rotations
Unidirection Control
![Page 43: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/43.jpg)
43
All the switches are open, which does not allow the motor to turn.
Bidirectional control
![Page 44: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/44.jpg)
44
Bidirectional control
When switches 1 and 4 are closed, current is allowed to pass through the motor.
![Page 45: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/45.jpg)
45
Bidirectional control
![Page 46: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/46.jpg)
46
Bidirectional control
An invalid configuration
Current flows directly to ground, creating a short circuit
![Page 47: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/47.jpg)
47
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
Bidirectional control
![Page 48: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/48.jpg)
48
The speed of the motor depends on three factors: – (a) load– (b) voltage– (c) current
For a given fixed load we can maintain a steady speed by using a method called pulse width modulation (PWM)
Pulse width modulation (PWM)
![Page 49: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/49.jpg)
49
By changing (modulating) the width of the pulse applied to the DC motor we can increase or decrease the amount of power provided to the motor, thereby increasing or decreasing the motor speed
PWM is so widely used in DC motor control that some microcontrollers come with the PWM circuitry embedded in the chip
Pulse width modulation (PWM)
![Page 50: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/50.jpg)
50
Pulse width modulation (PWM)
Although the voltage has a fixed amplitude, it has a variable duty cycle
That means the wider the pulse, the higher the speed
![Page 51: Motor Control Relay, Pwm, DC and Stepper Motors](https://reader033.vdocument.in/reader033/viewer/2022061422/55861dc5d8b42abe278b50da/html5/thumbnails/51.jpg)
51
DC Motor Connection using a Darlington Transistor