echo on
% Demo for use of trans.m and bod.m
% Given: controlled process in Laplace-domain
%        process numerator:   z=1
%        process denominator: n=[2 3 1]
% Asked: digital controller, single loop, PID-Type,
%        use of Digital Amount Optimum (BOD)
%        DEMO_1: command variable action

% 1. transform controlled process into Z-domain: use of trans.m
%	advantage of trans: choice of connection and measurement
% [zz,nz]=trans(z,n,T(,m,kode))
%   zz and nz = process numerator and denominator in Z-domain
%   T=sampling time; m=modified Z-transforn;
%   kode=... if given m-file works non-interactiv:
%      kode=1 sampler & instantaneous value (IV)
%      kode=2 zero order sample&hold (ZOS&H) & IV   or   sampler & MV
%      kode=3 ZOS&H & mean value (MV)

% 1. input: give "enter" = connection between controller and process by
%                          means of zero order sample & hold ;
%                          otherwise sampler only
% 2. input: give "enter" = measurement: instantaneous values ;
%                          otherwise mean values
z=1; n=[2 3 1]; T=1;
[zz,nz]=trans(z,n,T),

pause,            % please press any key

% 2. controller parameter - use of Digital Amount Optimum (BOD)
% [rz,rn(,fz,fn)]=bod(zz,nz)
%       rz and nz = controller numerator and denominator;
%       fz and fn = filter numerator and denominator (if desired only: e.g.
%                   (optimisation for disturbance and command variable action)
% 1. input: give "enter" = optimisation for command variable action;
%                          "1" forces optimisation for disturbance variable action
% 2. input: give "enter" = no polcompensation
%                          "1" forces polcompensation (display/choise)
% 3. input: give "enter" = controller with integral part
%                          "1" forces controller without integral part
% 4. input: give "1"     = this number matches the controller numerator degree
%                          which has to be computed; notice: for result degree
%                          polcompensation has to be taken into account !
% 5. input: give "enter" = choise of result output display - ever use "enter" !

[rz,rn]=bod(zz,nz),

% Suggested inputs caused the computing of a Digital Proportional/Integral
% controller (PI-controller)

pause,           %  please press any key

% Suggested inputs and parameters result in:

VR=1.0752; VRd1=-0.6815; VRd2=0;        %controller
VF=1;      f1=0;         f2=0;          %filter

% Now SIMULINK-simulation by means of einf_bei.m is possible
% Note_1: Controller denominator in einf_bei.m has no variables
% Note_2: Please be sure you'll call a command variable action (step response)

		 % please press any key
pause,		 % select "simulation" and then "start"
einf_bei
echo off