Skip to content
Snippets Groups Projects
Commit 585f2bdd authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Clean up

parent 68c9f837
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -16,7 +16,7 @@ module BallAndBeam ...@@ -16,7 +16,7 @@ module BallAndBeam
export run_experiment, fra, sortfqs, export run_experiment, fra, sortfqs,
bopl, bopl!, nypl, nypl!, plot, fbdesign, ffdesign, opendoc bopl, bopl!, nypl, nypl!, plot, fbdesign, ffdesign, opendoc
export SysFilter, init_sysfilter, sysfilter!, run_control_2DOF # For documentation export SysFilter, run_control_2DOF # For documentation
using LabProcesses, Plots, Polynomials, ControlSystems, ProgressMeter using LabProcesses, Plots, Polynomials, ControlSystems, ProgressMeter
...@@ -139,7 +139,7 @@ nypl(G; kwargs...) = (plot();nypl!(G;kwargs...)) ...@@ -139,7 +139,7 @@ nypl(G; kwargs...) = (plot();nypl!(G;kwargs...))
sysFB,L,T,C = fbdesign(G::AbstractMatrix, polevect, zerovect, gain) sysFB,L,T,C = fbdesign(G::AbstractMatrix, polevect, zerovect, gain)
Frequency Compensation to determine polynominals in compensator C=S/R. Frequency Compensation to determine polynominals in compensator C=S/R.
Frequency responses for loop transfer, closed loop and controller are calculated. Frequency responses for loop transfer, closed loop and controller are calculated.
`sys` is of type `StateSpace`, to be used together with [`sysfilter!`](@ref) `sys` is of type `StateSpace`, to be used together with [`SysFilter!`](@ref)
`G` is a frequency response matrix with ω in the first column and G(iω) in the second. `G` is a frequency response matrix with ω in the first column and G(iω) in the second.
""" """
function fbdesign(G::AbstractMatrix, polevect, zerovect, gain) function fbdesign(G::AbstractMatrix, polevect, zerovect, gain)
...@@ -156,7 +156,7 @@ end ...@@ -156,7 +156,7 @@ end
sysFF,YR,FF = ffdesign(G, polevect, zerovect, gain) sysFF,YR,FF = ffdesign(G, polevect, zerovect, gain)
Feedforward filter BFF/AFF to shape transfer function from `r` to `y`. Feedforward filter BFF/AFF to shape transfer function from `r` to `y`.
Frequency responses for closed loop with FF-filter and FF-filter are calculated. Frequency responses for closed loop with FF-filter and FF-filter are calculated.
`sys` is of type `StateSpace`, to be used together with [`sysfilter!`](@ref) `sys` is of type `StateSpace`, to be used together with [`SysFilter!`](@ref)
""" """
function ffdesign(G, polevect, zerovect, gain) function ffdesign(G, polevect, zerovect, gain)
sysFF,YR,_,FF = fbdesign(G, polevect, zerovect, gain) sysFF,YR,_,FF = fbdesign(G, polevect, zerovect, gain)
...@@ -179,24 +179,13 @@ function opendoc() ...@@ -179,24 +179,13 @@ function opendoc()
run(`xdg-open $docpath`) run(`xdg-open $docpath`)
end end
"""
state = init_sysfilter(sys::StateSpace)
Use together with [`sysfilter!`](@ref)
"""
init_sysfilter
"""
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).
"""
sysfilter!
""" """
sf = SysFilter(sys::StateSpace) Csf = SysFilter(sys::StateSpace)
Create a SysFilter object that can be used to implement control loops and simulators with LTI systems, i.e., `U(z) = C(z)E(z)`. See [`sysfilter!`](@ref) for usage. Returns an object used for filtering signals through LTI systems.
Create a SysFilter object that can be used to implement control loops and simulators
with LTI systems, i.e., `U(z) = C(z)E(z)`. To filter a signal `u` through the filter,
call like `y = Csf(u)`. Calculates the filtered output `y` in `y = Cx+Du, x'=Ax+Bu`
""" """
SysFilter SysFilter
......
...@@ -86,10 +86,8 @@ function arx(h,y::AbstractVector{Float64}, u::AbstractVector{Float64}, na, nb; ...@@ -86,10 +86,8 @@ function arx(h,y::AbstractVector{Float64}, u::AbstractVector{Float64}, na, nb;
if λ == 0 if λ == 0
w = A\y_train w = A\y_train
method = :LS
else else
w = (A'A + λ*eye(size(A,2)))\A'y_train w = (A'A + λ*eye(size(A,2)))\A'y_train
method = :LS_reg
end end
a = [1; -w[1:na]] a = [1; -w[1:na]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment