You are on page 1of 34

DC Motor Speed Control

The original problem is on these web pages.


http://www.engin.umich.edu/group/ctm/examples/motor/PID2.html
http://www.engin.umich.edu/group/ctm/examples/motor2/motor.html

ω( s) K
Gm( s) = = Transfer function for a DC Motor
V( s) 2
( J⋅ s + b ) ⋅ ( L⋅ s + R) + K

Ki A simple PID controller


Gc( s) = + Kp + Kd⋅ s
s

 Ki + Kp + Kd⋅ s ⋅ K
 s  Closed loop transfer function
  ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2 Gc( s) ⋅ Gm( s)
T( s) = T( s) =
1 +  + Kp + Kd⋅ s ⋅
Ki K 1 + Gc( s) ⋅ Gm( s)
 s  ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2

T( s) =
(Ki + Kp⋅s + Kd⋅s2)⋅K
J⋅ s ⋅ L + ( J⋅ R + b ⋅ L + K⋅ Kd) ⋅ s + ( K + K⋅ Kp + b ⋅ R) ⋅ s + K⋅ Ki
3 2 2

( Ki+Kp⋅ s+Kd⋅ s2) ⋅ K


J⋅ L
T( s) =
2
3J⋅ R + b ⋅ L + K⋅ Kd 2 K + K⋅ Kp + b ⋅ R K⋅ Ki
s + ⋅s + ⋅s +
J⋅ L J⋅ L J⋅ L

Desired characteristic
( s + λ )3 equation. In this case a
critically damped response is
desired with 3 poles at -λ.

Find the difference between the system characteristic equation and the desired
characteristic equation and the solve for the gains.
2
J⋅ R + b ⋅ L + K⋅ Kd 2 K + K⋅ Kp + b ⋅ R K⋅ Ki
− (s + λ )
3 3
DiffCE := s + ⋅s + ⋅s +
J⋅ L J⋅ L J⋅ L
coeffs , s

DiffCE

 Ki → λ 3⋅ J⋅ L
(−K2) − b⋅R + 3⋅λ 2⋅J⋅L ( −J) ⋅ R − b ⋅ L + 3 ⋅ λ ⋅ J⋅ L 

solve ,  Kp   K K K 
 
 Kd 

(c) 2009 Delta Computer Systems, Inc. 1/34 4/30/2013 11:10 AM


DC Motor Speed Control

DC Motor Parameters
See http://www.engin.umich.edu/group/ctm/examples/motor/motor.html

J := 0.01 J = 0.01 kg*m2

b := 0.1 b = 0.1 N*m*s

K := 0.01 K = 0.01 V/rad/sec

R := 1 R=1 Ohm

L := 0.5 L = 0.5 Henrys

Find the DC gain. It is about 0.1 radians per second per volt. Therefore the
motor has a maximum speed of 1 radian per second which is very slow.
Obviously this is not a realistic example.

K
lim float , 2 → .10
s → 0 ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2

Calculate the PID gains. Place the three closed loop poles at -λ radians to get a critically
damped response. Making λ bigger moves the closed loop poles farther to the left and
makes the response faster.

λ := 2 ⋅ π ⋅ 3 λ = 18.849556

3 L
Ki := λ ⋅ J⋅ Ki = 3348.677881
K

Kp :=
(−K2) − b⋅R + 3⋅λ 2⋅J⋅L Kp = 522.948638
K

( −J) ⋅ R − b ⋅ L + 3 ⋅ λ ⋅ J⋅ L
Kd := Kd = 22.274334
K

(c) 2009 Delta Computer Systems, Inc. 2/34 4/30/2013 11:10 AM


DC Motor Speed Control

Simulate modeling errors


The rnorm function generates a number with a mean of 1 and a standard deviation of σ. These
numbers multiplied by the model parameters to generate simulated 'true' systems parameters.

σ := 0.1

K := K⋅ rnorm( 1 , 1 , σ ) 0 K = 0.01

J := J⋅ rnorm( 1 , 1 , σ ) 0 J = 0.01

b := b ⋅ rnorm( 1 , 1 , σ ) 0 b = 0.1

R := R ⋅ rnorm( 1 , 1 , σ ) 0 R=1

L := L⋅ rnorm( 1 , 1 , σ ) 0 L = 0.5

The DC Motor Velocity Model in State Space


 −b K 
 J J  0 
Ac := 
 −10 1  B c :=  1 
0 
 Ac =   Bc =  
−K −R   −0.02 −2    2 
L
 L L
I := identity( 2 )

Τ := .001

Calculate arrays for use in discrete time.


 Ac⋅ Τ ) 
7
(Ac⋅ Τ )n B := I +
7
( n
⋅B ⋅Τ
A := I +
∑ n!  ∑( n + 1 )!  c
n =1  n =1 

 0.99005 0.000994   9.960103 × 10− 7 


A=  B= 
 −0.00002 0.998002   0.001998 

 Τ 0

0
1 −1
Kzi := ( Ki Kp Kd ) ⋅  
0
Convert the PID gains to
1 2 1  coefficients for the PID
 Τ −Τ 
 Τ difference equation.

Kzi = ( 22800.631198 −45071.616402 22274.333882 )

(c) 2009 Delta Computer Systems, Inc. 3/34 4/30/2013 11:10 AM


DC Motor Speed Control

PID Critically Damped Control. Graph the response of the DC Motor


0 
0 
x :=   u := 0 err :=  0 
0 0  0 0  
0 

 r − x0  Shift the error history


PID( r , x , u , err) := err ←  err0 
 
 err1 
  Update state
 A⋅ x + B ⋅ u

 ( ( ) )
max min u + Kz ⋅ err , 10 , −10 Calculate control output
i
 
 err  Return the error history too

Simulate 10 seconds in increments of Τ seconds


10
N := N = 10000 n := 0 .. N
Τ

r := 0 if n < 10
n
 0.5 + 0.0  −  0.5 − 0.0  ⋅ cosπ ⋅  n − 10  if 10 ≤ n < 1010 r(n) is the target or
 2   2    0.1⋅ N 
       reference velocity.
0.5 if n ≥ 1010 ∧ n < 0.3⋅ N
 0.5 − 0.8  −  −0.8 − 0.5  ⋅ cosπ ⋅  n − 0.3⋅ N  if 0.3⋅ N ≤ n < 0.4⋅ N
 2      0.1⋅ N 
   2    
−0.8 if n ≥ 0.4⋅ N ∧ n < 0.7⋅ N
 −0.8 − 0.25  −  −0.25 − −0.8  ⋅ cosπ ⋅  n − 0.7⋅ N  if 0.7⋅ N ≤ n < 0.8⋅ N
      0.1⋅ N 
 2   2    
−0.25 otherwise

 xn+1 
u  := PID r , x , u , err Call the PID routine
 n+1  ( n n n n) for each time period.
 errn+1 
 

(c) 2009 Delta Computer Systems, Inc. 4/34 4/30/2013 11:10 AM


DC Motor Speed Control

PID Velocity Control of DC Motor


0.6 10

0.4

0.2 5

Motor Current and Control Output


Target and Actual Velocity

0.2 0

0.4

0.6 5

0.8

1 10
0 2 4 6 8 10

Time
Target Velocity
Actual Velocity
Motor Current
Control Output

K = 0.01 J = 0.01 R=1 L = 0.5 Motor


λ = 18.849556 Ki = 3348.677881 Kp = 522.948638 Kd = 22.274334 Inner Loop

The actual velocity tracks the target velocity almost perfectly execet where the control output
saturates at about 3.3 seconds. A less radical velocity change or reducing the bandwidth by
reducing λ wouls avoid the output saturation.

(c) 2009 Delta Computer Systems, Inc. 5/34 4/30/2013 11:10 AM


DC Motor Speed Control

Open Loop Bode Plot Calculations

T( s) :=  Ki + Kp + Kd⋅ s ⋅ K
 
 s  ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2

n := 0 .. 320 Iterate the frequency from .01 HZ to 1000 HZ


using 64 steps per decade for a total of 256
n iterations.
−2
64
Hz := 10 Closed loop magnitude of transfer function as a
n
function of frequency

 Mn 
:= r ← Tj ⋅ ( 2 ⋅ π ) ⋅ Hz 
 φn   n
 
arg( r)
a←
deg
a ← a − 360 if n > 0 ∧ a − φ n− 1 > 100

 20⋅ log( r ) 
 
 a 

Open Loop Bode Plot


100 80

100
50
Magnitude db

Phase deg

120

0
140

50 160
1 .10
3
0.01 0.1 1 10 100

Frequency Hz
Magnitude
Phase

(c) 2009 Delta Computer Systems, Inc. 6/34 4/30/2013 11:10 AM


DC Motor Speed Control

Closed Loop Bode Plot Calculations

T( s) :=
(Ki + Kp⋅s + Kd⋅s2)⋅K
3 2 2 2 2
J⋅ s ⋅ L + J⋅ s ⋅ R + b ⋅ L⋅ s + s⋅ b ⋅ R + s⋅ K + K⋅ Ki + K⋅ Kp⋅ s + K⋅ Kd⋅ s

n := 0 .. 320 Iterate the frequency from .01 HZ to 1000 HZ


using 64 steps per decade for a total of 256
n iterations.
−2
64
Hz := 10 Closed loop magnitude of transfer function as a
n
function of frequency

 Mn 
:= r ← Tj ⋅ ( 2 ⋅ π ) ⋅ Hz 
 φn   n
 
arg( r)
a←
deg
a ← a − 360 if n > 0 ∧ a − φ n− 1 > 100

 20⋅ log( r ) 
 
 a 

Closed Loop Bode Plot


10 0

0
20

10
Magnitude db

40
Phase deg

20
60
30

80
40

50 100
1 .10
3
0.01 0.1 1 10 100

Frequency Hz
Magnitude
Phase

(c) 2009 Delta Computer Systems, Inc. 7/34 4/30/2013 11:10 AM


DC Motor Speed Control

Poles and Zeros

T( s) :=
(Ki + Kp⋅s + Kd⋅s2)⋅K
J⋅ s ⋅ L + ( J⋅ R + b ⋅ L + K⋅ Kd) ⋅ s + ( K + K⋅ Kp + b ⋅ R) ⋅ s + K⋅ Ki
3 2 2

 K⋅ Ki 
 2 
3 2 2
( )
J⋅ s ⋅ L + ( J⋅ R + b ⋅ L + K⋅ Kd) ⋅ s + K + K⋅ Kp + b ⋅ R ⋅ s + K⋅ Ki
coeffs , s
explicit
→
K + K⋅ Kp + b ⋅ R 
 J⋅ R + b ⋅ L + K⋅ Kd 
 
 J⋅ L 
 K⋅ Ki 
 2   −18.849556  Right where we
poles := polyroots  K + K⋅ Kp + b ⋅ R  
poles =  −18.849556  wanted them to be!
  J⋅ R + b⋅ L + K⋅ Kd    
   −18.849555 
 J⋅ L 

K⋅ Ki 
coeffs , s 
(Ki + Kp⋅s + Kd⋅s )⋅K 2
explicit
→ K⋅ Kp 

 
 K⋅ Kd 
  K⋅ Ki  
zeros := polyroots  K⋅ Kp  
  −11.738817 − 3.540924i 
 
zeros =  
 −11.738817 + 3.540924i 
  K⋅ Kd  
Poles and Zeros
20
Imaginary Axis

20 0 20

20

Real Axis
Poles
Zeros

(c) 2009 Delta Computer Systems, Inc. 8/34 4/30/2013 11:10 AM


DC Motor Speed Control

Add Outer Position Loop


Use i subscripts for inner loop
λ := λ Kii := Ki Kpi := Kp Kdi := Kd
parameters and i subscripts for
outer loop parameters.
3
 Kio  λ
 + Kpo + Kdo ⋅ s ⋅
 s  s⋅ ( s + λ ) 3
To =
3
 Kio  λ
1+  + Kpo + Kdo ⋅ s ⋅
 s  s⋅ ( s + λ ) 3

 Ki + Kp ⋅ s + Kd ⋅ s2 ⋅ λ 3
To =
 o o o 

s + 3 ⋅ s ⋅ λ + 3 ⋅ s ⋅ λ +  λ ⋅ Kdo + λ  ⋅ s + λ ⋅ Kpo ⋅ s + λ ⋅ Kio


5 4 3 2 3 3 2 3 3
 

DiffCE := s + 3 ⋅ s ⋅ λ + 3 ⋅ s ⋅ λ +  λ ⋅ Kdo + λ
3 2
5 4 3 2

3 3 3
( )3 ( )(
 ⋅ s + λ ⋅ Kpo ⋅ s + λ ⋅ Kio − s + µ ⋅ s + α ⋅ s + β
)


coeffs , s 2 2
3 ⋅ µ 3⋅ λ − 3 ⋅ µ ⋅ λ + 2 ⋅ µ 3 ⋅ µ 2⋅ ( −8 ) ⋅ µ ⋅ λ
2
+ 5⋅ µ + 3⋅ λ
2 ( 3 2
− λ + 18⋅ µ ⋅ λ − 10
 Kio   3 3 3
   λ λ λ
DiffCE  Kpo → 
solve ,  Kd  
 o   3 λ 2 − 3⋅ µ⋅ λ + 2⋅ µ2 2 ( −8 ) ⋅ µ ⋅ λ
2
+ 5⋅ µ + 3⋅ λ
2 ( 3 2
− λ + 18⋅ µ ⋅ λ − 10
 α  3 ⋅ µ ⋅ 3
3⋅ µ ⋅
3 3
   λ λ λ
 β 

 2
3 λ − 3⋅ µ⋅ λ + 2⋅ µ
2  The symbolic equations for the
 3⋅ µ ⋅  outer loop gains as a function of
 λ
3  the inner loop poles and the outer
  loop poles. If the relationship
 2
2 5 ⋅ µ − 8 ⋅ µ ⋅ λ + 3⋅ λ
2  between the outer loop poles, µ,
 3⋅ µ ⋅  and the inner loop poles, λ, is not
 Kio   λ
3
 right the outer loop gains will be
    negative or the unplaced poles, α
3 2 3 2
 Kpo   10⋅ µ − 18⋅ µ ⋅ λ − λ + 9 ⋅ µ ⋅ λ  and β, will be in the right hand
 Kd  =  3  plane.
 o  λ 
 α   1
   
 β  3 3 1  2
2
2 
 2 ⋅ λ − 2 ⋅ µ − 2 ⋅ ( −3) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ  
 
 1
3 2
 ⋅ λ − ⋅ µ + ⋅ ( −3 ) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ  
3 1 2 2
2 2 2 

(c) 2009 Delta Computer Systems, Inc. 9/34 4/30/2013 11:10 AM


DC Motor Speed Control

Graphs the outer loop gains and α and β as a function of the ratio of the
outer loop pole location to the inner loop pole locations. This is
backwards from a root locus plot.
µ := 0 , 0.01λ .. 1λ

Ki,Kp,Kd,alpha & beta as a function of mu


40

20
Ki,Kp,Kd,alpha & beta as a function of mu

20

40

60

80
0 0.2 0.4 0.6 0.8

mu / lambda
Ki
Kp
Kd
alpha
beta

µ is only valid where Ki, Kp, Kd, α and β are positive and this is only a small fractional range of λ.
Kd is negative if µ/λ is too low and α and β are negative if µ/λ is greater than 1.
Ki, Kp and Kd are maximum at 0.355λ:

(c) 2009 Delta Computer Systems, Inc. 10/34 4/30/2013 11:10 AM


DC Motor Speed Control

µ := µ

Find µ for max Ki

 0   0 
 0   0 
 1   1   0 
 3 λ 2 − 3⋅ µ⋅ λ + 2⋅ µ2   
 3 1 2    3 1 2  
d 
3⋅ µ ⋅  solve , µ →  + ⋅6 ⋅λ  + ⋅ 6   =  0 
dµ    0.844949 
 λ
3
  5 10    5 10  
 1   1
 0.355051 
 
 3 1 2    3 1 2  
 5 − 10 ⋅ 6  ⋅ λ   5 − 10 ⋅ 6  

Find µ for max Kp


 0   0 
   

1

1
     0 
 2 5 ⋅ µ 2 − 8 ⋅ µ ⋅ λ + 3⋅ λ 2   3 + 1 ⋅ 6 2  ⋅ λ   3 + 1 ⋅ 6 2  ⋅ λ 
 3⋅ µ ⋅  = 15.926913 

d
solve , µ →  5 10    5 10  
dµ  3    
 λ  1   1   6.692554 
 3 1 2    3 1 2  
 − ⋅ 6  ⋅ λ   − ⋅ 6  ⋅ λ 
 5 10    5 10  
Find µ for max Kd

 1 
 3 1 2  
 10⋅ µ 3 − 18⋅ µ 2⋅ λ − λ 3 + 9 ⋅ µ ⋅ λ 2   + ⋅ 6  ⋅ λ 
 5 10  
 3⋅  solve , µ → 
d
dµ  3   1 
 λ   3 1 2  
 − ⋅ 6  ⋅ λ 
 5 10  

The maximum outer loop gains will all happen at the same ratio of µ to λ.
 1
 3 1 2
µ :=  − ⋅ 6  ⋅ λ or about 0.355*λ
 5 10 

 1
 3 1 2
µ :=  − ⋅6  ⋅λ µ = 6.692554
 5 10 

(c) 2009 Delta Computer Systems, Inc. 11/34 4/30/2013 11:10 AM


DC Motor Speed Control

Substitute the optimal value of µ in terms of λ


Now all tuning can be done in terms of the inner loop poles position using λ alone.




 2
3 λ − 3⋅ µ⋅ λ + 2⋅ µ
2  
 3⋅ µ ⋅ 

 3 

λ
 

 2 2 

2 5 ⋅ µ − 8 ⋅ µ ⋅ λ + 3⋅ λ
3⋅ µ ⋅  
 1

 Kio   λ
3
  3 1 2  Kio 
    substitute , µ =  − ⋅6 ⋅λ   
3 2 3 2  5 10  
 Kpo   10⋅ µ − 18⋅ µ ⋅ λ − λ + 9 ⋅ µ ⋅ λ   Kpo  
 Kd  =  3  expand
→  Kd  =
 o  λ  simplfy  o 
 α   1  α  
    collect , λ  
 β  2  β  
3 3 1  2 2 

 2 ⋅ λ − 2 ⋅ µ − 2 ⋅ ( −3) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ   
  
 1

3 2

 ⋅ λ − ⋅ µ + ⋅ ( −3 ) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ  
3 1 2 2
2 2 2  


(c) 2009 Delta Computer Systems, Inc. 12/34 4/30/2013 11:10 AM


DC Motor Speed Control

The formulas for outer loop gains and unplaced poles in terms of λ alone
 1 
3
1 
2 
  1  
 3 1 2   −4 3 2  3 1 2  2
 3⋅  − ⋅6  ⋅ + ⋅ 6 + 2⋅  − ⋅6   ⋅λ 
  5 10   5 10  5 10  
 
1   1
2 2
  1 
  3 1 2    3 1 2  9 4 2 
 3⋅  − ⋅ 6  ⋅ 5 ⋅  − ⋅6  − + ⋅6  ⋅λ 
 5 10    5 10  5 5 
 
 Kio   3 2 
   1  1 1
  3 1 2  3 1 2 
 Kpo   10⋅  − ⋅ 6  − 18⋅  − ⋅6  +
22

9 2
⋅6 
 Kd  =  5 10   5 10  5 10
 o 
 α   1
   2
 β   1  2  
  1  1
 3 3 2  1   3 1 2 2  3 1 2  2 
 + ⋅ 6  ⋅ λ − ⋅ ( −3 ) ⋅ λ + 18⋅  − ⋅ 6  ⋅ λ − 15⋅  − ⋅ 6  ⋅ λ  
2

 5 20  2   5 10   5 10   
 1
 2
 1   1  1
2  
 3 3        
 + ⋅ 6 2  ⋅ λ + 1 ⋅ ( −3 ) ⋅ λ 2 + 18⋅  3 − 1 ⋅ 6 2  ⋅ λ 2 − 15⋅  3 − 1 ⋅ 6 2  ⋅ λ 2 
 5 20  2   5 10   5 10   

(c) 2009 Delta Computer Systems, Inc. 13/34 4/30/2013 11:10 AM


DC Motor Speed Control

Calculate numerical values for the outer loop gains

λ = 18.849556 Three Inner loop poles at −λ


Enable to override optimum
µ := 0.45⋅ λ
outer loop gains.

µ = 6.692554 Three Outer loop poles at -µ

 2
3 λ − 3⋅ µ⋅ λ + 2⋅ µ
2 
 3⋅ µ ⋅ 
 λ
3 
 
 2
2 5 ⋅ µ − 8 ⋅ µ ⋅ λ + 3⋅ λ
2 
 3⋅ µ ⋅ 
 o
Ki  λ
3

   
3 2 3 2
 Kpo   10⋅ µ − 18⋅ µ ⋅ λ − λ + 9 ⋅ µ ⋅ λ 
  :=  3 
 Kdo   λ 
 α   1
   
 β  3 3 1  2
2
2 
 2 ⋅ λ − 2 ⋅ µ − 2 ⋅ ( −3) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ  
 
 1
3 3 1  2 2
2
 ⋅ λ − ⋅ µ + ⋅ ( −3 ) ⋅ λ + 18⋅ µ ⋅ λ − 15⋅ µ  
2 2 2 
 Kio   8.92003 
 
 Kpo   5.630862 
  = 0.373939
 Kdo   
 α  6.692554 
   29.778451 

 β 

α is the same as µ so there are four outer loop poles at µ and one at β. The pole at β is always
farther to the left so it doesn't affect the response much.

(c) 2009 Delta Computer Systems, Inc. 14/34 4/30/2013 11:10 AM


DC Motor Speed Control

The DC Motor Velocity Model in State Space

0 1 0 
   0 
0 −b K  0 1 0  0 
Ac = 0 −10 1 
 B c :=   Bc =  0 
0
Ac :=  J J 
  1   
 R  0 −0.02 −2  2 
K
0 −L −   L 
 L

I := identity( 3 )

Calculate arrays for use in discrete time.


 Ac⋅ Τ ) 
7
(Ac⋅ Τ )n 
7
( n
⋅B ⋅Τ
A := I +
∑ n!
B := I +
 ∑
( n + 1 )!  c
n =1  n =1 

 1 0.000995 4.980052 × 10− 7   3.323354 × 10− 10 


   
A =  0 0.99005 0.000994  B= −7 
9.960103 × 10
 0 −0.00002   
 0.998002   0.001998 

(c) 2009 Delta Computer Systems, Inc. 15/34 4/30/2013 11:10 AM


DC Motor Speed Control

Cascade Control
The Cascaded loop controller and system simulator.
An outer loop closed loop generates a reference velocity. The inner loop tries to
follow the velocity generated by the outer loop.
Note the outer and inner loop is really using I-PD control where only the integrator
term is in the forward path. This makes the inner loop less susceptible to the
noise in the set point from the outer loop.
The second line computes the control output using the error between velocity
generated from the outer loop and the feed back or estimated velocity. The control
output is limited to -10 to +10 volts
10
N := n := 0 .. N Simulate 10
Τ seconds
r := x if n < 0.01⋅ N Calculate the target positions
n 0
and velocities. In this case
 0.2  the target velocities are 0
  if 0.01⋅ N ≤ n ∧ n < 0.2⋅ N since that target positions are
0 
changing only in step jumps.
 0.1  if 0.2⋅ N ≤ n ∧ n < 0.4⋅ N
 
0 
 0.05  if 0.4⋅ N ≤ n ∧ n < 0.65⋅ N
 
 0 
 0.35  otherwise
 
 0 

(c) 2009 Delta Computer Systems, Inc. 16/34 4/30/2013 11:10 AM


DC Motor Speed Control

0 
Cascade( r) := x ←  0 
0  
0 
v ←0
0
vi ← 0

u ←0
0
ui ← 0

for n ∈ 0 .. N − 1
x ← A⋅ x + B⋅ u
n+ 1 n n

 Kdo 
vpd ← −Kpo ⋅ x

n+ 1
0
(
+ ) ( ) − (xn)0
Τ  n+ 1 0
⋅ x

vi ← maxminvi + Kio ⋅ Τ ⋅ ( r ) − ( x )  , 1.0 − vpd , −1.0 − vpd


   n+1 0 n+ 1
0  
v ← vi + vpd
n+ 1

 Kdi 
u pd ← −Kpi ⋅ x

( n+1)1 + ( ) − (xn)1
Τ  n+ 1 1
⋅ x

u i ← maxminu i + Kii ⋅ Τ ⋅ v − ( x )  , 10 − u pd , −10 − u pd


   n+1 n+ 1 1
  
u ← u i + u pd
n+ 1

x 
u 
 
v 

x 
 u  := Cascade( r) Compute the system response
  and control output
v 

(c) 2009 Delta Computer Systems, Inc. 17/34 4/30/2013 11:10 AM


DC Motor Speed Control

Verify By Simulating and Graphing the Results.

Outer Loop Control

0.35 0.5

0.3 0.4
Target and Actual Position

0.25 0.3

Inner Target Velocity


0.2 0.2

0.15 0.1

0.1 0

0.05 0.1

0 0.2
0 2 4 6 8 10

Time
Target Position
Actual Position
Inner Target Velocity

K = 0.01 J = 0.01 R=1 L = 0.5 Motor

λ = 18.849556 Kii = 3348.677881 Kpi = 522.948638 Kdi = 22.274334 Inner Loop

µ = 6.692554 Kio = 8.92003 Kpo = 5.630862 Kdo = 0.373939 Outer Loop

(c) 2009 Delta Computer Systems, Inc. 18/34 4/30/2013 11:10 AM


DC Motor Speed Control

Inner Loop Control


10

0.5

0.4 5
Innter Target and Actual Velocity

0.3

Control Output, volts


0.2 0

0.1

0 5

0.1

0.2 10
0 2 4 6 8 10

Time
Inner Target Velocity
Actual Velocity
Control Output
Motor Current

K = 0.01 J = 0.01 R=1 L = 0.5 Motor

λ = 18.849556 Kii = 3348.677881 Kpi = 522.948638 Kdi = 22.274334 Inner Loop

µ = 6.692554 Kio = 8.92003 Kpo = 5.630862 Kdo = 0.373939 Outer Loop

(c) 2009 Delta Computer Systems, Inc. 19/34 4/30/2013 11:10 AM


DC Motor Speed Control

Cascade Control of a Type 1 Single Pole System Following a Sine Wave


Amp := 0.5 Hz := 0.25 Amplitude and frequency of
target generator.
Initial state of position and velocity

 Amp⋅ sin( 2⋅ π ⋅ Hz⋅ n ⋅ Τ ) 


r :=   Sinusoidal motion generator.
n
 2⋅ π ⋅ Hz⋅ Amp⋅ cos( 2 ⋅ π ⋅ Hz⋅ n⋅ Τ )  Generates target position, velocity
and acceleration.
x 
 u  := Cascade( r) Compute the system response
  and control output
v 
Outer Loop Control
0.6 0.8

0.6
0.4

0.4

0.2
Target and Actual Position

0.2

Inner Target Velocity


0 0

0.2
0.2

0.4

0.4
0.6

0.6 0.8
0 2 4 6 8 10

Time
Target Position
Actual Position
Output Velocity

(c) 2009 Delta Computer Systems, Inc. 20/34 4/30/2013 11:10 AM


DC Motor Speed Control

Inner Loop Control


0.8 10

0.6

0.4 5
Inner Target and Actual Velocity

0.2

Control Output, volts


0 0

0.2

0.4 5

0.6

0.8 10
0 2 4 6 8 10

Time
Inner Target Velocity
Actual Velocity
Control Output
Motor Current

K = 0.01 J = 0.01 R=1 L = 0.5 Actuator

λ = 18.849556 Kii = 3348.677881 Kpi = 522.948638 Kdi = 22.274334 Inner Loop

µ = 6.692554 Kio = 8.92003 Kpo = 5.630862 Kdo = 0.373939 Outer Loop

(c) 2009 Delta Computer Systems, Inc. 21/34 4/30/2013 11:10 AM


DC Motor Speed Control

Calculate Bandwidths

Calculate Inner Loop Bandwidth


 Kii  K
 ⋅
 j ⋅ ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R + K2
f( ω) :=
 Kii 
+ Kpi + Kdi ⋅ ( j ⋅ ω) ⋅
K
1+
j ⋅ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R + K2

ωi := 0.7⋅ λ ωi = 13.194689 The initial guess for the inner


loop bandwidth
ωi := root f ωi −
( ) , ωi
1
ωi = 9.609966 Inner loop bandwidth in radians
 2  per second

ωi
= 1.529474 Inner loop bandwidth in Hz
2⋅ π

Calculate Outer Loop Bandwidth


 Kii  K
 ⋅
 Kio  1  j ⋅ ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R + K2
 ⋅ ⋅
 j ⋅ω  j ⋅ω  Kii 
+ Kpi + Kdi ⋅ ( j ⋅ ω) ⋅
K
1+
j ⋅ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R + K2
f( ω) :=
 Kii  K
 ⋅
 Kio  1  j ⋅ ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R + K2
1+ + Kpo + Kdo ⋅ ( j ⋅ ω) ⋅ ⋅
 j ⋅ω  j ⋅ω  Kii 
+ Kpi + Kdi ⋅ ( j ⋅ ω) ⋅
K
1+
j ⋅ω  J⋅ ( j ⋅ ω) + b ⋅ L⋅ ( j ⋅ ω) + R +

ωo := 0.2λ ωo = 3.769911 Initial guess for the outer loop


band width
ωo := root f ωo −
( ) , ωo  ωo = 2.889634
1
Outer loop bandwidth in
 2  radians per second

ωo outer loop bandwidth in Hz


= 0.459899
2⋅ π

ωi Ratio of the inner loop to outer


= 3.325669 loop bandwidth. This ratio is
ωo fixed

(c) 2009 Delta Computer Systems, Inc. 22/34 4/30/2013 11:10 AM


DC Motor Speed Control

Inner Loop Bode Plot Calculations


 Kii  K Kpi and Kd i are in the feed
 ⋅ back path only. This makes
 s  ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2
T( s) := the inner loop less susceptible
 Kii  K to the noisy target velocities
1+ + Kpi + Kdi ⋅ s ⋅ generated by the outer loop.
 s  ( J⋅ s + b ) ⋅ ( L⋅ s + R) + K2
n := 0 .. 320 Iterate the frequency from .01 HZ
to 1000 HZ using 64 steps per
n decade for a total of 320
−2 iterations.
64
hz := 10
n

 Mn 
:= r ← Tj ⋅ ( 2 ⋅ π ) ⋅ hz 
 φn   n
 
arg( r)
a← Closed loop magnitude and phase
deg as a function of frequency
a ← a − 360 if n > 0 ∧ a − φ n− 1 > 100

 20⋅ log( r ) 
 
 a 

Inner Closed Loop Bode Plot


0 0

50
100
Phase deg
Gain db

100

200
150

200 300
1 .10
3
0.01 0.1 1 10 100

Frequency Hz
Gain
Phase

(c) 2009 Delta Computer Systems, Inc. 23/34 4/30/2013 11:10 AM


DC Motor Speed Control

Outer Loop Bode Plot Calculations


3
 Kio  λ
 ⋅ The outer loop gains are in the
 s  s⋅ ( s + λ ) 3 forward and feedback path. This
T( s) := help makes the outer loop faster
3
 Kio  λ than the inner loop.
1+ + Kpo + Kdo ⋅ s ⋅
 s  s⋅ ( s + λ ) 3

n := 0 .. 320 Iterate the frequency from .01 HZ


to 1000 HZ using 64 steps per
n decade for a total of 320
−2 iterations.
64
hz := 10
n

 Mn 
:= r ← Tj ⋅ ( 2 ⋅ π ) ⋅ hz 
 φn   n
 
arg( r)
a← Closed loop magnitude and phase
deg as a function of frequency
a ← a − 360 if n > 0 ∧ a − φ n− 1 > 100

 20⋅ log( r ) 
 
 a 

Outer Closed Loop Bode Plot


0 0

100

100
200
Phase deg
Gain db

300
200

400

300 500
1 .10
3
0.01 0.1 1 10 100

Frequency Hz
Gain
Phase

(c) 2009 Delta Computer Systems, Inc. 24/34 4/30/2013 11:10 AM


DC Motor Speed Control

Graph the Outer Loop Poles and Zeros


λ = 18.849556 Kii = 3348.677881 Kpi = 522.948638 Kdi = 22.274334

µ = 6.692554 Kio = 8.92003 Kpo = 5.630862 Kdo = 0.373939

Ti ( s) :=
(Ki + Kp⋅s + Kd⋅s2)⋅K simplify
(
→ Ki + Kp⋅ s + Kd
3 2 2 2 2 explicit
J⋅ s ⋅ L + J⋅ s ⋅ R + b ⋅ L⋅ s + s⋅ b ⋅ R + s⋅ K + K⋅ Ki + K⋅ Kp⋅ s + K⋅ Kd⋅ s
 Ki + Kp ⋅ s + Kd ⋅ s2 ⋅ K
 Kio  1  i i i 
 ⋅ ⋅
 s  s J⋅ s3⋅ L + J⋅ R + b ⋅ L + K⋅ Kd ⋅ s2 +  K2 + K⋅ Kp + b ⋅ R ⋅ s + K⋅ Ki
( i)  i  i
To ( s) :=
 Ki + Kp ⋅ s + Kd ⋅ s  ⋅ K
2
 Kio  1  i i i 
1+ + Kpo + Kdo ⋅ s ⋅ ⋅
 s  s J⋅ s3⋅ L + J⋅ R + b ⋅ L + K⋅ Kd ⋅ s2 +  K2 + K⋅ Kp + b ⋅ R ⋅ s + K⋅ Ki
( i)  i 
 33.48679 
 
coeffs , s
Ai := denom ( Ti ( s) ) →  5.329588 
float , 7  .2827434 
 .5e-2 
 
 ( −.840693 ) ⋅ λ
5 
 
 5 4 
 ( −.1312876 ) ⋅ λ − 10.00339⋅ λ 
 4 5 3
coeffs , s ( −1.562186) ⋅ λ − .559203e-2⋅ λ − 46.00881⋅ λ 
Ao := denom ( To ( s) ) →
float , 7  3 4 
 ( −7.285097) ⋅ λ − .6653937e-1 ⋅ λ 
 3 
( −.3660357) ⋅ λ
 
 3 
 ( −.5e-2) ⋅ λ 
 ( −.84070) ⋅ λ 5 
 
coeffs , s
B o := numer( To ( s) ) → ( −.131287 ) ⋅ λ 5 

float , 6  
 5
( −.559199e-2) ⋅ λ 

poles i := polyroots Ai ( ) ( )
poles o := polyroots Ao

 −38.497281 
 −15.302026 − 2.312133i 
 −18.862727   
poles i =  −18.845535  poles o =  −15.302026 + 2.312133i 
 
 −18.840418   −2.052903 + 1.505003i 
 
 −2.052903 − 1.505003i 

(c) 2009 Delta Computer Systems, Inc. 25/34 4/30/2013 11:10 AM


DC Motor Speed Control

S Plane
20
Imaginary Axis

20 0 20

20

Real Axis
Inner Loop Poles
Outer Loop Poles

K = 0.01 J = 0.01 R=1 L = 0.5 Motor

λ = 18.849556 Kii = 3348.677881 Kpi = 522.948638 Kdi = 22.274334 Inner Loop

µ = 6.692554 Kio = 8.92003 Kpo = 5.630862 Kdo = 0.373939 Outer Loop

(c) 2009 Delta Computer Systems, Inc. 26/34 4/30/2013 11:10 AM


DC Motor Speed Control

1
3
10⋅ µ − 9 ⋅ µ ⋅ λ
2 ) −3 3 1
⋅ ( −15) ⋅ µ + 18⋅ µ ⋅ λ − 3 ⋅ λ
2 2
2
−3 3 1
⋅ ( −15) ⋅ µ + 18⋅ µ ⋅ λ − 3
2
⋅µ + ⋅λ −  ⋅µ + ⋅λ +
2 2 2 2 2 2

1
3
10⋅ µ − 9 ⋅ µ ⋅ λ
2 ) −3 3 1
⋅ ( −15) ⋅ µ + 18⋅ µ ⋅ λ − 3 ⋅ λ
2 2
2
−3 3 1
⋅ ( −15) ⋅ µ + 18⋅ µ ⋅ λ − 3⋅
2
⋅µ + ⋅λ +  ⋅µ + ⋅λ −
2 2 2 2 2 2

(c) 2009 Delta Computer Systems, Inc. 27/34 4/30/2013 11:10 AM


DC Motor Speed Control

 1 
3
1 
2 
  
1   
 3 1 2  −4 3 2  3 1 2 2
 3⋅  − ⋅6  ⋅  + ⋅ 6 + 2⋅  − ⋅6  ⋅λ 
  5 10   5 10  5 10   
 
1   1
2 2
  1 
  3 1 2    3 1 2  9 4 2 
 3⋅  − ⋅ 6  ⋅ 5 ⋅  − ⋅6  − + ⋅6 ⋅λ 
 5 10    5 10  5 5 
 
  1 
3
 1 
2
1 
  3 1 2  3 1 2 22 9 2 
 10⋅  − ⋅ 6  − 18⋅  − ⋅6  + − ⋅6 
  5 10   5 10  5 10 
 1
 2
 1   1   1 
2  
 3 3    3 1 2 2  3 1 2  2 
1 
 + ⋅ 6  ⋅ λ − ⋅ ( −3) ⋅ λ + 18⋅  − ⋅ 6  ⋅ λ − 15⋅  − ⋅ 6  ⋅ λ  
2 2

 5 20  2   5 10   5 10   
 1
 2
 1  2  
  1  1

3 3 2 1   3 1 2 2  3 1 2  2 
 + ⋅ 6  ⋅ λ + ⋅ ( −3 ) ⋅ λ + 18⋅  − ⋅ 6  ⋅ λ − 15⋅  − ⋅ 6  ⋅ λ  
2
 5 20  2   5 10   5 10   

(c) 2009 Delta Computer Systems, Inc. 28/34 4/30/2013 11:10 AM


DC Motor Speed Control

(c) 2009 Delta Computer Systems, Inc. 29/34 4/30/2013 11:10 AM


DC Motor Speed Control

2
K

(c) 2009 Delta Computer Systems, Inc. 30/34 4/30/2013 11:10 AM


DC Motor Speed Control

)
2
Kd⋅ s ⋅
3 2 2
K
2 2
J⋅ s ⋅ L + J⋅ s ⋅ R + b ⋅ L⋅ s + s⋅ b ⋅ R + s⋅ K + K⋅ Ki + K⋅ Kp⋅ s + K⋅ Kd⋅ s

simplify

collect , s → K⋅  Kii + Kpi ⋅ s + Kdi ⋅ s
2
⋅
s ⋅ J⋅ L + K⋅ Kdi + J⋅ R + b ⋅ L + K⋅ Kdo ⋅ Kdi ⋅ s +  K⋅ Kdo ⋅ Kpi + K
( )
5 4
explicit 
Kii

(c) 2009 Delta Computer Systems, Inc. 31/34 4/30/2013 11:10 AM


DC Motor Speed Control

1
2

2
⋅λ  

1
2
2 
⋅λ 

(c) 2009 Delta Computer Systems, Inc. 32/34 4/30/2013 11:10 AM


DC Motor Speed Control

Kio

K⋅ Kpo ⋅ Kdi + K⋅ Kpi + b ⋅ R + K  ⋅ s + K⋅ Kio ⋅ Kdi + K⋅ Kpo ⋅ Kpi + K⋅ Kdo ⋅ Kii + K⋅ Kii ⋅ s + K⋅ Kio ⋅ Kpi + K
( ) (
2 3 2

(c) 2009 Delta Computer Systems, Inc. 33/34 4/30/2013 11:10 AM


DC Motor Speed Control

)
K⋅ Kpo ⋅ Kii ⋅ s + K⋅ Kio ⋅ Kii

(c) 2009 Delta Computer Systems, Inc. 34/34 4/30/2013 11:10 AM

You might also like