option for zero-length through

This commit is contained in:
Jan Käberich 2021-12-02 22:41:51 +01:00
parent 0908cd7fbd
commit ecf994cf4a
4 changed files with 96 additions and 4 deletions

View File

@ -27,6 +27,7 @@ Calibration::Calibration()
type = Type::None;
port1Standard = port2Standard = PortStandard::Male;
throughZeroLength = false;
}
Calibration::Standard Calibration::getPort1Standard(Calibration::Measurement m)
@ -141,6 +142,10 @@ bool Calibration::constructErrorTerms(Calibration::Type type)
port1Standard = PortStandard::Male;
port2Standard = PortStandard::Male;
}
if(port1Standard == port2Standard) {
// unable to use zero-length through
throughZeroLength = false;
}
switch(type) {
case Type::Port1SOL: constructPort1SOL(); break;
case Type::Port2SOL: constructPort2SOL(); break;
@ -194,6 +199,14 @@ void Calibration::construct12TermPoints()
p.fe30 = S21_isolation;
// See page 18 of https://www.rfmentor.com/sites/default/files/NA_Error_Models_and_Cal_Methods.pdf
// Formulas for S11M and S21M solved for e22 and e10e32
if (throughZeroLength) {
// use ideal through
actual.ThroughS11 = 0.0;
actual.ThroughS12 = 1.0;
actual.ThroughS21 = 1.0;
actual.ThroughS22 = 0.0;
}
auto deltaS = actual.ThroughS11*actual.ThroughS22 - actual.ThroughS21 * actual.ThroughS12;
p.fe22 = ((S11_through - p.fe00)*(1.0 - p.fe11 * actual.ThroughS11)-actual.ThroughS11*p.fe10e01)
/ ((S11_through - p.fe00)*(actual.ThroughS22-p.fe11*deltaS)-deltaS*p.fe10e01);
@ -859,6 +872,16 @@ QString Calibration::descriptiveCalName(){
return tmp;
}
bool Calibration::getThroughZeroLength() const
{
return throughZeroLength;
}
void Calibration::setThroughZeroLength(bool value)
{
throughZeroLength = value;
}
double Calibration::getMinFreq(){
return this->minFreq;
}
@ -900,6 +923,7 @@ nlohmann::json Calibration::toJSON()
j["type"] = TypeToString(getType()).toStdString();
j["port1StandardMale"] = port1Standard == PortStandard::Male;
j["port2StandardMale"] = port2Standard == PortStandard::Male;
j["throughZeroLength"] = throughZeroLength;
return j;
}
@ -910,6 +934,7 @@ void Calibration::fromJSON(nlohmann::json j)
resetErrorTerms();
port1Standard = j.value("port1StandardMale", true) ? PortStandard::Male : PortStandard::Female;
port2Standard = j.value("port2StandardMale", true) ? PortStandard::Male : PortStandard::Female;
throughZeroLength = j.value("throughZeroLength", false);
if(j.contains("measurements")) {
// grab measurements
for(auto j_m : j["measurements"]) {
@ -981,6 +1006,11 @@ ostream& operator<<(ostream &os, const Calibration &c)
istream& operator >>(istream &in, Calibration &c)
{
// old file format did not contain port standard gender, set default
c.port1Standard = Calibration::PortStandard::Male;
c.port2Standard = Calibration::PortStandard::Male;
c.throughZeroLength = false;
std::string line;
while(getline(in, line)) {
QString qLine = QString::fromStdString(line).simplified();
@ -1020,9 +1050,6 @@ istream& operator >>(istream &in, Calibration &c)
}
}
}
// old file format did not contain port standard gender, set default
c.port1Standard = Calibration::PortStandard::Male;
c.port2Standard = Calibration::PortStandard::Male;
qDebug() << "Calibration file parsing complete";
return in;
}

View File

@ -115,6 +115,8 @@ public:
};
void setPortStandard(int port, PortStandard standard);
PortStandard getPortStandard(int port);
bool getThroughZeroLength() const;
void setThroughZeroLength(bool value);
QString getCurrentCalibrationFile();
double getMinFreq();
@ -176,6 +178,7 @@ private:
QString currentCalFile;
PortStandard port1Standard, port2Standard;
bool throughZeroLength;
};
#endif // CALIBRATION_H

View File

@ -26,12 +26,26 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d
ui->tableView->setColumnWidth(3, 160);
UpdateCalibrationStatus();
auto updateThroughStandardUI = [=](){
if(cal->getPortStandard(1) == cal->getPortStandard(2)) {
// same gender on both ports, can't use zero length through
ui->throughCalkit->click();
ui->throughZero->setEnabled(false);
ui->throughCalkit->setEnabled(false);
} else {
// user may select option for through
ui->throughZero->setEnabled(true);
ui->throughCalkit->setEnabled(true);
}
};
connect(ui->port1Group, qOverload<int>(&QButtonGroup::buttonClicked), [=](){
if(ui->port1Male->isChecked()) {
cal->setPortStandard(1, Calibration::PortStandard::Male);
} else {
cal->setPortStandard(1, Calibration::PortStandard::Female);
}
updateThroughStandardUI();
UpdateCalibrationStatus();
});
@ -41,6 +55,16 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d
} else {
cal->setPortStandard(2, Calibration::PortStandard::Female);
}
updateThroughStandardUI();
UpdateCalibrationStatus();
});
connect(ui->throughGroup, qOverload<int>(&QButtonGroup::buttonClicked), [=](){
if(ui->throughZero->isChecked()) {
cal->setThroughZeroLength(true);
} else {
cal->setThroughZeroLength(false);
}
UpdateCalibrationStatus();
});
@ -48,9 +72,11 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d
if(!cal->getCalibrationKit().hasSeparateMaleFemaleStandards()) {
ui->port1Standards->hide();
ui->port2Standards->hide();
ui->throughStandard->hide();
// default selection is male
ui->port1Male->click();
ui->port2Male->click();
ui->throughCalkit->click();
} else {
// separate standards defined
if(cal->getPortStandard(1) == Calibration::PortStandard::Male) {
@ -63,6 +89,12 @@ CalibrationTraceDialog::CalibrationTraceDialog(Calibration *cal, double f_min, d
} else {
ui->port2Female->setChecked(true);
}
if(cal->getThroughZeroLength()) {
ui->throughZero->setChecked(true);
} else {
ui->throughCalkit->setChecked(true);
}
updateThroughStandardUI();
}
// Check calibration kit span

View File

@ -18,7 +18,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QGroupBox" name="port1Standards">
<property name="title">
@ -77,6 +77,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="throughStandard">
<property name="title">
<string>Through Standard</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="throughCalkit">
<property name="text">
<string>From calibration kit</string>
</property>
<attribute name="buttonGroup">
<string notr="true">throughGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="throughZero">
<property name="text">
<string>Zero-length through</string>
</property>
<attribute name="buttonGroup">
<string notr="true">throughGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -173,5 +202,6 @@
<buttongroups>
<buttongroup name="port1Group"/>
<buttongroup name="port2Group"/>
<buttongroup name="throughGroup"/>
</buttongroups>
</ui>