Fix impedance renormalization and honor new reference impedance for traces

This commit is contained in:
Jan Käberich 2024-03-01 09:08:37 +01:00
parent 542b07f52c
commit 358872904e
5 changed files with 20 additions and 9 deletions

View File

@ -151,7 +151,7 @@ void Trace::addData(const Trace::Data &d, const DeviceDriver::SASettings &s, int
addData(d, domain, 50.0, index);
}
void Trace::addDeembeddingData(const Trace::Data &d, int index)
void Trace::addDeembeddingData(const Trace::Data &d, double reference_impedance, int index)
{
bool wasAvailable = deembeddingAvailable();
if(index >= 0) {
@ -179,6 +179,7 @@ void Trace::addDeembeddingData(const Trace::Data &d, int index)
deembeddingData.insert(lower, d);
}
}
deembedded_reference_impedance = reference_impedance;
if(deembeddingActive) {
emit outputSamplesChanged(index, index + 1);
}
@ -687,7 +688,11 @@ void Trace::setModel(TraceModel *model)
double Trace::getReferenceImpedance() const
{
return reference_impedance;
if(deembeddingActive) {
return deembedded_reference_impedance;
} else {
return reference_impedance;
}
}
const std::vector<Trace::MathInfo>& Trace::getMathOperations() const
@ -1316,6 +1321,10 @@ bool Trace::deembeddingAvailable()
void Trace::setDeembeddingActive(bool active)
{
if(active == deembeddingActive) {
// no change
return;
}
deembeddingActive = active;
if(deembeddingAvailable()) {
if(active) {
@ -1330,6 +1339,7 @@ void Trace::setDeembeddingActive(bool active)
void Trace::clearDeembedding()
{
deembeddingData.clear();
setDeembeddingActive(false);
deembeddingChanged();
}

View File

@ -46,7 +46,7 @@ public:
void clear(bool force = false);
void addData(const Data& d, DataType domain, double reference_impedance = 50.0, int index = -1);
void addData(const Data& d, const DeviceDriver::SASettings &s, int index = -1);
void addDeembeddingData(const Data& d, int index = -1);
void addDeembeddingData(const Data& d, double reference_impedance = 50.0, int index = -1);
void setName(QString name);
void setVelocityFactor(double v);
void fillFromTouchstone(Touchstone &t, unsigned int parameter);
@ -288,6 +288,7 @@ private:
// de-embedding variables
std::vector<Data> deembeddingData;
bool deembeddingActive;
double deembedded_reference_impedance;
std::vector<MathInfo> mathOps;
TraceMath *lastMath;

View File

@ -314,7 +314,7 @@ void TraceModel::addVNAData(const DeviceDriver::VNAMeasurement& d, TraceMath::Da
if(!deembedded) {
t->addData(td, datatype, d.Z0, index);
} else {
t->addDeembeddingData(td, index);
t->addDeembeddingData(td, d.Z0, index);
}
}
}

View File

@ -46,7 +46,7 @@ void ImpedanceRenormalization::transformDatapoint(DeviceDriver::VNAMeasurement &
for(auto i=1;i<=ports;i++) {
auto S11name = "S"+QString::number(i)+QString::number(i);
auto S11 = p.measurements[S11name];
transformed[S11name] = Sparam(ABCDparam(Sparam(S11, 0.0, 0.0, 1.0), p.Z0), impedance).m11;
transformed[S11name] = Sparam(ABCDparam(Sparam(S11, 0.1, 0.1, 1.0), p.Z0), impedance).m11;
for(auto j=i+1;j<=ports;j++) {
auto S12name = "S"+QString::number(i)+QString::number(j);
auto S21name = "S"+QString::number(j)+QString::number(i);

View File

@ -94,10 +94,6 @@ VNA::VNA(AppWindow *window, QString name)
connect(calLoad, &QAction::triggered, [=](){
LoadCalibration();
if(window->getDevice() && !cal.validForDevice(window->getDevice()->getSerial())) {
InformationBox::ShowMessage("Invalid calibration", "The selected calibration was created for a different device. You can still load it but the resulting "
"data likely isn't useful.");
}
if(cal.getCaltype().type != Calibration::Type::None) {
if(InformationBox::AskQuestion("Adjust span?", "Do you want to adjust the span to match the loaded calibration file?", false)) {
SpanMatchCal();
@ -510,6 +506,10 @@ VNA::VNA(AppWindow *window, QString name)
calApplyToTraces->setEnabled(true);
bMatchCal->setEnabled(true);
saveCal->setEnabled(true);
if(window->getDevice() && !cal.validForDevice(window->getDevice()->getSerial())) {
InformationBox::ShowMessage("Invalid calibration", "The selected calibration was created for a different device. You can still load it but the resulting "
"data likely isn't useful.");
}
});
tb_cal->addWidget(cbType);