DC MOTOR CONTROL SYSTEMS
FOR ROBOT APPLICATIONS
By: Rick Bickle
11/7/2003
Motor control questions
Why do we need speed control?
How is DC motor speed controlled?
How is motor direction controlled?
What circuits can be used?
Reasons for accurate speed control
Motor speed should
be independent of
load.
Differential drive
platforms need to
synchronize wheel
speed to go in a
straight line.
Speed control with PWM
Pulse Width Modulation
Simple PWM circuit
U1A
74HC14A
1
2
U1B
74HC14A
3
4
U1C
74HC14A
5
6
U1D
74HC14A
9
8
U1E
74HC14A
11
10
U1F
74HC14A
13
12
C1
CAP NP
D1
DIODE
D2
DIODE
R2
POT
1
3
2
MG1
MOTOR DC
1
2
H-Bridge motor driver circuit
V+
V+
+5
+5
+5
+5
M1
DC Motor
Q1
IRF9510
Q5
2N2222
Q8
2N2222
R6
4.7K
R2
4.7K
R1
4.7K
R3
4.7K
R5
4.7K
U1C
74HC08
9
10
8
14
7
U1B
74HC08
4
5
6
14
7
Q4
IRF510
U1C
74HC08
9
10
8
14
7
R4
4.7K
Q6
2N2222
Q2
IRF9510
Q3
IRF510
U1A
74HC08
1
2
3
14
7
Q7
IRF510
Input A
Input B
PWM Input
CIRCUIT INPUTS
SS
SS
D
DD
D
G
GG
G
A B C Output
0 0 0 N Channel Brake
1 1 0 P Channel Brake
1 0 0 Forward
0 1 0 Reverse
X X 1 Motor Off
D
G
S
Optical encoder circuit
U6B
74HC86
4
5
6
R6 4.7K
R7 4.7K
D4
5V
D3
5V
R9 4.7K
D6
5V
D5
5V
R8 4.7K
U6A
74HC86
1
2
3
U6D
74HC86
12
13
11
U6C
74HC86
9
10
8
R10
10K
C15
0.001uF
C14
0.001uF
R11
10K
U27A
74HC14
1
2
U27B
74HC14
3
4
U27D
74HC14
9
8
U27C
74HC14
5
6
U27F
74HC14
13
12
U27E
74HC14
11
10
Tach Input A
Tach Input B
Tach Input A
Tach Input B
L. MotorR. Motor
Motor control diagram
PROCESSOR
DC
MOTOR
ENCODER
H-BRIDGE
CIRCUIT
Control systems
What is a control system?
What are some examples?
What are the types of control systems?
How are control systems represented?
Open loop control systems
The output of the plant does not affect
the input. (No feedback)
Less common today than closed loop
control systems.
Examples include:
Stereo volume control
Electric drill speed control
Open loop control system
GAIN
INPUT
PLANT
OUTPUT = INPUT X GAIN
Closed loop control systems
Use a measurement of output to control
the input (Feedback)
Examples include:
Air conditioning thermostat
Automobile cruise control
Closed loop control system
GAIN
INPUT
PLANTSUM
FEEDBACK
OUTPUT = (INPUT – OUTPUT) X GAIN
Motor control diagram
PROCESSOR
DC
MOTOR
ENCODER
H-BRIDGE
CIRCUIT
PID Closed loop control system
PID controls the gain portion of the
closed loop control system.
PID algorithms adjust the gain to the
plant based on several characteristics of
the feedback, not just the current
value.
PID control system diagram
I GAIN
INPUT
PLANTSUM
FEEDBACK
P GAIN
D GAIN
SUM
OUTPUT = (INPUT – OUTPUT) X (P GAIN + I GAIN + D GAIN)
Sample PID output chart
Set point
Rise time
Overshoot
Settling time
Peak time
Overdamped
Underdamped
PID implementation
What is the mathematics of PID?
How is it programmed?
What are some common problems?
How is the PID behavior optimized?
PID variables
Error term
P – Proportional gain
I – Integral gain
D – Derivative gain
Error term
The error term is derived by subtracting the feedback
(motor speed) from the set point (set speed).
This is the error in terms of a number of encoder
counts per unit time.
I GAIN
INPUT
PLANTSUM
FEEDBACK
P GAIN
D GAIN
SUM
Proportional term
Simple proportional coefficient Kp is multiplied by
the error term.
Provides linear response to the error term.
I GAIN
INPUT
PLANTSUM
FEEDBACK
P GAIN
D GAIN
SUM
Integral term
Integral coefficient Ki is multiplied by the error term
and added to the sum of all previous integral terms.
Provides response to accumulated error.
I GAIN
INPUT
PLANTSUM
FEEDBACK
P GAIN
D GAIN
SUM
Derivative term
Derivative coefficient Kd is multiplied by the difference
between the previous error and the current error.
Responds to change in error from one PID cycle to the next.
I GAIN
INPUT
PLANTSUM
FEEDBACK
P GAIN
D GAIN
SUM
PID calculation example
Error_term = Set_Speed – Encoder_Count;
P_Term = P_Gain * Error_Term;
D_Term = D_Gain * (Error_Term – D_State);
D_State = Error_Term;
I_State = I_State + Error_Term;
I_Term = I_Gain * I_State;
PWM_Set = PWM_Set + P_Term + I_Term + D_Term;
Factors to consider
PID cycle time (0.1 sec)
Motor speed (30 rpm)
Encoder resolution (500 counts/rev)
PWM frequency (1kHz)
Interrupt driven PID trigger
Eliminates code tuning
Maintains accurate PID timing