Skip to content

Commit b672758

Browse files
committed
consider internal reflection path for matching network
1 parent a84d8de commit b672758

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

Software/PC_Application/LibreVNA-GUI/VNA/Deembedding/matchingnetwork.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "unit.h"
55
#include "CustomWidgets/informationbox.h"
66
#include "appwindow.h"
7+
#include "Util/util.h"
78

89
#include <QDialog>
910
#include <QHBoxLayout>
@@ -54,6 +55,17 @@ void MatchingNetwork::transformDatapoint(VirtualDevice::VNAMeasurement &p)
5455
// at this point the map contains the matching network effect
5556
auto m = matching[p.frequency];
5657
VirtualDevice::VNAMeasurement uncorrected = p;
58+
59+
auto portReflectionName = "S"+QString::number(port)+QString::number(port);
60+
if(!uncorrected.measurements.count(portReflectionName)) {
61+
// the reflection measurement for the port to de-embed is not included, nothing can be done
62+
return;
63+
}
64+
// calculate internal reflection at the matching port
65+
auto portReflectionS = uncorrected.measurements[portReflectionName];
66+
auto matchingReflectionS = Sparam(m.forward, p.Z0).m22;
67+
auto internalPortReflectionS = matchingReflectionS / (1.0 - matchingReflectionS * portReflectionS);
68+
5769
// handle the measurements
5870
for(auto &meas : p.measurements) {
5971
QString name = meas.first;
@@ -78,9 +90,20 @@ void MatchingNetwork::transformDatapoint(VirtualDevice::VNAMeasurement &p)
7890
}
7991
} else {
8092
// through measurement
81-
// Already handled by reflection measurement (toSparam uses S12/S21 as well)
82-
// and if the corresponding reflection measurement is not available, we can't
83-
// do anything anyway
93+
if(i != port && j != port) {
94+
try {
95+
// find through measurements from these two ports to and from the embedding port
96+
auto toPort = uncorrected.measurements["S"+QString::number(port)+QString::number(j)];
97+
auto fromPort = uncorrected.measurements["S"+QString::number(i)+QString::number(port)];
98+
p.measurements[name] = p.measurements[name] + toPort * internalPortReflectionS * fromPort;
99+
} catch (...) {
100+
// missing measurements, nothing can be done
101+
}
102+
} else {
103+
// Already handled by reflection measurement (toSparam uses S12/S21 as well)
104+
// and if the corresponding reflection measurement is not available, we can't
105+
// do anything anyway
106+
}
84107
}
85108
}
86109
}

0 commit comments

Comments
 (0)