89 views (last 30 days)
Mohammed Yakoob on 30 Mar 2022
Answered: Mohammed Yakoob on 4 Apr 2022
I want to implement these loads as nonlinear and harmonic by using codes or Simulink to deal with this problem in control system? Pemendra Kumar Pardhi on 30 Mar 2022
For above you need to use MATLAB Simulink, in Simulink you can devoloped model as atteched picture file. Thanks
Pemendra Pardhi

Mohammed Yakoob on 30 Mar 2022
Hello dear and thanks so much for your answer!! I agree with your answer but I want the way that implemented this loads as a model to deal with them in control system not as the simscap electrical!!
Pemendra Kumar Pardhi on 31 Mar 2022
In simscape electrical, control can also be implements,
For what you want, can you share paper (if it is possible)?

Mohammed Yakoob on 1 Apr 2022
Yes dear friend I attached the article that I want to simulate
Mohammed Yakoob on 1 Apr 2022

Mohammed Yakoob on 4 Apr 2022
Hello Dear
I tray to implement these disturebance loads if I deal correct as shown bellow but the last one is the nonlinear signal I can't get it so please if you have any information let me knw??
My codes :
clc
close all
clear
%% Plant Paramiters
f= 60;
Ts= 1/f; %% one period
Th=Ts/2; %%half period
Wo= 2*pi*f;
Vdc= 300;
C_st=15*10^-6;
L_t=2*10^-3;
R_li=3; %resistance of the line
%% Implement a Single Phase Microgrid in a contious time form
% x_dot= AX+BU+dW ; Y= CX+DU+0W.
% X=[il Vg]' ; U=[Vsw] ; d= [ig]; Y=[Vg].
% for i= 1:1000
Aop=[0 1/L_t; 1/C_st 0];
Bop= [1/L_t; 0];
d=[0; -1/C_st];
Cop=[0 1];
Dop= ;
B= [Bop d];
%% Imlement the system
sys=ss(Aop,B, Cop, Dop);
sys_d= c2d(sys,0.0001);
%% Performance of The Open Loop System
t = 0.000:0.0001:Th;
V_r =Vdc*sin(Wo* t);
%% Cotrollability of the system
Co= ctrb(sys);
rank(Co);
%% LQR_LMI
Ac=Aop;
Bc= Bop;
C= Cop;
nx = size(Ac,2);
nu = size(Bc,2);
% closed loop
% LQR weights
Q = diag([1 1e-5]);
R = 1;
Klqr = lqr(Ac,Bop,Q,R,[]);
% % % LMI
% % A=Ac;
% % B1 = eye(nx);
% % B2=Bc;
% %
% % C1 = eye(nx);
% % D11 = zeros(nx,nx);
% % D12 = zeros(nx,nu);
% %
% % C2 = [sqrt(Q);
% % zeros(nu,nx)];
% % D21 = zeros(nx+nu,nx);
% % D22 = [zeros(nx,nu);
% % sqrt(R)];
% %
% % Pp = ltisys(A, [B1 B2], [C1; C2], [D11 D12; D21 D22]);
% %
% % siz = size(D22);
% % gamma0 = 0;
% % obj = [gamma0 0 0 1];
% %
% % [gopt,h2opt,Klmi,Pcl,X] = msfsyn(Pp,siz,obj);
% %
% % Klqr
% % Klmi
%% Closed loop system
Acl= [Aop-(Bop*Klqr)];
Bcl= [B];
Ccl= [0 1];
Dcl= [0 0];
states = {'i_L' 'V_g'};
inputs1 = {'V_r' 'dis'};
outputs1 = {'V_g'};
poles= eig(Acl);
sys_cl = ss(Acl,Bcl,Ccl,Dcl,'statename',states,'inputname',inputs1,'outputname',outputs1);
%% At the disturebance eqaul to zero
input1 = [V_r; zeros(size(t))]; %%assume tha the disturebance =0.
[y1,t,x]=lsim(sys_cl,input1,t);
figure()
plot(t,y1)
ylabel('V_out')
xlabel('time')
title('LQR controller Without the Disterbance Term')
grid on
%% LQR when the system has a load term at R=40 Ohm
dis = (V_r/R_l+R_li);
input2 = [V_r' dis'.*0.01];
[y2,t,x]=lsim(sys_cl,input2,t);
figure()
plot(t,y2)
ylabel('V_out')
xlabel('time')
title('LQR controller With the Disterbance Term at R=40Ohm')
grid on
%% 1) PERFORMANCE AGAINST UNKNOWN LOAD
z1=complex(0,-Wo*62.86e-6);
z2= complex(0.35,Wo*223.8e-3);
z3= complex(228);
z4=complex(76,-Wo*10e-6);
z5=complex(152,Wo*111.9e-3);
Z11= (1/z1)+ (1/z2) +(1/z3);
Z22=(1/z4)+(1/z5);
n= numel(t);
% % for m= 1:n
% %
% % if m<= 36
% % dis11= (y1(m,1)/R_li+Z11)';
% % dis11(1,m)=dis11;
% % elseif m<=n-36
% %
% % dis12= (y1(36+m,1)/R_li+Z11+Z22)';
% % dis12(1,m)=dis12;
% %
% % end
% %
% % end
% dis1=[dis11 dis12];
for m= 1:n
if m<= 36
dis11= 1e-1*[cos(5*2*pi*m')+cos(1*2*pi*m')+cos(.1*2*pi*m')];
dis11(1,m)=dis11;
elseif m<=n-36
dis12= 1*[cos(4*2*pi*m')+cos(2*2*pi*m')+cos(.2*2*pi*m')];
dis12(1,m)=dis12;
end
end
dis1=[dis11 dis12];
input3 = [V_r' dis1'];
[y3,t,x]=lsim(sys_cl,input3,t);
figure()
plot(t,y3)
ylabel('V_out')
xlabel('time')
grid on
%% (2) PERFORMANCE AGAINST HARMONIC LOAD
dis = ((V_r/R_l+R_li)+7*sin(Wo*t'));
input3 = [V_r' dis'.*0.001];
[y3,t,x]=lsim(sys_cl,input3,t);
figure()
plot(t,y3)
ylabel('V_out')
xlabel('time')
grid on

Mohammed Yakoob on 4 Apr 2022
if you ask me, why dont use the simscape electrical, because I dont know the why how to connect these loads to my control simulink with the output of my system (Y) or as reterun disturebance as input??

### Communities

More Answers in the  Power Electronics Control

### Categories

Find more on Electromechanical in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!