Synthesis

# Synthesis

`S, P, B = balance(A[, perm=true])`

Compute a similarity transform `T` resulting in `B = T\A*T` such that the row and column norms of `B` are approximately equivalent. If `perm=false`, the transformation will only scale `A` using diagonal `S`, and not permute `A` (i.e., set `P=I`).

source

`care(A, B, Q, R)`

Compute 'X', the solution to the continuous-time algebraic Riccati equation, defined as A'X + XA - (XB)R^-1(B'X) + Q = 0, where R is non-singular.

Algorithm taken from: Laub, "A Schur Method for Solving Algebraic Riccati Equations." http://dspace.mit.edu/bitstream/handle/1721.1/1301/R-0859-05666488.pdf

source

DAB Solves the Diophantine-Aryabhatta-Bezout identity

`X,Y = DAB(A,B,C)`

AX + BY = C, where A, B, C, X and Y are polynomials and deg Y = deg A - 1.

See Computer-Controlled Systems: Theory and Design, Third Edition Karl Johan Åström, Björn Wittenmark

source

`dare(A, B, Q, R)`

Compute `X`, the solution to the discrete-time algebraic Riccati equation, defined as A'XA - X - (A'XB)(B'XB + R)^-1(B'XA) + Q = 0, where A and R are non-singular.

Algorithm taken from: Laub, "A Schur Method for Solving Algebraic Riccati Equations." http://dspace.mit.edu/bitstream/handle/1721.1/1301/R-0859-05666488.pdf

source

`dkalman(A, C, R1, R2)` kalman(sys, R1, R2)`

Calculate the optimal Kalman gain for discrete time systems

source

`dlqr(A, B, Q, R)`, `dlqr(sys, Q, R)`

Calculate the optimal gain matrix `K` for the state-feedback law `u[k] = K*x[k]` that minimizes the cost function:

J = sum(x'Qx + u'Ru, 0, inf).

For the discrte time model `x[k+1] = Ax[k] + Bu[k]`.

See also `lqg`

Usage example:

``````using LinearAlgebra # For identity matrix I
h = 0.1
A = [1 h; 0 1]
B = [0;1]
C = [1 0]
sys = ss(A,B,C,0, h)
Q = I
R = I
L = dlqr(A,B,Q,R) # lqr(sys,Q,R) can also be used

u(x,t) = -L*x # Form control law,
t=0:h:5
x0 = [1,0]
y, t, x, uout = lsim(sys,u,t,x0=x0)
plot(t,x, lab=["Position"  "Velocity"], xlabel="Time [s]")``````
source

`dlyap(A, Q)`

Compute the solution `X` to the discrete Lyapunov equation `AXA' - X + Q = 0`.

source

`kalman(A, C, R1, R2)` kalman(sys, R1, R2)`

Calculate the optimal Kalman gain

See also `LQG`

source

`laglink(a, M; h=0)`

Returns a phase retarding link, the rule of thumb `a = 0.1ωc` guarantees less than 6 degrees phase margin loss. The bode curve will go from `M`, bend down at `a/M` and level out at 1 for frequencies > `a`

source

`leadlink(b, N, K; h=0)`

Returns a phase advancing link, the top of the phase curve is located at `ω = b√(N)` where the link amplification is `K√(N)` The bode curve will go from `K`, bend up at `b` and level out at `KN` for frequencies > `bN`

The phase advance at `ω = b√(N)` can be plotted as a function of `N` with `leadlinkcurve()`

Values of `N < 1` will give a phase retarding link.

See also `leadlinkat` `laglink`

source

`leadlinkat(ω, N, K; h=0)`

Returns a phase advancing link, the top of the phase curve is located at `ω` where the link amplification is `K√(N)` The bode curve will go from `K`, bend up at `ω/√(N)` and level out at `KN` for frequencies > `ω√(N)`

The phase advance at `ω` can be plotted as a function of `N` with `leadlinkcurve()`

Values of `N < 1` will give a phase retarding link.

See also `leadlink` `laglink`

source

`kp,ki,C = loopshapingPI(P,ωp; ϕl,rl, phasemargin)`

Selects the parameters of a PI-controller such that the Nyquist curve of `P` at the frequency `ωp` is moved to `rl exp(i ϕl)`

If `phasemargin` is supplied, `ϕl` is selected such that the curve is moved to an angle of `phasemargin - 180` degrees

If no `rl` is given, the magnitude of the curve at `ωp` is kept the same and only the phase is affected, the same goes for `ϕl` if no phasemargin is given.

See also `pidplots`, `stabregionPID`

source

`lqr(A, B, Q, R)`

Calculate the optimal gain matrix `K` for the state-feedback law `u = K*x` that minimizes the cost function:

J = integral(x'Qx + u'Ru, 0, inf).

For the continuous time model `dx = Ax + Bu`.

`lqr(sys, Q, R)`

Solve the LQR problem for state-space system `sys`. Works for both discrete and continuous time systems.

See also `LQG`

Usage example:

``````using LinearAlgebra # For identity matrix I
A = [0 1; 0 0]
B = [0;1]
C = [1 0]
sys = ss(A,B,C,0)
Q = I
R = I
L = lqr(sys,Q,R)

u(x,t) = -L*x # Form control law,
t=0:0.1:5
x0 = [1,0]
y, t, x, uout = lsim(sys,u,t,x0=x0)
plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")``````
source

Calculates and returns a PID controller on transfer function form. `time` indicates whether or not the parameters are given as gains (default) or as time constants `series` indicates whether or not the series form or parallel form (default) is desired

`C = pid(; kp=0, ki=0; kd=0, time=false, series=false)`

source

`place(A, B, p)`, `place(sys::StateSpace, p)`

Calculate gain matrix `K` such that the poles of `(A-BK)` in are in `p`.

Uses Ackermann's formula.

source

Implements REDUCE in the Emami-Naeini & Van Dooren paper. Returns transformed A, B, C, D matrices. These are empty if there are no zeros.

source

See ?rstd for the discerte case

source

rstd Polynomial synthesis in discrete time.

`R,S,T=rstd(BPLUS,BMINUS,A,BM1,AM,AO,AR,AS)`

`R,S,T=rstd(BPLUS,BMINUS,A,BM1,AM,AO,AR)`

`R,S,T=rstd(BPLUS,BMINUS,A,BM1,AM,AO)`

Polynomial synthesis according to CCS ch 10 to design a controller R(q) u(k) = T(q) r(k) - S(q) y(k)

Inputs: BPLUS : Part of open loop numerator BMINUS : Part of open loop numerator A : Open loop denominator BM1 : Additional zeros AM : Closed loop denominator AO : Observer polynomial AR : Pre-specified factor of R, e.g integral part [1, -1]^k AS : Pre-specified factor of S, e.g notch filter [1, 0, w^2]

Outputs: R,S,T : Polynomials in controller

See function DAB how the solution to the Diophantine- Aryabhatta-Bezout identity is chosen.

See Computer-Controlled Systems: Theory and Design, Third Edition Karl Johan Åström, Björn Wittenmark

source