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

Add missing sysfilter functions

parent 48557a1a
julia 0.6
ControlSystems
......@@ -8,7 +8,6 @@ Perform control experiemnt where the feedback and feedforward controllers are gi
`reference` is a reference generating function that accepts a scalar `t` (time in seconds) and outputs a scalar `r`, default is `reference(t) = sign(sin(2π*t))`.
The outputs `y,u,r` are the beam angle, control signal and reference respectively.
"""
function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10, reference = t->sign(sin(2π*t)))
h = sampletime(P)
......
export periodically
export periodically, init_sysfilter, sysfilter!
"""
@periodically(h, body)
......@@ -12,3 +12,23 @@ macro periodically(h, body)
sleep(max(0,$h-execution_time))
end
end
"""
state = init_sysfilter(sys::StateSpace)
Use together with [`sysfilter!`](@ref)
"""
function init_sysfilter(sys::StateSpace)
zeros(sys.nx,1)
end
"""
output = sysfilter!(state, sys::StateSpace, input)
Returns the filtered output `y` in `y = Cx+Du, x'=Ax+Bu`
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)`. Initialize `state` using [`init_sysfilter`](@ref).
"""
function sysfilter!(state, sys::StateSpace, input)
state .= sys.A*state + sys.B*input
output = sys.C*state + sys.D*input
end
Markdown is supported
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