Example H6.14
Matlab code for example 6.14 from the book "Regeltechniek voor het HBO"
Rootlocus and determination of instability gain for a feedback system with delay
- Date : 14/07/2018
- Revision : 1.0
Copyright (c) 2018, Studieboeken Specialist Permission is granted to copy, modify and redistribute this file, provided that this header message is retained.
The consequence of time delay on stability: the assignment
Figure 6.19a shows a heat exchanger. This process has the following properties:
- the time constant of the heat transfer (first order process) is 50 seconds
- the time constant of the valve control (first order process) is 10 seconds
- the time delay of the liquid is 6 seconds
- feedback is applied from sensor to valve with gain K
This creates a control system according to the block diagram of figure 6.19b.
The assignment is to construct the root locus for and to determine the value of K for which the system becomes unstable.
Solution
The following transfer function applies to the process:
. As the root locus in figure 6.20 shows, without time delay (dashed line) that system could never become unstable.
When the pure time delay of 6 seconds is replaced by a second order Padé approximation, the transfer function becomes:
. The Padé appoximation yields two complex adjugated poles: and two complex adjugated zeros . In figure 6.20 these poles and zeros are added to those of the heat exchanger and the root locus has been constructed using the computer (solid line). If we compare the solid line with the dashed line, we see for instance that for an often desired (this means ) the influence of the time delay is quite small. But stability is strongly influenced by the time delay. For the intersection with the imaginary axis we see: rad/s. If we determine the gain for this point using the graphical method according to formula 6.46 we find: . The exact values can be determined by simulation and turn out to be: rad/s and . Especially the deviation in the value of seems quite large, but for a practical setting with we find a value for K of approximately 4. Matlab code for this example
% clear all variables from Workspace
Create models:
First we create the models for the proces and the valve.
Tau_heat_transfer=50; % Time constant heat transfer
Tau_valve=10; % Time constant of valve control
Td=6; % Transporttime fluid
H_valve=1/(Tau_valve*s+1);
H_1=exp(-s*Td)*(1/(Tau_heat_transfer*s+1));
% Create total open loop model
Then we create a model which uses Pade approximation of the delay.
% Create proces model with pade approximation of delay
H_1_pade=pade(exp(-s*Td),Order)*(1/(Tau_heat_transfer*s+1));
H_tot_pade=H_valve*H_1_pade;
Analysis without delay
We are assuming that the temperature sensor works as a unit feedback and that there is gain controller that actuates the valve. See figure 6.19b of the book.
First we look at the root locus of the systeem if the delay would not be present:
H_1_nodelay=H_valve*(1/(Tau_heat_transfer*s+1));
The rootlocus shows that this system without delay would always be stable (for every positive value of K') as the rootlocus does not cross the vertical axis.
Analysis with delay
Next we look at the system with delay present. Without an approximation of the delay the rootlocus can not be shown. But it is offcourse possible to show the bode diagram of the open system to find the gain margin at a phase shift of -180 degrees.
First we will show the bode plot:
bodeplot(H_tot,H_tot_pade);
title('Bode diagram of H_{tot}');
legend('No Pade','With Pade','Location', 'SouthWest')
Zooming in around the area of -180 deg phase shift gives:
bodeplot(H_tot,H_tot_pade,ZoomArea);
title('Bode diagram of H_{tot} zoomed in around -180 deg');
legend('No Pade','With Pade','Location', 'SouthWest')
annotation(figure3,'textarrow',[0.432 0.514],[0.693 0.693],...
'String',{'Gain at 180 degrees'});
You can notice that the pade has a phase difference of 360 degrees. For instablity this can be disregarded. You can now read the gain margins from the plot. We could also use a Matlab command for this:
%%Determine the gain margin of H_tot from the bode plot;
[Gm,~,Wgm,~] = margin(H_tot); % [Gm,Pm,Wgm,Wpm] but Pm and Wpm not used thus ~
MsgStr=['Gain margin H_{tot} is : ', num2str(Gm), ' at ', num2str(Wgm), ' rad/s'];
% Add the answer as text to plot
annotation(figure3,'textbox',...
[0.17 0.53 0.39 0.064],...
%%Determine the gain margin of H_tot_pade from the bode plot;
[Gm,~,Wgm,~] = margin(H_tot_pade); % [Gm,Pm,Wgm,Wpm] but Pm and Wpm not used thus ~
MsgStr=['Gain margin H_{tot\_pade} is : ', num2str(Gm), ' at ', num2str(Wgm), ' rad/s'];
% Add the answer as text to plot
annotation(figure3,'textbox',...
[0.17 0.48 0.39 0.064],...
Conclusion
It shows that the difference between found value of the gain for oscillation without and with the 2nd order Pade approximation is very small. It can be concluded that the second order Pade approximation of the delay works very well in this case.
Rootlocus of the system with Pade approximation
Next we look again at the system when we approximate the delay with Pade. This allows us to also show the rootlocus.
h=rlocusplot(H_tot_pade);
% get the handle to the plot options
p.Title.String='Root Locus of H_{tot\_Pade}';
% write the options to the figure
Notice that the poles and zeros of the pade approximation are symmetrical around the imaginary axis with the zeros on the right and the poles on the left.
Show the step response of the found gain value where is oscillates
As a last step we will verify the oscillation using the step response. According to the bode diagrams, ocillation occurs around K_r=11.14. Here we take a look at the stepresponse of the feedback system for that gain.
H_cl=feedback(K_r*H_tot,1);
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');
Enhance the figures: Figure 1
set(gcf, 'Tag','EnhancedImage');
% create the plot again but now with rlocusplot to return a figure handle
h=rlocusplot(H_tot_pade,'k',H_1_nodelay,'k--');
[Z,P,Kpn]=zpkdata(H_tot_pade);
% get the handle to the plot options
p.Title.String='Root locus plot of H_{tot\_pade}';
% write the options to the figure
% Calculate location axis
Xoffset=0.14; % left part of the figure window not used by the graph
Scale=0.8; % part of the whole figure window used by the graph
omega = char(969); % Greek letter omega
lambda = char(955); % Greek letter lambda
annotation(figure1,'textarrow',[Vaxis_loc Vaxis_loc],...
[0.79 0.86],'String',{omega});
annotation(figure1,'textarrow',[0.9-0.07 0.9],...
[0.48 0.48],'String',{lambda});
annotation(figure1,'textbox',...
[Vaxis_loc 0.52 0.077 0.051],...
annotation(figure1,'textbox',...
[Vaxis_loc 0.46 0.0306 0.042],...
annotation(figure1,'textbox',...
[Vaxis_loc+0.01 0.81 0.077 0.0517],...
'String',['Kpn=', num2str(Kpn)],...