SIMULINK. Lineare und nichtlineare. Systeme

SIMULINK Systeme SIMULINK Lineare und nichtlineare Systeme Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth SIMULINK Systeme Inhalt • SIMULINK–Bib...
Author: Hilko Meyer
19 downloads 3 Views 193KB Size
SIMULINK Systeme

SIMULINK Lineare und nichtlineare Systeme Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

SIMULINK Systeme Inhalt • SIMULINK–Bibliothek Continuous • Linearisierung, Ermittlung eines Gleichgewichtspunkts • SIMULINK–Bibliothek Nonlinear • SIMULINK–Bibliothek Functions&Tables • Algebraische Schleifen • S–Funktionen

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

SIMULINK Systeme SIMULINK Bibliothek Continuous

• Elemente zur Modellierung zeitkontinuierlicher Systeme • Totzeiten 1 s Integrator du/dt Derivative

(s−1) s(s+1) x’ = Ax+Bu y = Cx+Du

Zero−Pole

State−Space

1

Memory

s+1 Transfer Fcn

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

Transport Delay

Variable Transport Delay

1

SIMULINK Systeme Von der DGL zum Continuous–Block Beispiel:

Feder–Masse–Schwinger

DGL: m · x ¨(t) + k · x(t) = 0 L¨ osung im Zeitbereich: x(t) = x0 cos (ω0t) + ωv0 sin (ω0t)

L0

0

¨ bergang in den Frequenzbereich: U 1 ¨ bertragungsfunktion X(s) = U s2 + ω02 ⇒ in SIMULINK: Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

0 Constant

1 2 s +2 Transfer Fcn (with initial outputs)

x

k

m

Scope1

2

SIMULINK Systeme Beispiel zu Continuous R¨ ucksetzen des Simulink Integrator-Blocks:

0.5 Constant

1 s xo

>=

Integrator Anfangswert

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

2

Scope

Relational Operator

Constant1

3

SIMULINK Systeme Linearisierung

• Linearisierung von Simulationsmodellen an beliebigem Arbeitspunkt • Befehlsaufruf: [A,B,C,D] = linmod(’sys’, x, u, para, xpert, upert) [Ad,Bd,Cd,Dd] = dlinmod(’sys’, T s, x, u) • Weitere Matlab–Befehle aus der Control System Toolbox zur Analyse anwendbar (ss, tf, zpk, bode, lsim) Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

4

SIMULINK Systeme Bestimmung eines Gleichgewichtspunkts • Gleichgewichtspunkt entspricht dem eingeschwungenem Zustand des Systems, d.h.

x˙ = 0 • Befehlsaufruf: [x,u,y] = trim(’sys’, x0, u0, y0) • weitere Optionen ⇒ help trim

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

5

SIMULINK Systeme SIMULINK Bibliothek Nonlinear

• Elemente zur Modellierung physikalischer Nichtlinearit¨ aten • Schalter Manual Switch Rate Limiter

Quantizer

Dead Zone Coulomb & Viscous Friction

Saturation

Backlash

Switch

Relay

Multiport Switch

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

6

SIMULINK Systeme Beispiele zu Nonlinear Beispiel zu Quantizer Parabel f(u) Clock

quantisierte Parabel

ausgabe To Workspace

(u(1)−5)^2 + 3 Quantizer

Beispiel zu Backlash u ausgabe Signal Generator

y Rate LimiterBacklash

To Workspace

1 Constant Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

7

SIMULINK Systeme SIMULINK Bibliothek Functions&Tables

• Nachschlagetabellen • programmierbare Funktionen

f(u) Look−Up Table

Fcn MATLAB Function

Look−Up Table (2−D)

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

system S−Function

MATLAB Fcn

uvm.

8

SIMULINK Systeme Beispiel zu Function&Tables

Beispiel zu Look–Up Table

auslese Ramp

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

Look−Up Table

To Workspace

9

SIMULINK Systeme Algebraische Schleifen • direct

f eedthrough:

Ausgang

u

h¨ angt vom Eingang zum gleichen Zeitpunkt ab

y

Sum

• Bl¨ ocke mit direct f eedthrough: Sum, Gain, Product (State Space, Integrator, Transfer Function, Zero–Pole)

• L¨ osung mit Algebraic Constraint:

f(z)

Solve f(z) = 0

z

Algebraic Constraint

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

10

SIMULINK Systeme Beispiel zu algebraischen Schleifen

1 z 3 − 1 sin z − z − 5 = 0 f (z) = 7 28

(1/7)* u^3 Fcn (1/28)* sin(u) Fcn1

f(z)

Solve f(z) = 0

z

Algebraic Constraint

5

z

3.9708653342418 Display

Constant z

Sum

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

11

SIMULINK Systeme S–Funktionen • selbst–programmierbare Funktionen • Ausf¨ uhrung innerhalb eines SIMULINK–Modells durch S–Function–Block • programmierbar in – Matlab (M–Files) – C, C++, Fortran, Ada (MEX Files) • Einbringen bereits vorhandenen Programm–Codes

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

12

SIMULINK Systeme Beispiel zu S–Funktionen P T1 :

¨ bertragungsfunktion: U

oder Zustandsdarstellung:

Step

pt1sfun

y

S−Function

To Workspace

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

Y (s) =

1 · U (s) 1 + sT

1 1 x˙ = − · x + · u T T y = x

13

SIMULINK Systeme Beispiel zu S–Funktionen function [sys,x0,str,ts] = pt1sfun(t,x,u,flag,T) A = [-1/T]; B = [ 1/T]; C = [ 1 ]; D = [ 0 ]; switch flag,

% % % %

Zustandsmatrix Eingangsmatrix Ausgangsmatrix Durchschaltmatrix=0

% Initialization % case 0, [sys,x0,str,ts]=mdlInitializeSizes(A,B,C,D); % Derivatives % case 1, sys=mdlDerivatives(t,x,u,A,B,C,D); % Outputs % case 3, sys=mdlOutputs(t,x,u,A,B,C,D); % Nicht verwendete Flags case {2, 4, 9}, sys=[];

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

% Unexpected flags % otherwise % Fehlerbehandlung error([’Unhandled flag = ’,num2str(flag)]); end % end pt1sfun

%===================== % mdlInitializeSizes %===================== % function [sys,x0,str,ts]=... mdlInitializeSizes(A,B,C,D) sizes = simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs

= size(A,1); = 0; = size(C,1);

sizes.NumInputs

= size(B,1);

14

SIMULINK Systeme Beispiel zu S–Funktionen sizes.DirFeedthrough = 0; sizes.NumSampleTimes = 1; sys = simsizes(sizes); x0

= zeros(size(A,1),1);

%==================== % mdlOutputs %==================== % function sys=mdlOutputs(t,x,u,A,B,C,D)

str = []; sys = C*x + D*u; ts = [0 0]; % end mdlInitializeSizes

% end mdlOutputs

%=================== % mdlDerivatives %=================== % function sys=mdlDerivatives(t,x,u,A,B,C,D) sys = A*x + B*u; % end mdlDerivatives

Vorlesung Matlab/Simulink Dipl.-Ing. U. Wohlfarth

15