Skip to content
Snippets Groups Projects
Commit ee3d1d1c authored by Sebastian Schwarz's avatar Sebastian Schwarz
Browse files

add notebook V04.3.ipynb

parent cad7b292
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:372cfa0a-fd52-4341-bb68-622e443a326c tags:
# <span style='color:OrangeRed'>V4 REGELALGORITHMEN FÜR DIE DIGITALE REGELUNG: TEIL 3</span>
%% Cell type:markdown id:89fa67fe-464b-4205-8bf2-b5f3e6af9cf8 tags:
<p>Gegeben ist das System gemäß des nachfolgenden Blockschaltbilds:</p>
%% Cell type:markdown id:d33ed972-9241-408e-99b6-94f70b5efb5b tags:
<img src="figures/ClosedLoop.png" alt="drawing" width="600" height="300"/>
%% Cell type:markdown id:9df9ca81-58a9-4b89-acf2-8d378e2bc038 tags:
G(s) ist dabei definiert als:
%% Cell type:code id:d51fb99c-e70c-4b3e-b0e2-b2efa97a2aaf tags:
``` octave
clear all
pkg load control
% Set the Octsim Engine to run the simulation
addpath('../Octsim');
num = [-1 1]
den = [1 4 3]
Gs = tf(num,den)
```
%% Output
num =
-1 1
den =
1 4 3
Transfer function 'Gs' from input 'u1' to output ...
-s + 1
y1: -------------
s^2 + 4 s + 3
Continuous-time model.
%% Cell type:markdown id:3d088845-789d-4a9f-8c69-7d89099a37a8 tags:
<p>Zunächst müssen wir die Regelstreke diskretisieren:</p>
%% Cell type:code id:3eba9469-4c8c-4e7a-ac53-9de59b0d075f tags:
``` octave
Ts = 0.2
Gz = c2d(Gs,Ts,'zoh')
[numzc,denzc] = tfdata(Gz)
numz = numzc{1}
denz = denzc{1}
```
%% Output
Ts = 0.20000
Transfer function 'Gz' from input 'u1' to output ...
-0.1195 z + 0.1468
y1: ----------------------
z^2 - 1.368 z + 0.4493
Sampling time: 0.2 s
Discrete-time model.
numzc =
{
[1,1] =
-0.11952 0.14679
}
denzc =
{
[1,1] =
1.00000 -1.36754 0.44933
}
numz =
-0.11952 0.14679
denz =
1.00000 -1.36754 0.44933
%% Cell type:markdown id:e32155c4-417f-422d-8b9d-9838d865f26a tags:
<p>Als Regler Gr(z) soll ein zeitdiskreter PID-Regler zum Einsatz kommen, der unter Verwendung eines Schwingversuchs ausglegt werden soll. Die enstrprechenden Einstellwerte für die Auslegung des Reglers sind in der folgenden Tabelle angegeben. Die kritische Frequenz beträgt 2.19 rad/sec. </p>
%% Cell type:markdown id:7cc10159-d06c-4391-a242-37dacc2e9fb7 tags:
<img src="figures/Table.png" alt="drawing" width="600" height="300"/>
%% Cell type:markdown id:c3e1ed60-e928-4a04-9b8d-e47dabba41fa tags:
In einem ersten Schritt wenden wir die w-Transformation an:
%% Cell type:code id:036534da-c817-459b-8698-6e1584b0392c tags:
``` octave
pkg load symbolic
warning('off', 'all');
syms z
syms w
Gzs = (numz(1)*z+numz(2))/(denz(1)*z^2+denz(2)*z+denz(3))
Gzw = subs(Gzs,z,(2+Ts*w)/(2-Ts*w))
```
%% Output
Symbolic pkg v2.8.0: Python communication link active, SymPy v1.5.1.
Gzs = (sym)
431⋅z 226⋅π
- ───── + ─────
3606 4837
─────────────────────
2 619⋅π⋅z 1090⋅π
z - ─────── + ──────
1422 7621
Gzw = (sym)
⎛w ⎞
431⋅⎜─ + 2⎟
226⋅π ⎝5 ⎠
───── - ────────────
4837 ⎛ w⎞
3606⋅⎜2 - ─⎟
⎝ 5⎠
─────────────────────────────────
2
⎛w ⎞ ⎛w ⎞
619⋅π⋅⎜─ + 2⎟ ⎜─ + 2⎟
1090⋅π ⎝5 ⎠ ⎝5 ⎠
────── - ───────────── + ────────
7621 ⎛ w⎞ 2
1422⋅⎜2 - ─⎟ ⎛ w⎞
⎝ 5⎠ ⎜2 - ─⎟
⎝ 5⎠
%% Cell type:markdown id:6950b9f5-4756-4a1b-8ae7-0adf3b82fef7 tags:
<p>Jetzt können wir den Controller entwerfen. Wir müssen die Verstärkung der Übertragungsfunktion für die kritische Frequenz berechnen: </p>
%% Cell type:code id:39e06d42-b904-485b-a313-d08081c7a7d6 tags:
``` octave
omkrit = 2.19
Gg = subs(Gzw,w,1j*omkrit)
Gg = double(simplify(Gg))
Gt = abs(Gg)
```
%% Output
omkrit = 2.1900
Gg = (sym)
2
⎛ 219⋅ⅈ⎞
53875000⋅⎜2 + ─────⎟
226⋅π ⎝ 500 ⎠
───── - ─────────────────────
4837 1889473683
───────────────────────────────────────────────
2 2
⎛ 219⋅ⅈ⎞ ⎛ 219⋅ⅈ⎞
77375000⋅π⋅⎜2 + ─────⎟ ⎜2 + ─────⎟
1090⋅π ⎝ 500 ⎠ ⎝ 500 ⎠
────── - ─────────────────────── + ────────────
7621 745100271 2
⎛ 219⋅ⅈ⎞
⎜2 - ─────⎟
⎝ 500 ⎠
Gg = -0.2668004 - 0.0011012i
Gt = 0.26680
%% Cell type:markdown id:b2b0cb1a-e6a9-452f-a2d1-41303c0ce418 tags:
Anwendung der Tabelle:
%% Cell type:code id:9859a5c9-7356-45b2-99ce-9d5e5b2c52fd tags:
``` octave
Tkrit = 2*pi/omkrit
Kkrit = 1/Gt
```
%% Output
Tkrit = 2.8690
Kkrit = 3.7481
%% Cell type:code id:120ed224-fa7c-43d9-b2ba-7d4b80979e0a tags:
``` octave
Kr = 0.6*Kkrit
Ti = 0.5*Tkrit
Td = 0.125*Tkrit
```
%% Output
Kr = 2.2489
Ti = 1.4345
Td = 0.35863
%% Cell type:markdown id:f6db16ba-486e-44b5-9113-b0d82df3a327 tags:
Die Koeffizienten des PID-Reglers sind:
%% Cell type:code id:44e27ae5-1d8c-4809-a79f-8ec6520ad859 tags:
``` octave
q0 = Kr*(1+Ts/Ti+Td/Ts)
q1 = -Kr*(1+2*Td/Ts)
q2 = Kr*Td/Ts
numr = [q0 q1 q2]
denr = [1 -1 0]
Grz = tf(numr,denr,Ts)
```
%% Output
q0 = 6.5949
q1 = -10.314
q2 = 4.0325
numr =
6.5949 -10.3139 4.0325
denr =
1 -1 0
Transfer function 'Grz' from input 'u1' to output ...
6.595 z^2 - 10.31 z + 4.033
y1: ---------------------------
z^2 - z
Sampling time: 0.2 s
Discrete-time model.
%% Cell type:markdown id:69da6df5-60b6-4c59-9b7a-3af40162c538 tags:
<p>Wir können die Ergebnisse in der Simulation überprüfen.</p>
%% Cell type:code id:a7c5a5cb-05f8-4bcd-8d02-f26e7dcfe99c tags:
``` octave
% Number of data flows in the schematic
nflows = 4;
tini = 0;
tfinal = 20;
dt = 0.05;
% Instance of the simulation schematic
sc1 = Schema(tini,tfinal,dt,nflows);
% List of components
c1{1} = StepSource(1,0,1,0.1);
c1{2} = Sum(1,2,3,1,-1);
c1{3} = DTTransferFunction(3,4,numr,denr,Ts);
c1{4} = TransferFunction(4,2,num,den);
sc1.AddListComponents(c1);
% Run the schematic and plot
out1 = sc1.Run([1 2 3]);
plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:));
```
%% Output
%% Cell type:markdown id:3a14500a-6689-460e-9239-2ac03dc4b474 tags:
Wir können die Ergebnis auch mit diesem Matlab/Octave Befehlen überprüfen:
%% Cell type:code id:4cd2fee7-4143-4a9c-9bd4-215a95b4b88e tags:
``` octave
Gol = Grz*Gz
Gcl = Gol/(1+Gol)
step(Gcl)
```
%% Output
Transfer function 'Gol' from input 'u1' to output ...
-0.7882 z^3 + 2.201 z^2 - 1.996 z + 0.5919
y1: ------------------------------------------
z^4 - 2.368 z^3 + 1.817 z^2 - 0.4493 z
Sampling time: 0.2 s
Discrete-time model.
Transfer function 'Gcl' from input 'u1' to output ...
-0.7882 z^7 + 4.067 z^6 - 8.638 z^5 + 9.67 z^4 - 6.017 z^3 + 1.972 z^2 - 0.266 z
y1: ------------------------------------------------------------------------------------
z^8 - 5.523 z^7 + 13.31 z^6 - 18.14 z^5 + 15.1 z^4 - 7.649 z^3 + 2.174 z^2 - 0.266 z
Sampling time: 0.2 s
Discrete-time model.
%% Cell type:code id:d105af20-f83d-468f-9486-51533fcad8b1 tags:
``` octave
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment