Skip to content

Commit

Permalink
Adding a filter to frequency measurements in remote microgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
saisasankkota committed Apr 17, 2024
1 parent be73156 commit ff58c6e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Binary file modified Models/RemoteMicrogrid.slx
Binary file not shown.
45 changes: 23 additions & 22 deletions ScriptData/Remote Microgrid/remoteMicrogridPlotFreAngle.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
%
% This plot shows the differences (Diesel and microgrid side) in voltage magnitude, frequency, and phase angle.

% Copyright 2022 - 2023 The MathWorks, Inc.
% Copyright 2022 - 2024 The MathWorks, Inc.
% Create new figure
h4_remote_microgrid = figure('Name', 'h4_remote_microgrid');
figure(h4_remote_microgrid)
Expand All @@ -26,56 +26,59 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
logsout_islandvoltage = logsout.get('IslandVoltage');

simlog_handles(1) = subplot(4, 1, 1);

% Neglect the initial data to avoid transients
tPlot = 2;
tIndex = find(logsout_islandcommand.Values.Time > tPlot,1);
tIndexPLL = find(logsout_gridfre.Values.Time > tPlot,1);
% selecting the plot
switch caseNum
case 3
% Plot results
plot(logsout_islandcommand.Values.Time, logsout_islandcommand.Values.Data, 'LineWidth', 1)
plot(logsout_islandcommand.Values.Time(tIndex:end), logsout_islandcommand.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_islanding.Values.Time, logsout_islanding.Values.Data, 'LineWidth', 1)
plot(logsout_islanding.Values.Time(tIndex:end), logsout_islanding.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
axis([2 8 -0.1 2.5])
title('Planned Island Command and BRK Status')
legend({'Island Command', 'Islanding', 'BRK Status'},'NumColumns',3);

case 4

plot(logsout_resynchcommand.Values.Time, logsout_resynchcommand.Values.Data, 'LineWidth', 1)
plot(logsout_resynchcommand.Values.Time(tIndex:end), logsout_resynchcommand.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_resynchronization.Values.Time, logsout_resynchronization.Values.Data, 'LineWidth', 1)
plot(logsout_resynchronization.Values.Time(tIndex:end), logsout_resynchronization.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
axis([2 8 -0.1 2.5])
title(' Resynch Command and BRK Status')
legend({'Resynch Command', 'Resynchronization', 'BRK Status'},'NumColumns',3);

case 5

plot(logsout_fault.Values.Time, logsout_fault.Values.Data, 'LineWidth', 1)
plot(logsout_fault.Values.Time(tIndex:end), logsout_fault.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
grid on
axis([2 8 -0.1 2.5])
title(' Fault and BRK Status')
legend({'Fault', 'BRK Status'},'NumColumns',2);
end

flag=sum(logsout_gridfre.Values.Data>60+frequencyLimit*60)+sum(logsout_gridfre.Values.Data<60-frequencyLimit*60)+...
sum(logsout_islandfre.Values.Data>60+frequencyLimit*60)+sum(logsout_islandfre.Values.Data<60-frequencyLimit*60);
flag=sum(logsout_gridfre.Values.Data(tIndexPLL:end)>60+frequencyLimit*60)+sum(logsout_gridfre.Values.Data(tIndexPLL:end)<60-frequencyLimit*60)+...
sum(logsout_islandfre.Values.Data(tIndex:end)>60+frequencyLimit*60)+sum(logsout_islandfre.Values.Data(tIndex:end)<60-frequencyLimit*60);
simlog_handles(1) = subplot(4, 1, 2);
plot(logsout_gridfre.Values.Time, logsout_gridfre.Values.Data, 'LineWidth', 1)
plot(logsout_gridfre.Values.Time(tIndexPLL:end), logsout_gridfre.Values.Data(tIndexPLL:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_islandfre.Values.Time, logsout_islandfre.Values.Data, 'LineWidth', 1)
plot(logsout_islandfre.Values.Time(tIndexPLL:end), logsout_islandfre.Values.Data(tIndexPLL:end), 'LineWidth', 1)


grid on
Expand All @@ -95,28 +98,26 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
axis([2 8 58 67])
ylabel('Frequency (Hz)')
legend({'Diesel Frequency', 'Island Frequency','Frequency Limits'},'NumColumns',3);
% legend({'Inverter', 'Diesel'});



simlog_handles(1) = subplot(4, 1, 3);
plot(logsout_gridangle.Values.Time, logsout_gridangle.Values.Data, 'LineWidth', 1)
plot(logsout_gridangle.Values.Time(tIndexPLL:end), logsout_gridangle.Values.Data(tIndexPLL:end), 'LineWidth', 1)
grid on
hold on
plot(logsout_islandangle.Values.Time, logsout_islandangle.Values.Data, 'LineWidth', 1)
plot(logsout_islandangle.Values.Time(tIndexPLL:end), logsout_islandangle.Values.Data(tIndexPLL:end), 'LineWidth', 1)
grid on
title('Diesel and Island Voltage Angle')
ylabel('Angle (deg)')
axis([2 8 -190 190])
legend({'Diesel voltage angle', 'Island voltage angle'},'NumColumns',2);

flag1=sum(logsout_gridvoltage.Values.Data>1+voltageLimit)+sum(logsout_gridvoltage.Values.Data<1-voltageLimit)+...
sum(logsout_islandvoltage.Values.Data>1+voltageLimit)+sum(logsout_islandvoltage.Values.Data<1-voltageLimit);
flag1=sum(logsout_gridvoltage.Values.Data(tIndexPLL:end)>1+voltageLimit)+sum(logsout_gridvoltage.Values.Data(tIndexPLL:end)<1-voltageLimit)+...
sum(logsout_islandvoltage.Values.Data(tIndexPLL:end)>1+voltageLimit)+sum(logsout_islandvoltage.Values.Data(tIndexPLL:end)<1-voltageLimit);
simlog_handles(1) = subplot(4, 1, 4); %#ok<*NASGU>
plot(logsout_gridvoltage.Values.Time, logsout_gridvoltage.Values.Data, 'LineWidth', 1)
plot(logsout_gridvoltage.Values.Time(tIndexPLL:end), logsout_gridvoltage.Values.Data(tIndexPLL:end), 'LineWidth', 1)

hold on
plot(logsout_islandvoltage.Values.Time, logsout_islandvoltage.Values.Data, 'LineWidth', 1,'Color','black')
plot(logsout_islandvoltage.Values.Time(tIndexPLL:end), logsout_islandvoltage.Values.Data(tIndexPLL:end), 'LineWidth', 1,'Color','black')
if flag1>0
plot([2, 8],[1+voltageLimit,1+voltageLimit],'LineWidth',1,'Color','r','LineStyle','-')
plot([2, 8],[1-voltageLimit,1-voltageLimit],'LineWidth',1,'Color','r','LineStyle','-')
Expand Down

0 comments on commit ff58c6e

Please sign in to comment.