EEE34 Microcontroller Applications Department of Electrical Engineering Lecture Motor Control Week 3
EEE34 Microcontroller Applications In this Lecture. Interface 85 with the following output Devices Optoisolator Stepper motor DC motor 2
Optoisolator EEE34 Microcontroller Applications An optoisolator, also called optocoupler, is to isolate two parts of a system. An optoisolator has an LED transmitter and a photo-transistor receiver, separated from each other by a gap. When current flows through the LED, it will light up and the light transmits across the gap. When the photo-transistor receives the light, it will turn on linking up the two output leads similar to a mechanical switch. The action of the photo-transistor will produce the same signal with the same phase as from the LED but with a different current and amplitude. The gap between the transmitter and receiver of optoisolators prevents the electrical current surge produced at the receiving reaching the transmitting end. 3
EEE34 Microcontroller Applications Interfacing an Optoisolator The optoisolator comes in a small IC package with four or more pins. There are also packages that contain more than one optoisolator. When placing an optoisolator between two circuits, two separate voltage source are used, one for each side. Unlike relays, no drivers need to be placed between the microcontroller output and the optoisolators. Figure. IC package of Optoisolator Figure.2 Controlling a Lamp via Optoisolator 4
EEE34 Microcontroller Applications Stepper Motor (/2) Stepper motor: a device that translates electrical pulses into mechanical movement Usually used in robotics Permanent magnet (PM) rotor surrounded by a stator Stepper shaft (rotor) moves in a fixed repeatable increment rather than running freely as in conventional motors Figure.3 Stepper shaft alignment 5
EEE34 Microcontroller Applications Stepper Motor (2/2) We shall consider a 4-phase stepper motor 6 leads: 4 stator winding leads and 2 center-tapped commons A N common A A common B S common N o S S N B B B common A Figure.4 A 4-phase stepper motor 6
EEE34 Microcontroller Applications Stepper Motor Position Control (/5) Current through the coils determine the polarity of the stator poles Applying a specific sequence of voltage to each winding will enable the rotor to rotate in a specific manner P.7 P.6 P.5 P.4 P.3 P.2 P. P. A B A A B +V 85 A B common Stepper Motor B Figure.5 7
Stepper Motor Position Control (2/5) EEE34 Microcontroller Applications There are several widely used sequences where each has a different degree of precision. Normal 4-step sequence 8-step sequence (half-stepping) Step angle the step angle is the minimum degree of rotation associated with a single step. The smaller of step angle, higher degree of precision in position control. Motor Step Angle ( ).72.8 2. 2.5 5. 7.5 Steps per Revolution 5 2 8 44 72 48 8
EEE34 Microcontroller Applications Stepper Motor Position Control (3/5) Normal 4-Step 4 Sequence Clockwise Step # 2 3 4 Winding A Winding B Winding A Winding B Counter-clockwise ORG H MOV A, #B ; load step sequence BACK: MOV P, A ; issue sequence to motor RR A ; rotate right clock ACALL DELAY ; wait SJMP BACK ; repeat the rotation sequence ; DELAY:.. ; time delay subroutine RET END 9
EEE34 Microcontroller Applications Stepper Motor Position Control (4/5) 8-Step Sequence (Half Step) Step # Winding A Winding B Winding A Winding B 2 Clockwise 3 4 5 6 7 Counter-clockwise 8
EEE34 Microcontroller Applications Stepper Motor Position Control (5/5) Program of 8-Step 8 Sequence (Half Step) ORG H MOV R, #B ; load normal step sequence MOV R, #B ; load half step sequence BACK: MOV A, R ; load normal sequence value MOV P, A ; issue sequence to motor RR A ; rotate right - clockwise MOV R, A ; store normal sequence value ACALL DELAY ; wait MOV A, R ; load half step sequence value MOV P, A ; issue sequence to motor RR A ; rotate right - clockwise MOV R, A ; store half step sequence value ACALL DELAY ; wait SJMP BACK ; repeat the rotation sequence ; DELAY:.. ; time delay subroutine RET END
EEE34 Microcontroller Applications Further example on Stepper Motor Position Control Controlling stepper motor via optoisolator Figure.6 85 connection to Stepper motor Example. If a switch is connected to port P2.7. Write a program to monitor the status of SW and perform the following: (a) If SW=, the stepper motor moves clockwise. (b) If SW=, the stepper motor moves counter-clockwise. 2
EEE34 Microcontroller Applications Further example on Stepper Motor Position Control Example. Program listing ORG H MAIN: SETB P2.7 ; make P2.7 as an input MOV A, #99H ; starting phase value MOV P, A ; send value to port TURN: JNB P2.7, CW ; check switch RR A ; rotate right - clockwise ACALL DELAY ; wait MOV P, A ; send value to port SJMP TURN ; repeat CW: RL A ; rotate left counter-clockwise ACALL DELAY ; wait MOV P, A ; send value to port SJMP TURN ; repeat ; DELAY: MOV R2, # ; time delay subroutine H: MOV R3, #255 H2: DJNZ R3, H2 DJNZ R2, H RET END 3
EEE34 Microcontroller Applications DC Motors DC motor: has only a pair of + and leads. Connecting to a DC voltage source, DC motors move in one direction. By reversing the voltage polarity, they will move in the opposite direction. Figure.7 DC motor rotation 4
DC Motors - Bidirectional control (/2) EEE34 Microcontroller Applications With the help of relays or some specially designed chips, the rotational directions (forward and backward) of DC motors can be control. The basic concept is the H-Bridge control of DC motors Figure.8 H-Bridge Motor Configuration Figure.9 H-Bridge Motor Clockwise Configuration 5
EEE34 Microcontroller Applications DC Motors - Bidirectional control (2/2) Figure. H-Bridge Motor Counter-Clockwise Configuration Figure. H-Bridge in an Invalid Configuration H-Bridge control can be created using relays, transistors, or a single IC solution. When using relays and transistors, make sure that invalid configuration do not occur. 6
Solution: ORG H MAIN: CLR P. ; H-Bridge switch CLR P. ; H-Bridge switch 2 CLR P.2 ; H-Bridge switch 3 CLR P.3 ; H-bridge switch 4 SETB P2.7 MONITOR: JNB P2.7, CW ; check switch SETB P. ; H-Bridge switch CLR P. ; H-Bridge switch 2 CLR P.2 ; H-Bridge switch 3 SETB P.3 ; H-Bridge switch 4 SJMP MONITOR CW: CLR P. ; H-Bridge switch SETB P. ; H-Bridge switch 2 SETB P.2 ; H-Bridge switch 3 CLR P.3 ; H-Bridge switch 4 SJMP MONITOR END EEE34 Microcontroller Applications Example.2 : If a switch is connected to port P2.7. Write a program to monitor the status of SW and perform the H-Bridge direction control of DC motor as follow: (a) If SW=, the DC motor moves clockwise. (b) If SW=, the DC motor moves counter-clockwise. 7
EEE34 Microcontroller Applications DC Motors - Speed control by PWM (/2) The speed of DC motor depends on three factors; (a) load, (b) voltage and (c) current For a fixed load, speed of DC motor can be changed by pulse width modulation (PWM) PWM is to change the width of the pulse applied to DC motor which lead to an increase or decrease the amount of power supplied to the motor. As a result, the motor speed increases or decreases respective to the power supplied. Although the amplitude of the pulse is fixed at a voltage level, but its duty is varied. The wider the pulse, the higher speed of motor. Motor Speed Figure.2 Pulse Width Modulation Comparison 8
EEE34 Microcontroller Applications Example.3 : Refer to figure.9, write a program to monitor the status of SW and perform the following: (a) If P2.7 =, the DC motor moves with 25% duty cycle pulse. (b) If P2.7 =, the DC motor moves with 5% duty cycle pulse. Figure.3 Connection of DC Motor speed Control by PWM 9
EEE34 Microcontroller Applications Read reference The 85 Microcontroller and Embedded Systems - Using Assembly and C, Mazidi Chapter 7 P.49 P.55 2
EEE34 Microcontroller Applications Review Questions. Give two applications for an optoisolator. 2. Give the advantages of an optoisolator over an electromechanical relay. 3. If a stepper motor takes 9 steps to make one complete revolution, what is the step angle for this motor? 4. Calculate the number of steps per revolution for a step angle of 7.5 degrees. 5. Finish the normal four-step sequence counterclockwise if the first step is (binary). 6. What is the effect of a time delay between issuing each step? 7. What is the factors which affect the speed of a DC motor? 8. What is the advantage of stepper motors over DC motors? 9. A DC motor is moving a load. How do we keep the motor speed constant?. What is PWM, and how is it used in DC motor control? 2
EEE34 Microcontroller Applications Department of Electrical Engineering END of Lecture Motor Control Week 3 22