My embedded function is not updating the value in the next step calculated from previous step
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I Have coded Matlab Embedded function to work my solar system at the MPP (incremental conductance). So i took the previous i, V and P and calculate what shouuld be duty cycle. And Tried to reach to the exact duty cycle for my MPP by continuously calculating the duty cycle from the previous step. But it did not take the previous step value rather always took initial D as 0 in each step. The code is:
function y = fcn(v_1,i_1,v,i,D)
d=.01;
deli=i-i_1;
delv=v-v_1;
if delv==0
if deli==0, m=D;
else
if deli>0, m=D+d;
else
m=D-d;
end
end
elseif ((deli/delv)+(i/v))<.01 && ((deli/delv)+(i/v))>-.01 , m=D;
else
if ((deli/delv)+(i/v))>.01, m=D+d;
else
m=D-d;
end
end
y=m;
end
2 comentarios
Walter Roberson
el 22 de Ag. de 2012
Khalid wrote,
Hi Kaustubha,
Thanks for your response.
D is the duty cycle of the boost converter. It is an input as well as the output of the function(by unit delay). The embedded function is supposed to update D and reach to the required D to make the circuit to work in Maximum power point by each iteration as the time goes on.
The link to see the the system in JPEG: http://knsakib.freehostia.com/The%20solar%20cell%20system.jpg
The link to see inside Boost controller: http://knsakib.freehostia.com/inside%20the%20boost%20converter%20control%20%28orange%29.jpg
The matlab embedded block: http://knsakib.freehostia.com/Maximum%20power%20point%20function%20%28inside%20the%20MPPT%29.jpg
_Please to go to the link or download the file copy paste those links on your browser otherwise its not working :(_
Respuestas (6)
Kaustubha Govind
el 23 de Ag. de 2012
From looking at your snapshots, the problem you described "it did not take the previous step value rather always took initial D as 0 in each step" only makes sense if "y" is calculated as 0 in every time step. I would recommend connecting a scope block at "y" and also at the output of the Unit Delay block that produces "D", and make sure both y and D are non-zero after the initial step.
0 comentarios
Mariano Lizarraga
el 25 de Ag. de 2012
I was trying to download your model to help you debug this but I only get the landing homepage of "freehostia". Here are a few things I would suggest you do:
1.- Just output a counter. Comment all your embedded matlab code and just do something like
y = D + 1;
and make sure your time delay in the feedback path of D has its initial condition to either 0 or the value you want the counter to start with. If you see that the output is indeed an ever increasing counter like here: http://skit.ch/nwnx then it is a good indication that something is not working as you expect on your embedded MATLAB function. If it is not, then something is going on with your time dealy block.
2.- Put your embedded MATLAB function in a set of known states and make sure you get the output you expect. That is, disconnect the feedback, put a known value into D and some conditions in v and i and put a scope after the time delay to make sure you are getting what you are expecting.
Hope this helps
---
Mariano
0 comentarios
KHALID SAKIB
el 23 de Ag. de 2012
1 comentario
Kaustubha Govind
el 24 de Ag. de 2012
If you connect a Scope right after the Unit Delay (before the input to the MATLAB Function block), do you see D taking non-zero values?
KHALID SAKIB
el 24 de Ag. de 2012
2 comentarios
Kaustubha Govind
el 27 de Ag. de 2012
Khalid: At step#2, D will indeed be 0, because it is the value of y at step#1 (note that D is the output of a Delay block). D should attain the value of 0.01 at step#3. Is this what you see?
KHALID SAKIB
el 26 de Ag. de 2012
1 comentario
Mariano Lizarraga
el 27 de Ag. de 2012
Khlaid, I've donwloaded your model and run it. The variable D is indeed changing, I don't see it to be perpetually identical to zero as you describe in your problem. I modified the embedded MATLAB code to print the value of D every time it runs, and it is indeed changing. It stays at the same value for multiple sample times but eventually changes and takes other values different than zero, here is a screenshot: https://skitch.com/malife/eq9ri/windows-xp-pro.
To make sure that it was indeed taking the input value I further modified the model and the embedded MATLAB function to just passthrough D as a new output D1, and once in the output plot it against input D, they are indeed identical, thus completely showing that D is indeed changing and being used inside the embedded MATLAB function. You can look at what I mean in this image: https://skitch.com/malife/eq98j/windows-xp-pro
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!