Controller Designed in Matlab is blowing up

In summary: N] In summary, the Z-transform of the controller's transfer function has near zero values in the numerator, which may be causing the controller to give trouble. I'm not sure if this is the actual problem, but I need a fresh pair of eyes to take a look at it.
  • #1
Ethers0n
27
0
I've been having some trouble figuring out why a controller that I've designed using MATLAB is giving me trouble.
I"m using a polynomial equations approach to the design problem. It seems that the Z transform of the controller's transfer function has near zero values in the numerator. I'm not sure if this is the actual problem, but, it's the only thing I've been able to come up with. I just need a fresh pair of eyes to take a look at it.

There are two different files here. The first produces the transfer function of the plant. The second has the coefficients of the plant transfer function hard coded into it, and is suppossed to produce the transfer function of the controller.

It seems that the Sylvester Matrix in the second file has zeros in, giving me a very small numerator for the controller...giving near infinite gain = bad.

thanks for the help.
And I apologize in advance if the post is long...


first file

%Servo Position Controller
%Using Polynomial Equation Method

%Defining the vairables in the TF

clear all;

Rm = 2.6; %armature resistance
Km = 0.00767; %Back-emf constant
Kt = 0.00767; %motor torque constant
Jm = 3.87e-7; %motor moment of inertia
Jeq = 2.0e-3; %equivalent moment of inertia at the laod
Beq = 4.0e-3; %equivalent viscous damping coefficent
Kg = 70; %srv02 system gear ratio (motor->load) (14X5)
Ng = 0.9; %gearbox efficiency
Nm = 0.69; %motor efficiency

Ts = .001; %sampling time is 1 mili-second


a0 = Jeq*Rm; %defining the terms of plant denominator,
a1 = (Beq*Rm + (Ng*Nm*Km*Kt*(Kg)^2)); %the denominator must be monic
a2 = 0;

b0 = (Ng*Nm*Kt*Kg); %defining terms of plant Numerator

PlantNum = [b0]; %plant numerator
PlantDenom = [a0 a1 a2]; %plant denominator

PlantTF = tf(PlantNum, PlantDenom) %making the plant transfer function

PlantTFz = c2d(PlantTF, Ts) %this produces the Z-Transform of the
%plant transfer function


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
second file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%This part of the file uses the Z-Transformed Plant Transfer Function
%solved for in SRV02part1.m and from the hard-coded variables (of the
%numerator and denominator coefficients, solves the Diophontine Equation
%used to produce a controller using the Polynomial Equation Approach

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% B(z) Y(z)
%------ = ------
% A(z) U(z)

%where A(z) = z^n + a1*z^(n-1) + ...+ a(n-1)*z + a(n)


clear all;

plantnum = [0.3334];
plantden = [0.0052 0.1894 0];

Plant = tf(plantnum, plantden);

Ts = .001; %this is the sampling time

Plantz = c2d(Plant,Ts)

a0 = 1;
a1 = - 1.964;
a2 = 0.9642;

%where B(z) = b0*z^n + b1*z^(n-1) + ...+ b(n-1)*z + b(n)

b0 = 0;
b1 = 3.167e-005;
b2 = 3.129e-005;

E = [a2, 0, b2, 0; %the Sylvester Matrix E for a plant with the equation
a1, a2, b1, b2; %like this (0*z^2) + (w*z) + X
1, a1, b0, b1; % ---------------------
0, 1, 0, b0;] % (q^2) + (g*z) + (y)

%becuase a second order system is desired (from the lab handout)
%the closed loop poles will be at z^2 + 2z + 1 ie at +-45 degrees from the
%axis...
% D = F*H, D = (z^3) + (2z^2) + z + 0 = (d0*z^3)+(d1*z^2)+(d2*z)+d3
% D = [d3
% d2
% d1
% d0]

D = [0;
1;
2;
1;];

M = (inv(E))*D %inverting the Sylvester Matrix and multiplying by D
%this gives the coefficients which will produce the desired
%controller...
% M = [alpha1
% alpha0
% beta1
% beta0]
%The desired controller is of the form
% beta0*z + beta1 Beta(z)
% --------------- = -----------
% alpha0*z + alpha1 Alpha(z)

Alpha = [M(2,1) M(1,1)]; %the alpha(z) term of controller
Beta = [M(4,1) M(3,1)]; %the beta(z) term of the controller

DioControTF = tf(Beta, Alpha, Ts); %feedback regulator or designed controller

%Tz = minreal((Plantz*DioControTF)/(1 + Plantz*DioControTF))

%figure
%step(Tz, 3)
 
Physics news on Phys.org
  • #2
Am I correct to assume that you are upset because the step response of your system shoots off to infinity? If so, that means that your system is unstable. Do you know the stability requirements for a discrete time system? Have a look at the roots of the denominator of the transfer function Tz and tell me if you are still surprised that it blows up.

Just having a few zeroes in your E matrix is not bad. It would be bad if a whole row or column was zero, because then inverting it would make Matlab angry. Your E matrix is not singular, but it is a little bit ill conditioned. But not enough so that it would lead to instability, probably just really large or small gain.
 
Last edited:
  • #3
Well, that's the problem, that transfer function is meant to be stable...i realize that it's not, but am unsure as to how why it's proving unstable. As I understand it, this method is supossed to return a stable controller transfer function.

Am I wrong in this assumption? Or is the code buggy and I'm not catching it? Is there a way to make the Tz stable, by say adding a proportional gain on the front end? (Wouldn't that defeat the purpose of this method? Because then it would have just been easier to start off by making a PID controller in the first place.)
 

1. Why is my controller designed in Matlab blowing up?

There could be several reasons for this. One possibility is that your controller design is unstable, meaning it is unable to control the system and causes it to blow up. Another possibility is that there may be errors in your code or incorrect input values, leading to unexpected results. It is important to carefully check your code and input values to identify the cause.

2. How can I prevent my controller from blowing up in Matlab?

To prevent your controller from blowing up, you can try implementing robust control techniques, such as PID control, that can handle uncertainty and disturbances. Additionally, make sure to carefully test and validate your controller design before implementing it in a real system. Regularly checking for errors and debugging your code can also help prevent unexpected results.

3. Can the simulation results in Matlab be different from real-life results?

Yes, the simulation results in Matlab may not always match the real-life results due to various factors such as modeling inaccuracies, sensor noise, and environmental disturbances. It is important to carefully validate your simulation results against real-world data to ensure that your controller design is effective in a real system.

4. How can I troubleshoot my controller design in Matlab?

If your controller is blowing up in Matlab, you can start by checking for any errors in your code or incorrect input values. You can also try debugging your code by setting breakpoints and stepping through the code to identify the source of the problem. Additionally, you can consult with other experts or refer to online resources for troubleshooting tips and techniques.

5. Is there a way to optimize my controller design in Matlab?

Yes, there are various techniques and tools available in Matlab that can help optimize your controller design. These include automated tuning methods, such as the Control System Tuner app, and optimization algorithms, such as genetic algorithms. It is important to carefully tune and optimize your controller to improve its performance and prevent it from blowing up.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
923
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
11
Views
766
  • Advanced Physics Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
17K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Electrical Engineering
Replies
5
Views
14K
  • Differential Geometry
Replies
4
Views
2K
Back
Top