diff --git a/Software/PC_Application/Calibration/calkit.cpp b/Software/PC_Application/Calibration/calkit.cpp index d02dd58..3fa14b5 100644 --- a/Software/PC_Application/Calibration/calkit.cpp +++ b/Software/PC_Application/Calibration/calkit.cpp @@ -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(Load.Z0, 0); + auto imp_load = complex(Load.resistance, 0); // Add parallel capacitor to impedance if(Load.Cparallel > 0) { auto imp_C = complex(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(0, frequency * 2 * M_PI * Load.Lseries); imp_load += imp_L; ref.Load = (imp_load - complex(50.0)) / (imp_load + complex(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) { diff --git a/Software/PC_Application/Calibration/calkit.h b/Software/PC_Application/Calibration/calkit.h index 5502cf9..8e3fc85 100644 --- a/Software/PC_Application/Calibration/calkit.h +++ b/Software/PC_Application/Calibration/calkit.h @@ -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 json_descr = {{ + const std::array 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}, diff --git a/Software/PC_Application/Calibration/calkitdialog.cpp b/Software/PC_Application/Calibration/calkitdialog.cpp index cd84de7..6d66a62 100644 --- a/Software/PC_Application/Calibration/calkitdialog.cpp +++ b/Software/PC_Application/Calibration/calkitdialog.cpp @@ -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); diff --git a/Software/PC_Application/Calibration/calkitdialog.ui b/Software/PC_Application/Calibration/calkitdialog.ui index bef6c3d..3cb705d 100644 --- a/Software/PC_Application/Calibration/calkitdialog.ui +++ b/Software/PC_Application/Calibration/calkitdialog.ui @@ -722,7 +722,7 @@ - 0 + 1 @@ -762,50 +762,60 @@ - + Z0: - + true - + Offset delay [ps]: - + - + Parallel C: - + - + Series L: - + + + + + Resistance: + + + + + + @@ -859,50 +869,60 @@ - + Z0: - + true - + Offset delay [ps]: - + - + Parallel C: - + - + Series L: - + + + + + Resistance: + + + + + + @@ -1456,12 +1476,12 @@ - - - - + + + +