Example H4.7

MATLAB code for example 4.7 from the book "Regeltechniek voor het HBO"

Determining a second order model from a response with no overshoot

Copyright (c) 2022, Studieboeken Specialist Permission is granted to copy, modify and redistribute this file, provided that this header message is retained.
Table of Contents
The approximation of a time delay according to formula 4.41 makes it possible to approximately determine the two time constants of a second order process with (so no overshoot in the step response) If , then the method of example 4.4 provides the solution. As an intermediate step we first reduce the system to a first order process with time delay.
To demonstrate this we consider the unit step response of figure 4.19. We see a step response with the characteristics of figure 4.7a, described by a formula like equation 4.19. So we decide it is a step response of a (dominant) second order process without overshoot. There are many processes with a step response as shown in figure 4.19. Especially thermal systems show that behaviour very often. Not surprising that this type of step response has got its own (famous) name: "s-curve"!
In figure 4.19 we draw as best as we can the bent tangent line. With the times and in this figure, the process can be approximately represented as a first order system with time delay and time constant :
.
With formula 4.41 we can approximate the time delay of 2 seconds with result:

MATLAB code (1) for this example (under construction)

To check the result you must simulate the unit step response of the approximation:
% clear all variables from Workspace and close all figures.
clear variables;
close all;
 
% Define 's' variable
s=tf('s');
H=4/((2*s+1)*(4*s+1));
Tsim=14; % simulationtime in seconds
figure(101);
step(H,Tsim);
grid on;
ylim([0 5]);
As can be seen the approximation is not so good

MATLAB code (2) for this example (under construction)

The approximation of a delay with a first order proces can be used to create a model of a system that shows a second order stepresponse with no overshoot ().
Let's assume that the measured unit step response looks like the MATLAB created figure below:
% For the moment in stead of a measurement we assume a time constant Tau_1 of 1 seconds
% and a time constant of Tau_2 of 2 seconds to simulate a measured stepresponse.
Tsim=14;
Tau_1=1;
Tau_2=4;
K_stat=4;
H_meas=(K_stat/(Tau_1*s+1))*(1/(Tau_2*s+1));
% Plot measured stepresponse
figure1=figure(101);
step(H_meas,Tsim);
grid on;
title('Simulation of a measured stepresponse');
ylim([0 5]);

MATLAB code (3) for this example (under construction)

We try to approximate it with a dead time Td followed by an exponential curve that fits with the right half of the measurement.
With measurements at two time points and the final value we can determine the time constant of an exponential curve. We measure the y-value at a time t1, t2 and its final value.
The tau value is then given by:
This all assumes that the exponential curve will start at t=0. Which it does not.
% Note down the measurements
t1=30;
t2=35;
Y_t1=3.87;
Y_t2=3.92;
Y_end=4;
Calculate the time constant and the dead time:
Tau_est=(t2-t1)/log((Y_end-Y_t1)/(Y_end-Y_t2))
Tau_est = 10.2985
 
fact_1=log((Y_end-Y_t1)/Y_end)
fact_1 = -3.4265
fact_2=log((Y_end-Y_t2)/Y_end)
fact_2 = -3.9120
Td_est=((fact_2*t1-fact_1*t2)/(fact_1-fact_2))
Td_est = 5.2880
Tau_est1=-(t1-Td_est)/fact_1
Tau_est1 = 7.2120
Tau_est2=-(t2-Td_est)/fact_2
Tau_est2 = 7.5951

Generate MATLAB figure(s) for usage in the book

Init create Enhanced Figures

Close all the earlier enhanced figures with a certain tag
EnhancedFig = findobj(0, 'Tag', 'EnhancedImage');
close(EnhancedFig);

Enhance the figures

figure1=figure(1001);
% Give it a tag
set(gcf, 'Tag','EnhancedImage');
 
% First plot the measured stepresonse
h=stepplot(H_meas,Tsim);
grid on;
title('Approximation of 2nd order model for a stepresponse with no overshoot');`z
 
Yoffset=0.01; % A slight offset to show the dashed e-curve better
t=[0:0.1:Tsim];
% PLot a exponential that fits with the right part
Td=2; % Td_est;
Tau=4; % Tau_est;
Y_end=4; % Final value of y(t)
H_approx1=1/(Tau*s+1)*exp(-s*Td);
% or ... in time domain
exponential=Y_end*(1-exp(-max((t-Td),0)/Tau))-Yoffset;
hold on;
plot(t,exponential,'--k');
 
% Create special characters
ch_tau = char(964); % Greek letter tau
ch_arrow = char(8594); % right arrow
 
% Place the aiding lines
T_63pct=Td+Tau;
plot([Td Td],[0 1],'--k');
plot([0 Td],[0.85 0.85],'-k');
plot([T_63pct T_63pct],[0 0.63*Y_end],'--k');
plot([0 T_63pct],[0.63*Y_end 0.63*Y_end],'--k');
plot([Td T_63pct],[0.75 0.75],'-k');
hold off;
annotation(figure1,'textarrow',[0.385 0.166],...
[0.421 0.271],'String',{['Td' ch_arrow ' ' ch_tau '_1 = 2']});
annotation(figure1,'textarrow',[0.383 0.246],...
[0.347 0.254],'String',{[ch_tau '_2 = 4']});
 

= Make model

H_approx2=Y_end/((Td*s+1)*(Tau*s+1));

= Compare the model with the measured reponse

figure3=figure(103);
step(H_meas,Tsim);
step(H_approx2,Tsim);