Simulink: Matlab function block for Charge controller of a solar home system.
Mostra commenti meno recenti
I am modelling a solar home system, with a battery protection system or charge controller, which controls 2 switches depending on the voltage of the battery.

% This is the code for the functional block, kindly read the comments
function [Sw_A, Sw_B] = fcn(v1,v2,v3,v4,v_bat,i_bat)% sw A is PV sw and SW_B is load switch
while i_bat < 0 % battery is discharging hence curent is negative
if v_bat < v1 % 1. if battery voltage is too low, load is cut off
Sw_B = 0;
elseif v_bat < v3 % 4. Battery is discharged into load and voltage is safely low, reconnect pv
Sw_A = 1;
end
while i_bat > 0 % Battery is charging
if v_bat > v2 % 2. if voltage is raised high enough, the load is reconnected
Sw_B = 1;
elseif v_bat > v4 % 3. Battery is being overcherged, cut off PV switch
Sw_A = 0;
end
end
This function is showing multiple errors, I can only assume I have done some silly rookie mistakes. Any help will be greartly appreciated. if you require any more data please ask.

Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Solar Power in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!