Extracting Delay and Rise time from graph for Ziegler-Nichols Tuning method

4 views (last 30 days)
Firstly, I am experimenting with following code. It is suppose to find the tangent i.e. rise time and delay time i.e. 0-10% of the graph. I was not able to find similar approach. This code is not my own, I am just using it for the sake of understanding ZN using code.
Secondly, The problem occurs at function openloop. the polyfit function is suppose to extract the values.
Furthermore, If someone can help me rewrite the code using a less complicated and complex approach, I will extremely greatful.
%constants R = 1.2; L = 0.560e-3; Kt = 25.5E-3; Ks = 37.4; tm = 17.1e-3; J = 92.5e-7; p = 3;
%evaluatedconstants te = L/(p*R); Ke = (3*R*J)/(tm*Kt);
% Start of code global zn_line_x zn_line_y;
%Transfer function G = tf([1/Ke],[tm*te tm 1]);
% Plots the Step Response diagram figure; step (G, 0.5) title ('Open Loop Step Response diagram'); xlabel('Time'); ylabel('Voltage (volts)'); grid on; %Code successfully works up-to this point
coeff_x = polyfit([6 10 12],openloop(2,[6 10 12]),1); %Problem occurs here coeff_y = polyfit([700:900],openloop(2,[700:900]),1); &and here, error is index exceeds dimension
for n=1:100 zn_line_x(n)=coeff_x(1)*n+coeff_x(2); end
for n=1:900 zn_line_y(n)=coeff_y(1)*n+coeff_y(2); end
figure(2) hold on plot(openloop(2,:), 'red') plot(zn_line_x); plot((zn_line_y), 'green'); legend ('1step response', 'line'); grid on axis([0 400 0 14]); l = length(openloop(2,:)); L_samples = roots(coeff_x);
[a,b,c] = intersect(zn_line_x, zn_line_y);

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!