Separate Z0/resistance entries for load in calibration kit

This commit is contained in:
Jan Käberich 2022-01-14 11:24:41 +01:00
parent dc5cb73b3f
commit d5f2f7019e
4 changed files with 73 additions and 26 deletions

View File

@ -90,6 +90,11 @@ Calkit Calkit::fromFile(QString filename)
throw runtime_error("JSON parsing error: " + string(e.what()));
}
if(j.contains("SOLT")) {
// older file versions specify Z0 for resistance. If resistance entry is missing,
// set it to Z0 later
bool loadResistanceMissing_m = false;
bool loadResistanceMissing_f = false;
qDebug() << "JSON format detected";
// calkit file uses json format, parse
for(auto e : c.json_descr) {
@ -108,6 +113,11 @@ Calkit Calkit::fromFile(QString filename)
if(!entry_exists) {
// missing entry in json file, nothing to do (default values already set in constructor)
qWarning() << "Entry" << e.name << "not present in file, assuming default value";
if(e.name == "SOLT/Load/Param/Resistance") {
loadResistanceMissing_m = true;
} else if(e.name == "SOLT/Load/Param/Resistance_Female") {
loadResistanceMissing_f = true;
}
continue;
}
// json library does not now about QVariant, handle used cases
@ -126,6 +136,15 @@ Calkit Calkit::fromFile(QString filename)
throw runtime_error("Unimplemented metatype");
}
}
// adjust Z0/resistance in case of older calkit file version
if(loadResistanceMissing_f) {
c.SOLT.load_f.resistance = c.SOLT.load_f.Z0;
c.SOLT.load_f.Z0 = 50.0;
}
if(loadResistanceMissing_m) {
c.SOLT.load_m.resistance = c.SOLT.load_m.Z0;
c.SOLT.load_m.Z0 = 50.0;
}
} else {
qDebug() << "Legacy format detected";
// legacy file format, return to beginning of file
@ -149,7 +168,7 @@ Calkit Calkit::fromFile(QString filename)
c.SOLT.short_m.L1 = readLine(file).toDouble();
c.SOLT.short_m.L2 = readLine(file).toDouble();
c.SOLT.short_m.L3 = readLine(file).toDouble();
c.SOLT.load_m.Z0 = readLine(file).toDouble();
c.SOLT.load_m.resistance = readLine(file).toDouble();
c.SOLT.Through.Z0 = readLine(file).toDouble();
c.SOLT.Through.delay = readLine(file).toDouble();
c.SOLT.Through.loss = readLine(file).toDouble();
@ -243,7 +262,7 @@ class Calkit::SOLT Calkit::toSOLT(double frequency, bool male_standards)
if(Load.useMeasurements) {
ref.Load = ts_load->interpolate(frequency).S[0];
} else {
auto imp_load = complex<double>(Load.Z0, 0);
auto imp_load = complex<double>(Load.resistance, 0);
// Add parallel capacitor to impedance
if(Load.Cparallel > 0) {
auto imp_C = complex<double>(0, -1.0 / (frequency * 2 * M_PI * Load.Cparallel));
@ -253,7 +272,7 @@ class Calkit::SOLT Calkit::toSOLT(double frequency, bool male_standards)
auto imp_L = complex<double>(0, frequency * 2 * M_PI * Load.Lseries);
imp_load += imp_L;
ref.Load = (imp_load - complex<double>(50.0)) / (imp_load + complex<double>(50.0));
ref.Load = addTransmissionLine(ref.Load, 50.0, Load.delay*1e-12, 0, frequency);
ref.Load = addTransmissionLine(ref.Load, Load.Z0, Load.delay*1e-12, 0, frequency);
}
if(Open.useMeasurements) {

View File

@ -73,7 +73,7 @@ private:
};
Short short_m, short_f;
using Load = struct {
double Z0, delay, Cparallel, Lseries;
double resistance, Z0, delay, Cparallel, Lseries;
QString file;
bool useMeasurements;
int Sparam;
@ -110,7 +110,7 @@ private:
QString name;
QVariant def;
};
const std::array<JSONDescription, 71> json_descr = {{
const std::array<JSONDescription, 73> json_descr = {{
{&manufacturer, "Manufacturer", ""},
{&serialnumber, "Serialnumber", ""},
{&description, "Description", ""},
@ -157,6 +157,7 @@ private:
{&SOLT.short_f.file, "SOLT/Short/Measurements/File_Female", ""},
{&SOLT.short_f.Sparam, "SOLT/Short/Measurements/Port_Female", 0},
{&SOLT.load_m.resistance, "SOLT/Load/Param/Resistance", 50.0},
{&SOLT.load_m.Z0, "SOLT/Load/Param/Z0", 50.0},
{&SOLT.load_m.delay, "SOLT/Load/Param/Delay", 0.0},
{&SOLT.load_m.Cparallel, "SOLT/Load/Param/C", 0.0},
@ -164,6 +165,7 @@ private:
{&SOLT.load_m.useMeasurements, "SOLT/Load/Measurements/Use", false},
{&SOLT.load_m.file, "SOLT/Load/Measurements/File", ""},
{&SOLT.load_m.Sparam, "SOLT/Load/Measurements/Port", 0},
{&SOLT.load_f.resistance, "SOLT/Load/Param/Resistance_Female", 50.0},
{&SOLT.load_f.Z0, "SOLT/Load/Param/Z0_Female", 50.0},
{&SOLT.load_f.delay, "SOLT/Load/Param/Delay_Female", 0.0},
{&SOLT.load_f.Cparallel, "SOLT/Load/Param/C_Female", 0.0},

View File

@ -42,6 +42,7 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
ui->short_Z0->setUnit("Ω");
ui->open_Z0->setUnit("Ω");
ui->load_resistance->setUnit("Ω");
ui->load_Z0->setUnit("Ω");
ui->load_parC->setUnit("F");
ui->load_parC->setPrefixes("fpnum ");
@ -64,6 +65,7 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) :
ui->short_Z0_f->setUnit("Ω");
ui->open_Z0_f->setUnit("Ω");
ui->load_resistance_f->setUnit("Ω");
ui->load_Z0_f->setUnit("Ω");
ui->load_parC_f->setUnit("F");
ui->load_parC_f->setPrefixes("fpnum ");
@ -247,6 +249,7 @@ void CalkitDialog::parseEntries()
ownKit.SOLT.short_m.L2 = ui->short_L2->value();
ownKit.SOLT.short_m.L3 = ui->short_L3->value();
ownKit.SOLT.load_m.resistance = ui->load_resistance->value();
ownKit.SOLT.load_m.Z0 = ui->load_Z0->value();
ownKit.SOLT.load_m.delay = ui->load_delay->value();
ownKit.SOLT.load_m.Cparallel = ui->load_parC->value();
@ -268,6 +271,7 @@ void CalkitDialog::parseEntries()
ownKit.SOLT.short_f.L2 = ui->short_L2_f->value();
ownKit.SOLT.short_f.L3 = ui->short_L3_f->value();
ownKit.SOLT.load_f.resistance = ui->load_resistance_f->value();
ownKit.SOLT.load_f.Z0 = ui->load_Z0_f->value();
ownKit.SOLT.load_f.delay = ui->load_delay_f->value();
ownKit.SOLT.load_f.Cparallel = ui->load_parC_f->value();
@ -332,6 +336,7 @@ void CalkitDialog::updateEntries()
ui->short_L2->setValueQuiet(ownKit.SOLT.short_m.L2);
ui->short_L3->setValueQuiet(ownKit.SOLT.short_m.L3);
ui->load_resistance->setValueQuiet(ownKit.SOLT.load_m.resistance);
ui->load_Z0->setValueQuiet(ownKit.SOLT.load_m.Z0);
ui->load_delay->setValueQuiet(ownKit.SOLT.load_m.delay);
ui->load_parC->setValueQuiet(ownKit.SOLT.load_m.Cparallel);
@ -353,6 +358,7 @@ void CalkitDialog::updateEntries()
ui->short_L2_f->setValueQuiet(ownKit.SOLT.short_f.L2);
ui->short_L3_f->setValueQuiet(ownKit.SOLT.short_f.L3);
ui->load_resistance_f->setValueQuiet(ownKit.SOLT.load_f.resistance);
ui->load_Z0_f->setValueQuiet(ownKit.SOLT.load_f.Z0);
ui->load_delay_f->setValueQuiet(ownKit.SOLT.load_f.delay);
ui->load_parC_f->setValueQuiet(ownKit.SOLT.load_f.Cparallel);

View File

@ -722,7 +722,7 @@
<item>
<widget class="QTabWidget" name="mf_load">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_7">
<attribute name="title">
@ -762,50 +762,60 @@
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>Z0:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="SIUnitEdit" name="load_Z0">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Offset delay [ps]:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="SIUnitEdit" name="load_delay"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Parallel C:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="SIUnitEdit" name="load_parC"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Series L:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="SIUnitEdit" name="load_serL"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Resistance:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SIUnitEdit" name="load_resistance"/>
</item>
</layout>
</item>
</layout>
@ -859,50 +869,60 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout_12">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_61">
<property name="text">
<string>Z0:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="SIUnitEdit" name="load_Z0_f">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_62">
<property name="text">
<string>Offset delay [ps]:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="SIUnitEdit" name="load_delay_f"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_63">
<property name="text">
<string>Parallel C:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="SIUnitEdit" name="load_parC_f"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_64">
<property name="text">
<string>Series L:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="SIUnitEdit" name="load_serL_f"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Resistance:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SIUnitEdit" name="load_resistance_f"/>
</item>
</layout>
</item>
</layout>
@ -1456,12 +1476,12 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="ThroughType"/>
<buttongroup name="LoadType"/>
<buttongroup name="LoadType_f"/>
<buttongroup name="OpenType_f"/>
<buttongroup name="ShortType"/>
<buttongroup name="OpenType"/>
<buttongroup name="LoadType"/>
<buttongroup name="ShortType"/>
<buttongroup name="ThroughType"/>
<buttongroup name="OpenType_f"/>
<buttongroup name="TRL_Rtype"/>
<buttongroup name="ShortType_f"/>
</buttongroups>