% ControlEngineering, 2019 (Springer), Keviczky Bars Hetthéssy Bányász
% Example 7.1 (7.20), p.262: 1PT1, large dead time
% solution fig. 7.12, p.263
Vs1=1; num1=1; den1=[10  1];  Td1=5;

% book, p.263, control structure given with inner optimal controller and
%              feed forward structure

% BO-Toolbox: PI undelayed
RegPIu= bo_u_gen(12,Vs1,num1,den1,Td1,23),
% RegPIu:  VR=,   TN=,   TR0=,
cn1_uPI=[RegPIu(2)  1], cd1_uPI=[RegPIu(3)  0],
% BO-Toolbox: PID undelayed
RegPIDu= bo_u_gen(13,Vs1,num1,den1,Td1,23)
% RegPIDu:  VR=,   TN=,    TR0=,    TV=,
N=1*10^-3;   % alternative D-term approximation: apply Simulink PID block
cn1_PIDu=[RegPIDu(4)*RegPIDu(2)  RegPIDu(2)  1], 
cd1_PIDu=[N*RegPIDu(3)  RegPIDu(3)  0],

% BO-Toolbox: PI delayed
[RegPId,A21,A31]= bo_d_gen(12,Vs1,num1,den1,Td1,23), %A2,A3: solver check
%RegPId: VR=,    TN=,    TR0=,
cn1_PId=[RegPId(2)  1], cd1_PId=[RegPId(3)  0],
fn1_PId=[0          1], fd1_PId=[RegPId(2)  1],

% BO-Toolbox: PID delayed
[RegPIDd,A22,A32]= bo_d_gen(13,Vs1,num1,den1,Td1,23),
%RegPIDd: VR=,    TN=,    TR0=,    TV=,
N=1*10^-3;                                      % N: see comment above
cn1_PIDd=[RegPIDd(4)*RegPIDd(2)  RegPIDd(2)  1],
cd1_PIDd=[N*RegPIDd(3)           RegPIDd(3)  0],
fn1_PIDd=[0                      0           1],
fd1_PIDd=[RegPIDd(4)*RegPIDd(2)  RegPIDd(2)  1],

disp('"LK_ex071_sim.slx" will be called - compare parameters')
LK_ex071_sim; sim('LK_ex071_sim',230),
disp('Repeat bo_d_gen call at MATLAB promt, if search algorithm fails')
