Commit a38c1b06 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Update README

parent 44083893
...@@ -54,7 +54,7 @@ for (i,t) = enumerate(0:h:duration) ...@@ -54,7 +54,7 @@ for (i,t) = enumerate(0:h:duration)
@periodically h begin @periodically h begin
y[i] = measure(P) y[i] = measure(P)
r[i] = reference(t) r[i] = reference(t)
u[i] = control(i) u[i] = calc_control(i,y,r)
control(P, u[i]) control(P, u[i])
end end
end end
...@@ -64,13 +64,17 @@ Often one finds the need to implement a stateful controller, i.e., a function ...@@ -64,13 +64,17 @@ Often one finds the need to implement a stateful controller, i.e., a function
that has a memory or state. To this end, the function [`sysfilter`](@ref) is that has a memory or state. To this end, the function [`sysfilter`](@ref) is
provided. This function is used to implement control loops where a signal is provided. This function is used to implement control loops where a signal is
filtered through a dynamical system, i.e., `U(z) = C(z)E(z)`. filtered through a dynamical system, i.e., `U(z) = C(z)E(z)`.
Usage is demonstrated below Usage is demonstrated below, which is a simplified implementation of the block
diagram above (transfer function- and signal names corresponds to the figure).
```julia ```julia
stateC = init_sysfilter(C) stateG1 = init_sysfilter(G1)
stateG4 = init_sysfilter(G4)
function control(i) function control(i)
e = r[i]-y[i] rf = sysfilter!(stateG4, G4, r)
u = sysfilter!(stateC, C, e) e = rf-y
u = sysfilter!(stateG1, G1, e)
end end
``` ```
`C` must here be represented by a [`StateSpace`](http://juliacontrol.github.io/ControlSystems.jl/latest/lib/constructors/#ControlSystems.ss) type from [`ControlSystems.jl`](https://github.com/JuliaControl/ControlSystems.jl). `G1` and `G4` must here be represented by [`StateSpace`](http://juliacontrol.github.io/ControlSystems.jl/latest/lib/constructors/#ControlSystems.ss) types from [`ControlSystems.jl`](https://github.com/JuliaControl/ControlSystems.jl).
`TransferFunction` types can easily be converted to a `StateSpace` by `Gss = ss(Gtf)`. `TransferFunction` types can easily be converted to a `StateSpace` by `Gss = ss(Gtf)`.
Continuous time systems can be discretized using `Gd = c2d(Gc, h)`. (The sample time of a process is available through `h = sampletime(P)`.)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment