PID Controls of Motors Howie Choset (thanks to George Kantor and Wikipedia)

advertisement
PID Controls of Motors
Howie Choset
(thanks to George Kantor and Wikipedia)
http://www.library.cmu.edu/ctms/ctms/examples/motor/motor.htm
Overview
• Mass-Spring-Damper System
• Second order ODE
– Definition
– Vary parameters
– Forcing functions
• Different feedback meaning
– Proportional
– Derivative
•
•
•
•
•
Control for Error – block diagram
Integral Control
Different Affects of Varying PID
Feed Forward Term
Vehicle Controls
Mass Spring
Standard Form of DEQ
Natural (undamped) frequency (rads/sec)
Damping ratio (unitless)
Vary Natural Frequency
Mass Spring Damper
Standard Form of DEQ
Natural (undamped) frequency (rads/sec)
Damping ratio (unitless)
Let
Solutions/Responses
Under-damped (0 < ζ < 1)
Let
Solutions/Responses
Under-damped (0 < ζ < 1)
Let
Solutions/Responses
Under-damped (0 < ζ < 1)
decay
Oscillation, damped natural frequency
Let
Step Response
,
As time goes on, x(t) goes to 1
PID Feedback
-Kx
(
+ K) x = 0
Proportional Feedback
plant
Set desired position to zero
Note that the oscillation dies out at
approximately the same rate but has
higher frequency. This can be thought of
as “stiffening the spring”.
Proportional/Damping
plant
We can increase the
damping (i.e., increase the
rate at which the
oscillation dies out)
Increasing damping slows everything down (note deriv is an approx and turning the gain high, can cause problems because in a sense it amplifies nois
PD works well if desired point is an equilibrium of system, which makes
sense because when you are at target, PD does not exert force
Non-zero desired PD
Xd = 1.6
Settle time same
Steady state error!
At set point, applying no force so end up settling at equilibrium
that balances force due to error and force due to spring (damper
goes away in steady state because depends on derivative).
Crank up P gain, steady state error gets smaller, but that causes
overshoot, oscillations, etc which you don’t want
PID Control
plant
System does its
dynamic thing and
then gradually
integrates to correct
for steady state error
As increase I gain, gets
faster, good response
Integral gets so bad, it starts
to interfere with other
dynamics, lead to unintended
motions which could lead to
instability
Winding of motor
Review of Motor Model
•electric inductance (L) = [H]
(VL = L di/dt)
* input (V): Source Voltage
* output (theta): position of shaft
* The rotor and shaft are assumed to be rigid
• moment of inertia of the rotor (J) [kg.m^2/s^2]
* damping ratio of the mechanical system (b) [Nms]
* electromotive force constant
•Ke is volt (electromotive force) per radians per second (V/ rad/sec)
• torque constance
•Kt is torque amp (Nm/Amp)
* electric resistance (R) = [ohm]
Review of Motor Model
Torque is proportional to current (Lenz’s Law)
Back emf is proportional to motor speed (Faraday’s Law)
Mechanical Equation of Motion
Jθ + bθ = Ki
Electrical Equation of Motion
di
L + Ri = V − Kθ
dt
s( Js + b ) Θ( s ) = KI( s )
(Ls + R)I( s ) = V − KsΘ( s )
sθ
K
=
V ( Js + b )( Ls + R ) + K 2
+
-
+
Assume (K=Ke=Kt)
-
Solve for diff eq in w dot
Closed Loop Controller
Give it a velocity command
and get a velocity output
Ref
+
error
-
Controller
Controller Evaluation
Steady State Error
Rise Time (to get to ~90%)
Overshoot
Settling Time (Ring) (time to steady state)
Stability
voltage
Plant
θ
Closed Loop Response (Proportional Feedback)
Proportional Control K
p
Easy to implement
Input/Output units agree
Improved rise time
Steady State Error (true)
➡P: ➢Rise Time vs. ➡ Overshoot*
➡P: ➢Rise Time vs. ➢ Settling time*
➡P: ➢Steady state error vs. other problems
R
+
error
-
Voltage = Kp error
Controller
voltage
Plant
θ
*In some other systems, not mass-spring
Closed Loop Response (PI Feedback)
Proportional/Integral Control
1
K p + KI
No Steady State Error
s
Bigger Overshoot and Settling
Saturate counters/op-amps
➡P: ➢Rise Time vs. ➡ Overshoot
➡P: ➢Rise Time vs. ➢ Settling time
➡I: ➢Steady State Error vs. ➡Overshoot
Ref
+
error
-
1
voltage
K p + KI
s
Voltage = (Kp+1/s Ki) error
Plant
θ
Closed Loop Response (PID Feedback)
Proportional/Integral/Differential
Quick response
Reduced Overshoot
1
K p + K I + sK D
s
Sensitive to high frequency noise
Hard to tune
➡P: ➢Rise Time vs. ➡ Overshoot
➡P: ➢Rise Time vs. ➢ Settling time
➡I: ➢Steady State Error vs. ➡Overshoot
➡D: ➢Overshoot vs. ➡Steady State Error
R
+
error
-
1
K p + K I + sK D
s
Voltage = (Kp+1/s Ki + sKd) error
voltage
Plant
θ
Quick and Dirty Tuning
•
•
•
•
Tune P to get the rise time you want
Tune D to get the setting time you want
Tune I to get rid of steady state error
Repeat
• More rigorous methods – Ziegler Nichols, Selftuning,
• Scary thing happen when you introduce the I term
– Wind up (example with brick wall)
– Instability around set point
Feed Forward
Volt
Decouples Damping from PID
To compute K b
Try different open loop inputs and measure output velocities
For each trial i,
ui
i
K b = . , K b = avg K bi
Tweak from there.
K
θi
Kb
R
+
error
-
+
volt
+
Controller
Plant
θ
Follow a straight line with differential drive
or at least get to a point
Error can be difference in wheel velocities or accrued distances
Make both wheels spin the same speed
asynchronous – false start
wheels can have slight differences (radius, etc)
Make sure both wheels spin the same amount and speed
false start
Assumptions
•
•
•
•
planar workspace
position of robot and goal are known
omni-directional robot (we’ll relax this later)
control input is velocity:
(boldface lie, we’ll relax this later, too)
Proportional (P) Control:
•
•
•
•
the equation above is called a control law
kp is called the proportional gain
kp is a tunable parameter
physically, kp is the stiffness of the spring
Proportional-Derivative (PD) control:
Fill the world with honey!
In direction of arrow
•
•
•
•
opposite
kd is called the derivative gain
kp and kd are tunable parameters
physically, kd is the damping term
all of the stuff about P control still applies
Robot Inputs
So far we’ve assumed something like
But really, we control the velocities of the left and
right wheels, which can easily be mapped to forward
and turning velocities:
Nonholonomic Constraints
The equations of motion using these controls are:
The fact that the robot can’t move sideways is a
nonholonomic constraint (we will see this again).
The Problem:
P or PD control won’t work.
No smooth control law will!
A Simple Solution:
Like a rigid trailor
hitch (not driving
to point)
A Simple Solution (cont.):
If we ignore orientation:
so we can implement the PD control law as:
p
p
Did not get rid of nh constraint, but moved it to something we don’t care about
(theta, angular and linear velocities) - trailor hitch story
Line following
More complicated control laws – track orientation
m1vref = vref + K1 * thetaerror + K2 * offset error
m2vref = vref - K1 * thetaerror - K2 * offset error
offset
Really, there is a sensor
Encoders
Encoders – Incremental
Photodetector
Encoder disk
LED Photoemitter
Encoders - Incremental
Encoders - Incremental
• Quadrature (resolution enhancing)
Where are we?
• If we know our encoder values after the
motion, do we know where we are?
Where are we?
• If we know our encoder values after the
motion, do we know where we are?
• What about error?
Download