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

Merge branch 'master' of gitlab.control.lth.se:processes/BallAndBeam.jl

parents 2706ae6c 9c6b958e
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ using LabProcesses, Plots, Polynomials, ControlSystems, ProgressMeter
run_experiment(P::BallAndBeamType, ω, duration, settling_time, amplitude, bias)
Perform fra-experiemnt For a single frequency `ω`. Called from inside `fra`
"""
function run_experiment(P::BallAndBeamType, ω, duration, settling_time, amplitude, bias)
function run_experiment(P::BeamType, ω, duration, settling_time, amplitude, bias)
h = sampletime(P)
data = zeros(0:h:duration)
LabProcesses.initialize(P)
......@@ -63,7 +63,7 @@ integrate(fun,data,ω,h) = h*sum(fun(ω*(i-1)*h).*data[i] for i = 1:length(data)
- `nbr_of_periods = 10`:
- `amplitude = 1`: Very low freqs might require smaller amplitude
"""
function fra(P::BallAndBeamType, Ω::AbstractVector;
function fra(P::BeamType, Ω::AbstractVector;
bias = 0,
settling_time = 2,
nbr_of_periods = 10,
......
using BallAndBeam, LabProcesses, ControlSystems, JLD
# @load "workspace.jld" # Run this command to restore a saved workspace
bias = 0 # Change this if your process drifts over time
P = LabProcesses.BallAndBeam(0.01, bias)
bias = 0.01 # Change this if your process drifts over time
P = LabProcesses.Beam(0.01, bias)
h = sampletime(P)
settling_time = 1
......@@ -27,25 +27,25 @@ G3 = fra(P, w1_300, amplitude=2, bias=bias, nbr_of_periods=nbr_of_periods, s
# Concatenate (overlapping) estimates to be used and sort based on freq
G123 = sortfqs([G1; G2; G3])
bopl(G123)
bopl(G123, m=:star)
nypl(G123)
## Control ==================================================================================
# polevect = [-10]
# zerovect = []
# gain = 1
# sysFBc,L,T,C = fbdesign(G, polevect, zerovect, gain)
# polevect = [-10]
# zerovect = []
# gain = 1
# sysFFc,YR,FF = ffdesign(T, polevect, zerovect, gain)
# bopl(C, lab="Controller")
# bopl!(L, lab="Closed-loop system e->y")
# bopl!(FF, lab="Feedforward compensator")
# bopl!(YR, lab="Closed-loop system r->y")
# sysFB,sysFF = c2d(sysFBc,h)[1],c2d(sysFFc,h)[1]
# y,u,r = run_control_2DOF(P, sysFB, sysFF, duration=5, reference = t->2sign(sin(2π/3*t)))
# plot([y u r], lab = ["y" "u" "r"])
polevect = [-10]
zerovect = []
gain = 1
sysFBc,L,T,C = fbdesign(G, polevect, zerovect, gain)
polevect = [-10]
zerovect = []
gain = 1
sysFFc,YR,FF = ffdesign(T, polevect, zerovect, gain)
bopl(C, lab="Controller")
bopl!(L, lab="Closed-loop system e->y")
bopl!(FF, lab="Feedforward compensator")
bopl!(YR, lab="Closed-loop system r->y")
sysFB,sysFF = c2d(sysFBc,h)[1],c2d(sysFFc,h)[1]
y,u,r = run_control_2DOF(P, sysFB, sysFF, duration=5, reference = t->2sign(sin(2π/3*t)))
plot([y u r], lab = ["y" "u" "r"])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment