My embedded function is not updating the value in the next step calculated from previous step
조회 수: 6 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2012년 8월 22일
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 :(_
답변 (6개)
Kaustubha Govind
2012년 8월 23일
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
Mariano Lizarraga
2012년 8월 25일
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
KHALID SAKIB
2012년 8월 23일
댓글 수: 1
Kaustubha Govind
2012년 8월 24일
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
2012년 8월 24일
댓글 수: 2
Kaustubha Govind
2012년 8월 27일
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
2012년 8월 26일
댓글 수: 1
Mariano Lizarraga
2012년 8월 27일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 String에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!