mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-01-11 03:00:26 +01:00
Improve taking de-embedding measurements
- Automatically restart measurement even when the sweep was stopped - Fix crash due to zeroed de-embedding reference impedance - Fix crash due to not cleaned up dialog pointer with dangling connections - Automatically excite the correct ports for the measurement
This commit is contained in:
parent
e1168f2a32
commit
fe08937bb7
|
|
@ -37,6 +37,7 @@ Trace::Trace(QString name, QColor color, QString live)
|
|||
reference_impedance(50.0),
|
||||
domain(DataType::Frequency),
|
||||
deembeddingActive(false),
|
||||
deembedded_reference_impedance(50.0),
|
||||
lastMath(nullptr)
|
||||
{
|
||||
settings.valid = false;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ void Deembedding::startMeasurementDialog(DeembeddingOption *option)
|
|||
measurementUI = ui;
|
||||
ui->setupUi(measurementDialog);
|
||||
connect(measurementDialog, &QDialog::finished, [=](){
|
||||
if(measuring) {
|
||||
measuring = false;
|
||||
emit finishedMeasurement();
|
||||
}
|
||||
measuringOption = nullptr;
|
||||
measurementUI = nullptr;
|
||||
delete ui;
|
||||
});
|
||||
|
||||
|
|
@ -52,6 +58,7 @@ void Deembedding::startMeasurementDialog(DeembeddingOption *option)
|
|||
traceChooser->setEnabled(false);
|
||||
ui->buttonBox->setEnabled(false);
|
||||
measuring = true;
|
||||
emit triggerMeasurement();
|
||||
});
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){
|
||||
|
|
@ -128,15 +135,6 @@ Deembedding::Deembedding(TraceModel &tm)
|
|||
|
||||
void Deembedding::Deembed(DeviceDriver::VNAMeasurement &d)
|
||||
{
|
||||
// figure out the point in one sweep based on the incomig pointNums
|
||||
static unsigned lastPointNum;
|
||||
if (d.pointNum == 0) {
|
||||
sweepPoints = lastPointNum;
|
||||
} else if(d.pointNum > sweepPoints) {
|
||||
sweepPoints = d.pointNum;
|
||||
}
|
||||
lastPointNum = d.pointNum;
|
||||
|
||||
for(auto it = options.begin();it != options.end();it++) {
|
||||
if (measuring && measuringOption == *it) {
|
||||
// this option needs a measurement
|
||||
|
|
@ -144,14 +142,17 @@ void Deembedding::Deembed(DeviceDriver::VNAMeasurement &d)
|
|||
if(measurements.size() == 0) {
|
||||
// this is the first point of the measurement
|
||||
measurements.push_back(d);
|
||||
} else {
|
||||
// this is the first point of the next sweep, measurement complete
|
||||
measuring = false;
|
||||
measurementCompleted();
|
||||
}
|
||||
} else if(measurements.size() > 0) {
|
||||
// in the middle of the measurement, add point
|
||||
measurements.push_back(d);
|
||||
|
||||
if(d.pointNum == sweepPoints - 1) {
|
||||
// this is the last point, measurement complete
|
||||
measuring = false;
|
||||
emit finishedMeasurement();
|
||||
measurementCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
if(measurementUI) {
|
||||
|
|
@ -223,6 +224,11 @@ void Deembedding::clear()
|
|||
}
|
||||
}
|
||||
|
||||
bool Deembedding::isMeasuring()
|
||||
{
|
||||
return measuring;
|
||||
}
|
||||
|
||||
std::set<unsigned int> Deembedding::getAffectedPorts()
|
||||
{
|
||||
set<unsigned int> ret;
|
||||
|
|
@ -233,6 +239,11 @@ std::set<unsigned int> Deembedding::getAffectedPorts()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Deembedding::setPointsInSweepForMeasurement(unsigned int points)
|
||||
{
|
||||
sweepPoints = points;
|
||||
}
|
||||
|
||||
nlohmann::json Deembedding::toJSON()
|
||||
{
|
||||
nlohmann::json list;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ public:
|
|||
void swapOptions(unsigned int index);
|
||||
void clear();
|
||||
|
||||
bool isMeasuring();
|
||||
|
||||
std::set<unsigned int> getAffectedPorts();
|
||||
void setPointsInSweepForMeasurement(unsigned int points);
|
||||
|
||||
std::vector<DeembeddingOption*>& getOptions() {return options;}
|
||||
nlohmann::json toJSON() override;
|
||||
|
|
@ -38,7 +41,8 @@ public:
|
|||
public slots:
|
||||
void configure();
|
||||
signals:
|
||||
void triggerMeasurement(bool S11 = true, bool S12 = true, bool S21 = true, bool S22 = true);
|
||||
void triggerMeasurement();
|
||||
void finishedMeasurement();
|
||||
void optionAdded();
|
||||
void allOptionsCleared();
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -192,6 +192,18 @@ VNA::VNA(AppWindow *window, QString name)
|
|||
enableDeembeddingAction->setEnabled(false);
|
||||
manualDeembed->setEnabled(false);
|
||||
});
|
||||
connect(&deembedding, &Deembedding::triggerMeasurement, [=]() {
|
||||
// de-embedding measurement requested
|
||||
wasRunningBeforeDeembeddingMeasurement = running;
|
||||
Run();
|
||||
});
|
||||
connect(&deembedding, &Deembedding::finishedMeasurement, [=](){
|
||||
if(wasRunningBeforeDeembeddingMeasurement) {
|
||||
Run();
|
||||
} else {
|
||||
Stop();
|
||||
}
|
||||
});
|
||||
|
||||
// Tools menu
|
||||
auto toolsMenu = new QMenu("Tools", window);
|
||||
|
|
@ -1220,6 +1232,7 @@ void VNA::SetPoints(unsigned int points)
|
|||
settings.activeSegment = 0;
|
||||
}
|
||||
emit pointsChanged(points);
|
||||
deembedding.setPointsInSweepForMeasurement(points);
|
||||
settings.npoints = points;
|
||||
SettingsChanged();
|
||||
}
|
||||
|
|
@ -1799,9 +1812,18 @@ void VNA::ConfigureDevice(bool resetTraces, std::function<void(bool)> cb)
|
|||
s.excitedPorts.push_back(i);
|
||||
}
|
||||
} else {
|
||||
for(unsigned int i=1;i<=DeviceDriver::getInfo(window->getDevice()).Limits.VNA.ports;i++) {
|
||||
if(traceModel.PortExcitationRequired(i))
|
||||
s.excitedPorts.push_back(i);
|
||||
if(deembedding.isMeasuring()) {
|
||||
// use the required ports for the de-embedding measurement
|
||||
for(auto p : deembedding.getAffectedPorts()) {
|
||||
s.excitedPorts.push_back(p);
|
||||
}
|
||||
} else {
|
||||
// use the required ports from the trace model
|
||||
for(unsigned int i=1;i<=DeviceDriver::getInfo(window->getDevice()).Limits.VNA.ports;i++) {
|
||||
if(traceModel.PortExcitationRequired(i)) {
|
||||
s.excitedPorts.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
settings.excitedPorts = s.excitedPorts;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ private:
|
|||
Deembedding deembedding;
|
||||
QAction *enableDeembeddingAction;
|
||||
bool deembedding_active;
|
||||
bool wasRunningBeforeDeembeddingMeasurement;
|
||||
|
||||
// Status Labels
|
||||
QLabel *lAverages;
|
||||
|
|
|
|||
Loading…
Reference in a new issue