PD control  (stable, linear system)

Differential equation

Define simple second-order differential equation with input f

diffeq = m  x''[t] + b  x '[t] + k  x[t] == f ;

Display differential equation

diffeq // TraditionalForm

k x(t) + b x^′(t) + m x^′′(t) f

Numeric system values

The values below are exact, because of numeric instability in DSolve[ ]. Use NDSolve[ ] for non-exact values.

vals = {m->1, b1, k1, x01, dx00} ;

Zero control (f = 0)

Control input

control = {f0} ;

Damping ratio and natural frequency

{ζ, ω} /. {ζs, ωs} /. vals

{1/2, 1}

Corresponding roots

roots /. vals

{1/2 (-1 -  3^(1/2)), 1/2 (-1 +  3^(1/2))}

Differential equation solution

fx = ProcessDSolve[{diffeq, initCond} /. vals /. control // N] ; x[t] == fx // TraditionalForm

FormBox[RowBox[{x(t), , RowBox[{RowBox[{1.,  , RowBox[{, ^, RowBox[{(, RowBox[ ... {-, 0.5}],  , t}], )}]}],  , RowBox[{sin, (, RowBox[{0.866025,  , t}], )}]}]}]}], TraditionalForm]

Plot length

RowBox[{RowBox[{tmax,  , =,  , 10.}], ;}]

Plot solution

g1 = Plot[fx, {t, 0, tmax}, PlotStyleBlue, FrameTrue, PlotRangeAll] ;

[Graphics:../HTMLFiles/index_95.gif]

PD control (f = -k_px - k_vOverscript[x, .])

Control input

control = {f -kp x[t] - kv x '[t]} ;

Corresponding controlled system

controlledSystem = diffeq /. control ;

Display controlled system equation

controlledSystem // TraditionalForm

k x(t) + b x^′(t) + m x^′′(t)  -kp x(t) - kv x^′(t)

controlledSystem = controlledSystem // Simplify ; controlledSystem // TraditionalForm

(k + kp) x(t) + (b + kv) x^′(t) + m x^′′(t) 0

Desired controlled system characteristics

The values below are exact, because of numeric instability in DSolve[ ]. Use NDSolve[ ] for non-exact values.

desiredCharacteristics = {ω4, ζ1} ;

Computation of gain values for characteristic equation s^2 + 2ζsω + ω^2 = 0

eqs = {ω (ω/.ωs), ζ  (ζ/.ζs)} ; eqs2 = eqs /. {k (k + kp), b (b + kv)} ; eqs2 // TraditionalForm

{ω (k + kp)^(1/2)/m^(1/2), ζ (b + kv)/(2 (k + kp)^(1/2) m^(1/2))}

gainsSymbolic = Solve[eqs2, {kp, kv}] // Flatten

{kv -b + 2 m ζ ω, kp -k + m ω^2}

gains = gainsSymbolic /. vals /.desiredCharacteristics

{kv7, kp15}

Controlled system roots

controlledCharEq = DiffEqToCharEq[controlledSystem] ; controlledRoots = (s/.#) & /@ Solve[controlledCharEq, s] ;

Display controlled system roots

controlledRoots /. vals /. gains

{-4, -4}

Differential equation solution

fx = ProcessDSolve[{controlledSystem, initCond} /. vals /. gains] ; x[t] == fx // TraditionalForm

x(t) 4 ^(-4 t) t + ^(-4 t)

Plot length

RowBox[{RowBox[{tmax,  , =,  , 10.}], ;}]

Plot solution

g2 = Plot[fx, {t, 0, tmax}, PlotStyleRed, FrameTrue, PlotRangeAll] ;

[Graphics:../HTMLFiles/index_118.gif]

Compare to unforced system

Show[g1, g2] ;

[Graphics:../HTMLFiles/index_120.gif]

Control f

dfx = D[fx, t] ; fn = f /. control /. gains/. {x[t] fx, x '[t] dfx} ; fn // TraditionalForm

112 ^(-4 t) t - 15 (4 ^(-4 t) t + ^(-4 t))

Plot[fn, {t, 0, tmax}, PlotStyleMagenta, FrameTrue, PlotRangeAll] ;

[Graphics:../HTMLFiles/index_125.gif]

Root locus plot

kpRange = {kp, 15, 15, 1} ; kvRange = {kv, 0, 20} ;

g3 = GainLines[controlledRoots /. vals, kpRange, kvRange, DisplayFunctionIdentity, Plo ... tRangeAll] ; Show[GraphicsArray[{{g3}, {g4}}], DisplayFunction$DisplayFunction] ;

[Graphics:../HTMLFiles/index_128.gif]


Created by Mathematica  (November 12, 2003)