Motor Control Prof. Rohan Munasinghe Department of Electronic and Telecommunication Engineering Faculty of Engineering University of Moratuwa 4 DC Motors Small, cheap, reasonably efficient, easy to use ideal for small robotic applications Efficiency Mechanical friction, cause some electrical energy to be wasted as heat Toy motors 5%, Industrial-grade 9% Motor Selection for the Control Board Rated Voltage and Current A 6V motor isn t happy to be powered by a 9V battery. A 2V motor runs too slowly when powered by a 9V supply. Rated voltage is to be provided. Do not use 3V to 4.5V small DC motors found in many toy cars. These inexpensive motors are extremely noisy and inefficient. Frequent Board resetting will result. Testing a motor for compatibility with the control board Connect ohmmeter to the motor terminals, and gently rotate the motor shaft by hand until you obtain the smallest possible winding resistance R min., and calculate current I max = V rated / R min, If motor drives has a higher capacity > I max motor can be interfaced the Board. Improving current handling capability (example: MIT Handy Board) use SN7544 quadruple half H driver, which is a plug-and-play replacement for the L293D, or stack two L293Ds by soldering corresponding pins. Brushed DC Motor Components Operating Voltage Is the recommended voltage you should use to power the motor Most motors will run fine at lower voltages, though they will be less powerful Can operate at higher voltages at expense of operating life Operating Current When there is no resistance to its motion, the motor draws the least amount of current, and when there is so much resistance to cause the motor to stall, it draws the maximum current Stall current: maximum current a motor can draw at its specified voltage Stall torque: torque at stall current
Basic Inductor Theory Ideal Inductor: Current rises at constant rate di V = L dt Motor (Inductor) Switching OFF -ve high voltage builds up. Stored energy is dissipated by producing an electric arc across the switching terminals Real Inductor: Current saturates as voltage drops more across the resistor When a motor is running, the armature acts as an inductor, and when the current in the armature changes, voltage spikes are generated that might be of higher voltage than the Vs power supply or lower voltage than ground. Suppress Arc Using Diodes Spike Cancellation Circulating current dissipates stored energy slowly. Freewheeling diodes Diodes connecting from each driver output to either Vs, or ground perform the important function of trapping and shunting away inductive voltage spikes that naturally occur as part of any motor s operation. No arc Suppose all drive transistors are OFF suddenly, and as a result a voltage greater than Vs is generated at the motor on the OUT line. Then the diode labeled D conducts, shunting this voltage to the Vs power supply. If the diodes were not present, these inductive voltage spikes would damage sensitive electronic components. One-Half of L293D/SN7544 Motor Driver Chip
MOSFET Drivers H-Bridge Circuit MOSFETs Smaller Bias Current compared to BJT Almost zero bias current under steady state condition (ON or OFF) Low ON Resistance Higher current Fast Switching speed (can be uses to control motor speed via PWM) Rotation of the DC motor can be controlled (CW or CCW) Mostly used 2 different channel MOS-FETs 2 N-Channel MOS-FETs 2 P-Channel MOS-FETs CW Rotattion CCW Rotattion CW CCW Two MOS-FETs are ON and the others are OFF One MOS-FET Drive the positive supply, and the other one is driving the negative supply MOS-FETs are working in the apposite condition fron the CCW rotation The polarity of the motor become the apposite from the CCW thus makes the DC motor turning in the apposite direction (CW) Two MOS-FETs are ON and the others two are OFF One MOS-FET Drive the positive supply, and the other one is driving the negative supply
MOSFET Driven through Optocouplers Bias for CW Rotation Q4=on CW Q2=on Optocouplers are used to separate the controller and motor ground signal The N-Channels are biased to +VSS The P-Channels are biased to -VSS Optocopuplers are supplied from the controller with different ground signal from the motor supply Bias for CCW Rotation Speed Control for CW Q3=on Q4=on Q=on CCW Speed CW Q2 Pulsed PWM
Speed Control for CCW DC Motor Braking Q3=on Q Pulsed Speed CCW Q=on Q2=on PWM We can short motor terminal by pulling all the motor terminal to the low side (-VSS). It make the maximum current flow as the motor rotate Prohibited Condition Prohibited Condition 2 Q4=on Q3=on Q4=on Q=on Short Circuit Q2=on Q=on Short Circuit
Prohibited Condition 3 Decoder Logic Decoder can be used to Protect H-Bridge from the Prohibited Conditions Input A Input B Input C Input D Conditions All Circuits short (Prohibited condition) Short Circuit (Prohibited condition) Q3=on Short Circuit (Prohibited condition) Short Circuit (Prohibited condition) Short Circuit (Prohibited condition) Short Circuit Q2=on Motor Turn Clockwise Brake (Upper Part is closed loop) Circuit Open (Motor Off / Free running) Short Circuit (Prohibited condition) Brake (Lower Part is closed loop) Motor Turn Counter Clockwise Circuit Open (Motor Off / Free running) Short Circuit (Prohibited condition) Circuit Open (Motor Off / Free running) Circuit Open (Motor Off / Free running) All Circuits Open (Motor Off / Free running) Assignment 2 L298 Dual Full Bridge Driver (4A) Design the following combinational logic circuit, which will make sure that prohibited conditions won t be generated. Determine Combinational required. Logic Circuit inputs A B C D Prohibited Conditions won t happen 5-7 V Motor Control Pins Up to 46V, 4A Motor Terminals < 2A Motor Control Pins
L298 Dual Full Bridge Driver (4A) To Drive inductive loads : solenoids, relays, DC / stepper motors External smoothing caps Power Power and Speed of DC Motors Product of the output shaft s rotational velocity and torque Output power is zero when Torque is zero: Motor is spinning freely with no load on the shaft. Rotational velocity is at its highest, but the torque is zero, and it s not driving any mechanism (Actually, the motor is doing some work to overcome internal friction, but that is of no value as output power) Rotational velocity is zero: Motor is stalled, it is producing its maximal torque. But as there is no motion, no work is delivered onto the load In between two extremes, output power shows a parabolic relationship Homework: Draw Truth Table for Out and Out2 as a functions of In and In2 Feedback Control Example: Air conditioner Temperature sensing system (sensor or mechanism) feeds back room temperature, and compares it with the desired temperature. Error is determined. Use the error signal (positive or negative) to adjust the cool airflow to the room. If error is +ve reduce cool air flow If error is ve increase cool air flow There is a delay in air temperature measuring system. Delayed response can cause oscillations in room temperature. Proportional Control of Motors control signal is proportional to the amount of error: Generates a stronger control signal when the present state is farther away from the goal state At t=, suppose that the setpoint = and actual position=. Then e()=, so the motor turns at % power, driving the wheel toward the desired position. As it moves, the error becomes progressively smaller. When it is at position=5, the error is only 5, and the motor is given only 5% power. When it arrives at the intended position of, the error is zero, and the motor turns off momentarily. 27 Proportional Gain (ratio between error and power): Instead of a one-toone ratio between error and motor %power, modify the controller so it multiplies the error value by 5. The wheel should reach the set-point faster, and it should resist being turned away from it much more aggressively. 28
Proportional Control of Motors Overshoot: Response moves beyond set-point, and stops and turns back. Oscillations: After an overshoot, error becomes ve, thus, proportional controller drives the motor in the opposite direction. In the subsequent motion, motor might undershoot as well. This overshoot and undershoot phenomena repeats for a while, and gradually, the oscillation is expected to die out. Controller Design: Design to minimize both overshoot and oscillation, but let little overshoot to improve system response to reach the set-point as quickly as possible. 29 K p =: Full-power is delivered to motor as long as error>. When position falls below, power command begin to fall off. Position overshoots, and shows little oscillation Steady State Error (Offset): System does not stabilize at the set-point, but at. This generates a power command of %, which is too small to activate the motor K p =2: should ameliorate the offset problem, since the same static error will result in a higher power command Offset has been eliminated, but at cost of oscillations before settling Proportional Gain K p K p = K p =2 3 K p =3 Causes predominant oscillation K p =5 Oscillation behavior has taken over. System is too sensitive (responsive). A slight error causes huge power delivered through the motor. Subsequent slight errors in +ve and ve directions causes sustainable swing around the set point. While the position error is small on the graph, the power swings vigorously. Proportional Gain K p K p =3 K p =5 Proportional-Derivative Control Proportional controller drives the wheel to the set point faster, but results in overshoots and oscillations at higher gains Observation: At larger errors, velocity is small, and at smaller errors velocity is large (as motor swings around the set point) Use derivative control What if we reduce motor power by a quantity proportional to speed. No effect at larger errors Reduce power near set point (reduce oscillations) This looks like what we need to improve response while reducing overshoot 3 32
Proportional-Derivative Control Servo Motors K p =4, K D =: Overshoot is minimized, and there is no any significant oscillatory behavior. K p =4, K D = K p =, K D =5: K D is too large. Controller puts on the brakes too aggressively and the system stops too early before reaching the set-point. When the velocity hits zero, the proportional gain kicks in again and the system corrects K p =, K D =5 33 The servo motor is actually an assembly of four parts: DC motor Gear reduction unit Position sensor Feedback control circuit Servo Motors Servo Motors cntd.. Three wires of a servo: power, ground, control. The power source must be constantly applied Servo shaft typically does not rotate 36 like a DC motor, but can only rotate ± from the centre position. servo has its own power electronics, so very little power flows over the control signal. Servo motors require a 5~6 V DC power supply. This can be taken from the control board power if the servo's aren't doing too much work. Otherwise, a separate power supply is recommended If available DC Voltage is higher, N4 diodes can be used to drop the voltage down to around 6V. Servo will hold the position and resists disturbances to deflect from the command position. Servo needs a consistent (repetitive) voltage pulse to hold the position. Turn rate : is the time it takes to move between the two extreme positions. It is about few seconds in high torque motors
Servo Motor Control cntd.. Servo Motor Specifications Servo PWM method is different from the speed control PWM Speed control PWM: overall duty cycle (% on-time) determines the power/speed of the motor Servo PWM: length of the pulse is used as the shaft position command Futaba S48 : 92ms (full counterclockwise), 52ms (center), 22ms (full clockwise) The servo control pulse modulated frequency is 5Hz (2 ms period), which means that you can command the servo in every 2ms go here 2ms Servo Motors on MIT Handy Board Winch Servo Winch servo rotates continuously Can be used for robot s main drive motors servo 6V control servo 2 5V control Conversion Potentiometer is replaced by a pair of fixed resistors, and the position feedback is taken from the center (feedback signal becomes a constant, and is referred to center position) Therefore, motor continues to turn due to error (reference - center). This methods allows both speed and direction control. the farther the control signal is away from the center position, the faster the motor turns 9.6V
Stepper Motors Coil identification Unipolar motors (easy to drive type) have four coils and are likely to have 5 or 6 wires attached. Use an ohmmeter to identify the connections A-E, B-E,C-E2,D-E2 R A-B, C-D 2R A-C, A-D, B-C, B-D, E-E2 To drive a stepper motor, you need to excite the coils in a particular sequence. there are two sequences that will work. You can use either drive sequence, but find the most reliable one for the application. unipolar stepper motor coil configurations Stepper Motor Control Sequence : Energizes just one coil at a time (4step/cycle). As the current is switched from coil to coil, the motor moves by one step (say.8 ). Reverse the sequence to reverse the direction of rotation Sequence 2: Energizes two coils at a time. There are still four steps to this cycle. Twice as much current is drawn in this sequence, and about.4 times more torque than in sequence. E E2 Stepper Motor Control cntd.. Half stepping Motor Controls Direction Control, Speed control, braking Open loop, or Closed loop control Gearbox Shaft encoder
Digital IR Sensors Break-Beam Sensor Position Feedback: Slotted Wheel Eg: 4: gearbox, 5 slots 36 o =.8 o shaft / slot 4 5 Question : How to determine the direction of motion, and speed of motion?