Skip to content

Commit ff58c6e

Browse files
committed
Adding a filter to frequency measurements in remote microgrid
1 parent be73156 commit ff58c6e

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

Models/RemoteMicrogrid.slx

1.71 KB
Binary file not shown.

ScriptData/Remote Microgrid/remoteMicrogridPlotFreAngle.m

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
44
%
55
% This plot shows the differences (Diesel and microgrid side) in voltage magnitude, frequency, and phase angle.
66

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

2828
simlog_handles(1) = subplot(4, 1, 1);
29-
29+
% Neglect the initial data to avoid transients
30+
tPlot = 2;
31+
tIndex = find(logsout_islandcommand.Values.Time > tPlot,1);
32+
tIndexPLL = find(logsout_gridfre.Values.Time > tPlot,1);
3033
% selecting the plot
3134
switch caseNum
3235
case 3
3336
% Plot results
34-
plot(logsout_islandcommand.Values.Time, logsout_islandcommand.Values.Data, 'LineWidth', 1)
37+
plot(logsout_islandcommand.Values.Time(tIndex:end), logsout_islandcommand.Values.Data(tIndex:end), 'LineWidth', 1)
3538
grid on
3639
hold on
37-
plot(logsout_islanding.Values.Time, logsout_islanding.Values.Data, 'LineWidth', 1)
40+
plot(logsout_islanding.Values.Time(tIndex:end), logsout_islanding.Values.Data(tIndex:end), 'LineWidth', 1)
3841
grid on
3942
hold on
40-
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
43+
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
4144
grid on
4245
axis([2 8 -0.1 2.5])
4346
title('Planned Island Command and BRK Status')
4447
legend({'Island Command', 'Islanding', 'BRK Status'},'NumColumns',3);
4548

4649
case 4
4750

48-
plot(logsout_resynchcommand.Values.Time, logsout_resynchcommand.Values.Data, 'LineWidth', 1)
51+
plot(logsout_resynchcommand.Values.Time(tIndex:end), logsout_resynchcommand.Values.Data(tIndex:end), 'LineWidth', 1)
4952
grid on
5053
hold on
51-
plot(logsout_resynchronization.Values.Time, logsout_resynchronization.Values.Data, 'LineWidth', 1)
54+
plot(logsout_resynchronization.Values.Time(tIndex:end), logsout_resynchronization.Values.Data(tIndex:end), 'LineWidth', 1)
5255
grid on
5356
hold on
54-
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
57+
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
5558
grid on
5659
axis([2 8 -0.1 2.5])
5760
title(' Resynch Command and BRK Status')
5861
legend({'Resynch Command', 'Resynchronization', 'BRK Status'},'NumColumns',3);
5962

6063
case 5
6164

62-
plot(logsout_fault.Values.Time, logsout_fault.Values.Data, 'LineWidth', 1)
65+
plot(logsout_fault.Values.Time(tIndex:end), logsout_fault.Values.Data(tIndex:end), 'LineWidth', 1)
6366
grid on
6467
hold on
65-
plot(logsout_brkstatus.Values.Time, logsout_brkstatus.Values.Data, 'LineWidth', 1)
68+
plot(logsout_brkstatus.Values.Time(tIndex:end), logsout_brkstatus.Values.Data(tIndex:end), 'LineWidth', 1)
6669
grid on
6770
axis([2 8 -0.1 2.5])
6871
title(' Fault and BRK Status')
6972
legend({'Fault', 'BRK Status'},'NumColumns',2);
7073
end
7174

72-
flag=sum(logsout_gridfre.Values.Data>60+frequencyLimit*60)+sum(logsout_gridfre.Values.Data<60-frequencyLimit*60)+...
73-
sum(logsout_islandfre.Values.Data>60+frequencyLimit*60)+sum(logsout_islandfre.Values.Data<60-frequencyLimit*60);
75+
flag=sum(logsout_gridfre.Values.Data(tIndexPLL:end)>60+frequencyLimit*60)+sum(logsout_gridfre.Values.Data(tIndexPLL:end)<60-frequencyLimit*60)+...
76+
sum(logsout_islandfre.Values.Data(tIndex:end)>60+frequencyLimit*60)+sum(logsout_islandfre.Values.Data(tIndex:end)<60-frequencyLimit*60);
7477
simlog_handles(1) = subplot(4, 1, 2);
75-
plot(logsout_gridfre.Values.Time, logsout_gridfre.Values.Data, 'LineWidth', 1)
78+
plot(logsout_gridfre.Values.Time(tIndexPLL:end), logsout_gridfre.Values.Data(tIndexPLL:end), 'LineWidth', 1)
7679
grid on
7780
hold on
78-
plot(logsout_islandfre.Values.Time, logsout_islandfre.Values.Data, 'LineWidth', 1)
81+
plot(logsout_islandfre.Values.Time(tIndexPLL:end), logsout_islandfre.Values.Data(tIndexPLL:end), 'LineWidth', 1)
7982

8083

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

101102

102103
simlog_handles(1) = subplot(4, 1, 3);
103-
plot(logsout_gridangle.Values.Time, logsout_gridangle.Values.Data, 'LineWidth', 1)
104+
plot(logsout_gridangle.Values.Time(tIndexPLL:end), logsout_gridangle.Values.Data(tIndexPLL:end), 'LineWidth', 1)
104105
grid on
105106
hold on
106-
plot(logsout_islandangle.Values.Time, logsout_islandangle.Values.Data, 'LineWidth', 1)
107+
plot(logsout_islandangle.Values.Time(tIndexPLL:end), logsout_islandangle.Values.Data(tIndexPLL:end), 'LineWidth', 1)
107108
grid on
108109
title('Diesel and Island Voltage Angle')
109110
ylabel('Angle (deg)')
110111
axis([2 8 -190 190])
111112
legend({'Diesel voltage angle', 'Island voltage angle'},'NumColumns',2);
112113

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

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

0 commit comments

Comments
 (0)