Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

matlab code to plecs

0 votes
729 views
Hi

I am working on the MPPT algorithm (P&O) and I did it in MATLAB function and it works. However, I cannot transfer it to C-script, and I dunno how it works in plecs.

could anyone help, the script is as follows:

 

function duty = MPPT_algorithm (vpv,ipv,delta)
duty_init=0.1; duty_min=0; duty_max=0.85;

persistent Vold Pold duty_old;

if isempty(Vold)
    Vold=0;     Pold=0;     duty_old= duty_init;
    
end

P=vpv*ipv;
dV=vpv-Vold;
dP=P-Pold;

if dP~=0 && vpv>30
    if dP< 0
        if dV < 0
            duty = duty_old - delta;
        else
            duty=duty_old + delta;
        end
    else
        if dV<0
            duty =duty_old + delta;
        else
            duty = duty_old - delta ;
        end
    end
else
    duty = duty_old;
    
end

if duty>= duty_max
    duty=duty_max;
elseif duty<duty_min
    duty = duty_min
    
end

duty_old= duty;
Vold= vpv;
Pold=P;
asked Jul 15, 2020 by babackmn (20 points)

1 Answer

0 votes
Hello,

There are several examples of C-Script-based MPPT algorithms in the PLECS demo model library already. See the "Single-Phase PV Inverter with Partial Shading" model, for example.

Best regards,

Kris
answered Jul 16, 2020 by Kris Eberle (1,591 points)
...