Capstone Design - Robotics: Motors and Control
Capstone Design - Robotics: Motors and Control
Capstone Design - Robotics: Motors and Control
Jizhong Xiao
Department of Electrical Engineering
City College of New York
jxiao@ccny.cuny.edu
Robot Actuators
Stepper motors
DC motors
AC motors
Physics review:
Things seek lowest energy states.
Nature is lazy. • iron core vs. magnet N S
• magnetic fields tend to line up
N
Electric fields and magnetic S
fields are the same thing. + v - + v -
Stepper Motor Basics
stator S
N S N S
rotor
torque
N S
angle
N
Half stepping
Increased Resolution
N S
More teeth on rotor or stator
Half stepping
Increased Resolution
N S
More teeth on rotor or stator
Half stepping
How to Control?
4 Lead Wire Configuration
Step Table
Red
Step Red Blue Yellow White A+
0 + - + - 4 lead
1 - + + - motor
A-
2 - + - + Blue
3 + - - +
4 + - + - Yellow White
B+ B-
Clockwise Facing Mounting End
Each step, like the second hand of a clock => tick, tick
Increase the frequency of the steps => continuous motion
Motoring along...
• direct control of position
• precise positioning (The amount of
rotational movement per step depends
on the construction of the motor)
• Easy to Control
N rotor S
stator
brush
+
V
-
commutator
attached to shaft
DC motor basics
permanent
magnets
N rotor S N S
stator
+ +
V V
- -
DC motor basics
permanent
magnets
N rotor S N S N N S S
stator
+ + +
V V V
- - -
Position Sensors
Optical Encoders
Relative position
Absolute position
Other Sensors
Resolver
Potentiometer
Optical Encoders
• Relative position
- direction
light sensor
- resolution
decode
light emitter circuitry
grating
Optical Encoders
mask/diffuser
• Relative position
light sensor
decode
light emitter circuitry
grating
A diffuser tends to
smooth these signals
Ideal Real
Optical Encoders
• Relative position
- direction
light sensor
- resolution
decode
light emitter circuitry
grating
Optical Encoders
• Relative position
- direction
light sensor
- resolution
decode
light emitter circuitry
grating
A
A lags B
B
B
Optical Encoders
• Relative position
- direction
light sensor
- resolution
decode
light emitter circuitry
grating
Phase lag between A and B is 90 degree
B A leads B
Optical Encoders
• Detecting absolute position
something simpler ?
Optical Encoders
• Detecting absolute position
wires ?
Gray Code
# Binary
0 0 000
1 1 001
2 10 011
3 11 010
4 100 110
5 101 111
110 101
6
111 100
7
1000
8
1001
9
among others...
Other Sensors
• Resolver
= driving a
stepper motor
• Potentiometer
= varying
resistance
Control
Control: getting motors to do what you want them to
What you want to control = what you can control
For DC speed
motors:
voltage
windings’
resistance
R
N
w
V V e back
N S emf
V e
DC motor model
Controlling speed with voltage
tR
V= + ke w
R kt
V e
- or -
V
w=- R t+
kt ke ke
DC motor model Speed is proportional to voltage.
speed vs. torque at a fixed voltage
speed w
ke
ktV
torque t
R
speed vs. torque at a fixed voltage
speed w Linear mechanical power Pm = F v
Rotational version of Pm = t w
V no torque at max speed
ke
speed vs.
torque
ktV
torque t stall torque
R
speed vs. torque
speed w
V
ke
max speed gasoline engine
power output
speed vs.
torque
ktV
torque t stall torque
R
Motor specs
tR We want a particular
V= + ke w motor speed w .
kt
Duty cycle:
The ratio of the “On time” and the “Off time” in one cycle
Determines the fractional amount of full power delivered to the
motor
Open-loop vs. Close-loop Control
Open-loop Control:
V(t)
desired speed w Controller Motor w
solving for V(t)
actual speed
PID controller
actual speed wa
PID Controller
PID control: Proportional / Integral / Derivative control
V = Kp • ( e + Ki ∫ e + Kd ddte )
Error signal e
wd - wa
desired wd V actual w
compute V using
- PID feedback
Motor
actual speed w
Evaluating the response
rise time
Kp = 20 Kp = 50
Kp = 200 Kp = 500
Steady-state Errors, P-type
Kp = 50 Kp = 200
Control Performance, PI - type
Kp = 100
Ki = 50 Ki = 200
You’ve been integrated...
Kp = 100
instability &
oscillation
Control Performance, PID-type
Kp = 100
Kd = 2 Kd = 5 Ki = 200
Kd = 10 Kd = 20
PID final control
PID Tuning
How to get the PID parameter values ?
(1) If the system has a known mathematical model (i.e., the
transfer function), analytical methods can be used (e.g., root-
locus method) to meet the transient and steady-state specs.
(2) When the system dynamics are not precisely known, we
must resort to experimental approaches.
Ziegler-Nichols Rules for Tuning PID Controller:
Using only Proportional control, turn up the gain until the system
oscillates w/o dying down, i.e., is marginally stable. Assume that K
and P are the resulting gain and oscillation period, respectively.
Then, use for P control for PI control for PID control
Kp = 0.5 K Kp = 0.45 K Kp = 0.6 K Ziegler-Nichols Tuning
for second or higher
Ki = 1.2 / P Ki = 2.0 / P order systems
Kd = P / 8.0
Implementing PID
Use discrete approximations to the I and D terms:
i=now
• Integral term: S e
i=0 i
b. 0.09 of sampling rate might represent, a 90 cycle/second sine wave being sampled at 1000
samples/second; in another word, there are 11.1 samples taken over each complete cycle of the sinusoid
d. Aliasing occurs when the frequency of the analog sine wave is greater than the Nyquist frequency (one-
half of the sampling rate); in other word, the sampling frequency is not fast enough. Aliasing
misrepresents the information, so the original signal cannot be reconstructed properly from the samples.
Shannon’s Sampling Theorem
An analog signal x(t) is completely specified by the samples
if x(t) is bandlimited to wBL ws / 2 , where ws 2 / Ts
In other word, a continuous signal can be properly sampled,
only if it does not contain frequency components above one-
half of the sampling rate.
Definitions:
Given a signal bandlimited to f BL , must sample at greater than 2 f BL
to preserve information. The value 2 f BL is called Nyquist rate (of
sampling for a given f BL )
Given sampling rate f s , the highest frequency in the signal must be
less than f s / 2 if samples are to preserve all the information. The
value f NYQ f s / 2 is called the Nyquist frequency (associated with a
fixed sample frequency).
Rule of Thumb
For a closed-loop control system, a typical
choice for the sampling interval T based on
rise time is 1/5 th or 1/10 th of the rise time.
(i.e., 5 to 10 samples for rise time)
Motor Drive
Micro-controller
Logic Level