Skip to content

Commit 5f0fc84

Browse files
committed
simplify example code
1 parent 95dd9b2 commit 5f0fc84

File tree

2 files changed

+10
-34
lines changed

2 files changed

+10
-34
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
- uses: julia-actions/julia-runtest@v1
4343
# continue-on-error: ${{ matrix.version == 'nightly' }} # Allow nightly to fail and workflow still count as completed
4444
- uses: julia-actions/julia-processcoverage@v1
45-
if: ${{ matrix.version == '1' }}
45+
if: ${{ matrix.version == '1.7' }}
4646
- uses: codecov/codecov-action@v1
47-
if: ${{ matrix.version == '1' }}
47+
if: ${{ matrix.version == '1.7' }}
4848
with:
4949
file: lcov.info

docs/src/examples/example.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ By plotting the gang of four under unit feedback for the process
5151
```math
5252
P(s) = \dfrac{1}{(s + 1)^4}
5353
```
54-
```jldoctest PIDDESIGN; output = false
54+
```@example PIDDESIGN
55+
using ControlSystems, Plots
5556
P = tf(1,[1,1])^4
5657
gangoffourplot(P,tf(1))
57-
58-
save_docs_plot("pidgofplot.svg"); # hide
59-
60-
# output
61-
6258
```
63-
![](../../plots/pidgofplot.svg)
59+
6460

6561
we notice that the sensitivity function is a bit too high around frequencies ω = 0.8 rad/s. Since we want to control the process using a simple PI-controller, we utilize the
6662
function [`loopshapingPI`](@ref) and tell it that we want 60 degrees phase margin at this frequency. The resulting gang of four is plotted for both the constructed controller and for unit feedback.
@@ -69,38 +65,18 @@ function [`loopshapingPI`](@ref) and tell it that we want 60 degrees phase margi
6965
using ControlSystems, Plots
7066
P = tf(1,[1,1])^4
7167
ωp = 0.8
72-
C,kp,ki = loopshapingPI(P,ωp,phasemargin=60,form=:parallel)
73-
74-
p1 = gangoffourplot(P, [tf(1), C]);
75-
p2 = nyquistplot([P, P*C], ylims=(-1,1), xlims=(-1.5,1.5));
76-
77-
plot(p1,p2, layout=(2,1), size=(800,800))
68+
C,kp,ki,fig = loopshapingPI(P,ωp,phasemargin=60,form=:parallel, doplot=true)
69+
fig
7870
```
7971

80-
8172
We could also consider a situation where we want to create a closed-loop system with the bandwidth ω = 2 rad/s, in which case we would write something like
82-
```jldoctest PIDDESIGN; output = false
83-
using Plots
73+
```@example PIDDESIGN
8474
ωp = 2
85-
kp,ki,C60 = loopshapingPI(P,ωp,rl=1,phasemargin=60,form=:standard,doplot=true)
86-
87-
p1 = gangoffourplot(P, [tf(1), C60]);
88-
p2 = nyquistplot([P, P*C60], ylims=(-2,2), xlims=(-3,3));
89-
90-
plot(p1,p2, layout=(2,1), size=(800,800))
91-
92-
# gangoffourplot(P, [tf(1), C60]) # hide
93-
# save_docs_plot("pidgofplot3.svg") # hide
94-
# nyquistplot([P, P*C60]) # hide
95-
# save_docs_plot("pidnyquistplot2.svg"); # hide
96-
save_docs_plot("pidgofnyquistplot2.svg") # hide
97-
98-
# output
99-
75+
C60,kp,ki,fig = loopshapingPI(P,ωp,rl=1,phasemargin=60,form=:standard,doplot=true)
76+
fig
10077
```
10178
Here we specify that we want the Nyquist curve `L(iω) = P(iω)C(iω)` to pass the point `|L(iω)| = rl = 1, arg(L(iω)) = -180 + phasemargin = -180 + 60`
10279
The gang of four tells us that we can indeed get a very robust and fast controller with this design method, but it will cost us significant control action to double the bandwidth of all four poles.
103-
![](../../plots/pidgofnyquistplot2.svg)
10480

10581

10682
### PID loop shaping

0 commit comments

Comments
 (0)