Filter löschen
Filter löschen

Solving Diffrential equations which include PID Controller

10 Ansichten (letzte 30 Tage)
Muhammad Mudassar
Muhammad Mudassar am 3 Sep. 2019
Kommentiert: Rik am 13 Sep. 2019
Hello, I have four diffrential equations which depends on each other and one of the diffrential equation contain a PID controller. I want to solve these diffrential equations by incorporating that PID controller but don't know how to incorporate PID controller while solving these equations.
Here is the picture of those equation

Antworten (1)

Alex Gros-Balthazard
Alex Gros-Balthazard am 3 Sep. 2019
Hello,
That looks like a system of linear differential equations that I believe matlab can find a close form symbolic solution for.
Make each derivative one of your state variables. Then express the derivative of each state variable as linear combination of the other state variables. Suppose you had 3 state variables: you should be able to write this in state variable form:
dx1/dt = c11*x1 + c12*x2 + c13*x3 + f1(t)
dx2/dt = c21*x1 + c22*x2 + c23*x3 + f2(t)
dx3/dt = c31*x1 + c32*x2 + c33*x3 + f3(t)
See matlab manual pages in symbolic toolbox on using dsolve to solve a system of linear differential equations and also on putting differential equations into matrix form. You CAN and should solve this by hand as well.
Your Proportional integral derivative controller function looks like it contains state variables. The forcing functions, f1 f2 and f3 cannot include any dependency on state variables.
I think matlab will handle and sort all that for you, if you just substitute your definition of Vpid into the other equations where it belongs. So you have four state variables, Ef, Vf, Vr and Va.
The derivative of each of those can be expressed as a linear combination of those state variables plus some forcing function. I believe you can actually just write those differential equations symbolically, substitute in your definition of Vpid where ever it belongs, because it contains state variables, part of which make up the coefficient matrix and part of which goes into the forcing functions. So you substitute Vpid, symbolically, and I think matlab will do rest automatically, without you having to even write them in the above format. Matlab will just do it internally. You can and should check what it does. Use equations to matrix format function to check what matlab is doing.
Check matlab functions:
dsolve
equationsToMatrix
Matlab will also solve that for you numerically, although it's simple enough that I believe matlab will find closed form symbolic solutions.
Best Regards
Alex GB
  2 Kommentare
Muhammad Mudassar
Muhammad Mudassar am 7 Sep. 2019
Sir I did as you advise to do but it gives some error which I couldn't able to find out what actually it means i.e.
%%%%%%%%%%%%%%%%%%%%%%%%%%
Error using odearguments (line 113)
Inputs must be floats, namely single or double.
Error in ode23t (line 143)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Untitled2 (line 9)
[t,y] = ode23t(@trap,[0 2],[Efd0 Vr0 Vf0 Va0]);
%%%%%%%%%%%%%%%%%%%%%%%%%
I also try to write by using single and double but that also doesn't work for me.
Kindly guide me what I can do now
Here is the my code
%% Main File
clc
clear all
close all
Kad=1;
Efd0=1.253863906350126*Kad;
Vr0=1.045000000000000;
Vf0=1.253863906350126*Kad;
Va0=1.254330160918846;
[t,y] = ode23t(@trap,[0 2],[Efd0 Vr0 Vf0 Va0]);
t1=1:length(y);
plot(t,y(:,1),'--')
%% Function File
function dydt = trap(t,y)
Te=0.785000000000000;
Ke=1;
Aex=3.186162949476561e-05;
Bex=1.959622092949451;
Tr=0.010000000000000;
Tf=1;
Ta=0.020000000000000;
Ka=1;
Vref=1.045000000000000;
Vss=0;
Kf=0.030000000000000;
Kp=200;
Ki=50;
Kd=50;
Td=0.010000000000000;
Vt=1.045000000000000;
syms s
VPID=(Vref+Vss-y(2)-(Kf/Tf)*(y(1)-y(3)))* (Kp+(Ki/s)+(s*Kd)/(s*Td+1)); %%defining VPID
%% Defining diffrential equations by assuming State Variables as
%%y1=Efd,y2=Vr, y3=Vf and y4=Va
y1d=(1/Te)*( y(4)-(Ke+Aex*exp(Bex*y(1))*y(1)));
y2d=(1/Tr)*(Vt-y(2));
y3d=(1/Tf)*(y(1)-y(3));
y4d=(1/Ta)*(Ka*VPID-y(4));
dydt = [y1d;y2d;y3d;y4d];
Rik
Rik am 13 Sep. 2019
Comment posted as flag by Muhammad Mudassar:
Still I couldn't able to incorporate PID controller which is in Laplace domain

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Chemistry finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by