Real-Time Control Lecture - MAELabs UCSD
Real-Time Control Lecture - MAELabs UCSD
Real-Time Control Lecture - MAELabs UCSD
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Requirements<br />
Modeling<br />
Open-Loop Survey<br />
Proportional <strong>Control</strong><br />
PID <strong>Control</strong><br />
Robustness<br />
<strong>Real</strong>-<strong>Time</strong> <strong>Control</strong><br />
MAE 156A
What does your system need to do?<br />
Requirements<br />
Feedback control can be expensive – are you sure that you need it?<br />
Passive <strong>Control</strong> = no electronic components (e.g. water level)<br />
Active <strong>Control</strong> = electronic components (e.g. cruise control)<br />
reference<br />
<strong>Control</strong> Actuator<br />
Sensors<br />
MAE 156A<br />
noise<br />
noise<br />
Mechanical<br />
System<br />
2
Modeling<br />
Developing an accurate system model is important because a small time investment<br />
at the beginning of a project can save huge amounts of time later<br />
Modeling is needed to verify design choices<br />
Modeling is needed to select components<br />
You might as well get organized and build a complete system model<br />
Components or suppliers will change – and you don't want to repeat the entire design cycle<br />
over again.<br />
An accurate model can be used to develop test procedures and methods<br />
Try a new idea on the model first (before you embarrass yourself in the lab)<br />
MAE 156A<br />
3
V c<br />
(-)<br />
1<br />
L<br />
R s1<br />
Block Diagram : Motor and Table<br />
K t<br />
R<br />
V_c = motor command voltage<br />
L = armature inductance<br />
R = armature resistance<br />
K_t = torque constant<br />
K_e = back EMF constant<br />
T_m = motor torque<br />
T m ˙ <br />
r t<br />
r m<br />
r t<br />
r<br />
m K e<br />
MAE 156A<br />
(-)<br />
±D<br />
1<br />
Js<br />
J = equivalent moment of inertia (at table)<br />
D = equivalent friction (at table)<br />
theta = table angular position<br />
r_t = table radius<br />
r_m = motor shaft radius<br />
1<br />
s<br />
4
Open-Loop System Survey<br />
An open-loop system survey is used to study the system dynamics.<br />
Is the system dynamic model accurate enough?<br />
What are system dynamic characteristics?<br />
Determine open-loop system transfer functions<br />
Identify nonlinear functions and behavior<br />
Make following assumptions to find the open-loop transfer function of motor + table<br />
Armature dynamics are “fast”: L/R is a small number<br />
Dry friction acts like viscous friction<br />
s<br />
V c s =<br />
r t /r m K t / R<br />
J s 2 [ D' K t / Rr t / r m 2 K e ]s<br />
MAE 156A<br />
D '≈ D<br />
∣ ˙ max∣<br />
5
Motor Drive<br />
Pot A/D Counts<br />
300<br />
200<br />
100<br />
0<br />
-100<br />
-200<br />
Open-Loop Test Data<br />
-300<br />
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1<br />
600<br />
500<br />
400<br />
300<br />
200<br />
100<br />
0<br />
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1<br />
MAE 156A<br />
added weight<br />
<strong>Time</strong> (sec)<br />
<strong>Time</strong> (sec)<br />
6
A set<br />
(-)<br />
Aset = pot count set point<br />
A = pot count<br />
Block Diagram : Closed-Loop<br />
time<br />
control<br />
driver motor + table<br />
delay<br />
±255 board<br />
K s e − d s<br />
A<br />
K(s) = control system dynamics<br />
G(s) = motor + table dynamics<br />
Q<br />
MAE 156A<br />
N<br />
tau_d = time delay<br />
V c <br />
G s<br />
N = motor driver board conversion [V/count]<br />
Q = table position to pot [count/rad]<br />
7
Proportional <strong>Control</strong><br />
Start with a simple control scheme that sets the motor drive voltage proportional to<br />
the set point error.<br />
K s=K p = proportional gain<br />
Approximate time delay using a first-order lag filter.<br />
e − d ≃ 1<br />
d s1<br />
The closed-loop characteristic equation is:<br />
J d s 3 D' ' d J s 2 D' ' sK p QN r t /r m K t / R=0<br />
D ' ' =D ' K t / Rr t /r m 2 K e<br />
MAE 156A<br />
8
K s=K p<br />
Root Locus for Varied Kp<br />
K p ∞<br />
0<br />
-120 -100 -80 -60 -40 -20 0 20<br />
MAE 156A<br />
Imaginary<br />
60<br />
40<br />
20<br />
-20<br />
-40<br />
-60<br />
K p ∞<br />
K p ∞<br />
<strong>Real</strong><br />
Open-Loop Pole<br />
9
Motor Drive<br />
Pot A/D Counts<br />
300<br />
200<br />
100<br />
0<br />
-100<br />
-200<br />
Proportional <strong>Control</strong><br />
-300<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
1000<br />
800<br />
600<br />
400<br />
200<br />
0<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
MAE 156A<br />
<strong>Time</strong> (sec)<br />
<strong>Time</strong> (sec)<br />
10
Pot A/D Counts Motor Drive<br />
300<br />
200<br />
100<br />
0<br />
-100<br />
-200<br />
Limit Cycle Response<br />
-300<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
1000<br />
800<br />
600<br />
400<br />
200<br />
0<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
MAE 156A<br />
<strong>Time</strong> (sec)<br />
<strong>Time</strong> (sec)<br />
11
K s=K p K d s<br />
K d<br />
K p<br />
=1<br />
Root Locus for PD <strong>Control</strong><br />
K p ∞<br />
0<br />
-60 -50 -40 -30 -20 -10 0 <strong>Real</strong><br />
K p ∞<br />
MAE 156A<br />
Imaginary<br />
150<br />
100<br />
50<br />
-50<br />
-100<br />
-150<br />
Open-Loop Pole<br />
12
Pot A/D Counts Motor Drive<br />
300<br />
200<br />
100<br />
0<br />
-100<br />
-200<br />
Proportional + Derivative <strong>Control</strong><br />
-300<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
1000<br />
800<br />
600<br />
400<br />
200<br />
0<br />
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2<br />
MAE 156A<br />
<strong>Time</strong> (sec)<br />
<strong>Time</strong> (sec)<br />
13
Implementation Issues<br />
Numerical differentiation tends to amplify noise<br />
Consider adding a lag filter to smooth the response<br />
K s=K p K i<br />
s K d s≃K p K i<br />
s K d s<br />
q s1<br />
Numerical integration may lead to actuator drive saturation<br />
Consider “anti-windup” integrator<br />
is= K i<br />
s [ A set s−As]<br />
If amplitude of i(s) exceeds a<br />
threshold, either reset i(s) = 0 or hold<br />
i(s) at the threshold value.<br />
MAE 156A<br />
q = smoothing time constant<br />
14
Loop <strong>Time</strong> Considerations<br />
Numerical integration and differentiation depend upon loop time step.<br />
What happens if you change the loop time step?<br />
Laplace Domain<br />
<strong>Time</strong> Domain<br />
Discrete <strong>Time</strong><br />
d s=K d s [ A set s−As] =K d<br />
d t=K d ˙et<br />
d [k ]≃K d <br />
d [k ]≃ K d<br />
<br />
e [k ]−e[k −1]<br />
<br />
e[k ]−e[k −1]<br />
MAE 156A<br />
s es<br />
k =loop counter<br />
=time step<br />
A change in the loop<br />
time step alters the<br />
effective derivative gain!<br />
15
Robustness<br />
A closed-loop system exhibits robustness if its response characteristics are<br />
insensitive to parameter variations and noise.<br />
Parameter variations are likely to occur through normal wear<br />
Expected wear should be considered as part of the overall life cycle design<br />
Noise may depend on environment and operating conditions<br />
Gain and phase margins are traditional measures of robustness<br />
Gain margin measures tolerance to loop gain variations<br />
Phase margin indicates tolerance to loop phase variations<br />
Phase margin also measures tolerance to loop time delay<br />
Other robustness tests are possible using a model simulation<br />
Consider random variations in each model parameter<br />
Robustness results become part of your system's performance specification<br />
MAE 156A<br />
16
Summary<br />
Even a low-fidelity model can help you understand the underlying dynamics.<br />
Don't be afraid of nonlinear elements – there is often an approximation available.<br />
Keep track of loop step time as your design progresses.<br />
Your effective control gains may change with time step<br />
Large time delays reduce phase margin<br />
Debugging real-time control firmware can be frustrating if you don't carefully consider<br />
each code modification.<br />
When in doubt, print out intermediate results!<br />
MAE 156A<br />
17