echo on
%demo_2 - use of zust_au1.m and subsequently zust_aug1.m
%
% Given: controlled process in Laplace-domain: a two-mass system with
%        electrical motor according a paper in "Automatisierungstechnik"
%        at 35 (1987) 7, p. 275 / 283,
%        Oldenbourg Verlag (publishing house) Muenchen, Germany
% 	 T   = sampling time
%        Tel = remining time constant (current control: closed loop)
%	 TM  = mechanical motor time constant
%	 TF  = spring time constant
%	 TL  = load time constant
%
% Asked: controller gains of a digital state space controller structure,
%        use of Digital Amplitude Optimum (BOD)
%        K1 = controller gain for differential speed
%        K2 = controller gain for spring torque
%        K3 = controller gain for dynamic error of the motor speed
%        K4 = controller gain for disturbance variable
%        Disturbance variable and command variable action
pause,       % please press any key

% Definition of process time constants
T=1; Tel=4; TM=30; TF=5; TL=30;   % values in milliseconds
% Transformation of the controlled process into Z-domain and computation
% of the controller gains as DEMO-solution for other controlled processes;
% Use of Digital Amplitude Optimum (BOD)
erg=zust_au1(T,Tel,TM,TF,TL)       % please wait
K1=erg(1); K2=erg(2); K3=erg(3);  % preparation for SIMULINK
pause,       %  please press any key

% SIMULINK-simulation by use of demo_2s.mdl you see: 
% motor speed, load speed and differential speed for
% command variable action (step response)
STF=T; FVF=1; STS=T; FVS=0;  K4=0; demo_2s; sim('demo_2s',250)
pause,		 %  please press any key

% SIMULINK-simulation by use of demo_2s.mdl you see:
% motor speed, load speed and differential speed for
% disturbance variable action (step response)
K4=-(1+K2), % given by use of limes-problem
FVF=0; FVS=-0.4; demo_2s; sim('demo_2s',250)
echo off
