Borrar filtros
Borrar filtros

PI controller and an integrator.

2 visualizaciones (últimos 30 días)
Charanraj
Charanraj el 8 de Mayo de 2015
Hi, I am using a discrete control algorithm to control an inverter. In this I have to construct a PI controller and an integrator. My challenge is i have to do all these in an s-function only as a code. So, my system is discrete system with the following values
Matlab integration time, Ti=10^-6 sec Sampling time, Ts=10^-4 sec Count = Ts/Ti=100
So, my for loop count is 100 values either 0to99 or 1to100. I am doing it with the level of a counter, rather using for loop. So the control algorithm is carried out inside the counter loop, as follows-
%global declaration
global count;
global e2;
global e1;
global inte;
global inti;
global PI;
global kp;
global ki;
kp=1; ki=2.5;
%main program
if count<(100-0)
count=count+1;
else
e2=desired-measured; %error
prop=error; %for P
inte=(e2+e1)*Ti/2; %for I
inti=sum(inte); %for I
PI=kp*prop+ki*inti; %for PI controller
%
% %some blocking for matrix calculations
%
x_dot=[x1;x2;x3]; %output of the vector after some control calculations
state1=sum(x_dot(1)); %for integration
state2=sum(x_dot(2));
state3=sum(x_dot(3));
x=[(state1+state11)*Ti/2; (state1+state11)*Ti/2; (state1+state11)*Ti/2]; %output after integration
e1=e2; %for getting the previous count values in the next count
state11=state1;
state22=state2;
state33=state3;
count=0;
end
My queries:
1) Is the PI counter code ok? Or should I sum the PI value ? But there is just simple matrix multiplication after PI controller.
*2) Is the method used for Integrating a vector ok? It is just a vector, x_dot=[x1;x2;x3] and i have to integrate in. When I look the alternate to use the function directly like trapz or quad, I have doubts of using the format inside my for loop, which already is structured to have 100 counts in every 10^-4 seconds.Because, I do not find any example for discrete systems and how to call the integrating time in it. Can I be able to use directly the trapz of each element in the vector for example
x1=trapz(x_dot(1)); x2=trapz(x_dot(2)); x3=trapz(x_dot(3));
or likethis, using the integration time, Ti=10^-4 sec (but remember, this is also my matlab integration time)
x1=trapz(Ti,x_dot(1)); x2=trapz(Ti,x_dot(2)); x3=trapz(Ti,x_dot(3));
Any advices/guidances will b highly useful for learning.

Respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by