mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-06 06:53:37 +00:00
Experimental feature: only excite one port when other traces are paused
This commit is contained in:
parent
44124bc09e
commit
de8761545d
18 changed files with 130 additions and 40 deletions
Binary file not shown.
|
|
@ -279,7 +279,12 @@ Calibration::InterpolationType Calibration::getInterpolation(Protocol::SweepSett
|
|||
return InterpolationType::Extrapolate;
|
||||
}
|
||||
// Either exact or interpolation, check individual frequencies
|
||||
uint32_t f_step = (settings.f_stop - settings.f_start) / (settings.points - 1);
|
||||
uint32_t f_step;
|
||||
if(settings.points > 1) {
|
||||
f_step = (settings.f_stop - settings.f_start) / (settings.points - 1);
|
||||
} else {
|
||||
f_step = settings.f_stop - settings.f_start;
|
||||
}
|
||||
for(uint64_t f = settings.f_start; f <= settings.f_stop; f += f_step) {
|
||||
if(find_if(points.begin(), points.end(), [&f](const Point& p){
|
||||
return abs(f - p.frequency) < 100;
|
||||
|
|
@ -549,8 +554,8 @@ istream& operator >>(istream &in, Calibration &c)
|
|||
} else {
|
||||
throw runtime_error("Incomplete calibration data, the requested \"" + line + "\"-Calibration could not be performed.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return in;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ void TraceModel::togglePause(unsigned int index)
|
|||
traces[index]->pause();
|
||||
}
|
||||
emit dataChanged(createIndex(index, 1), createIndex(index, 1));
|
||||
emit requiredExcitation(PortExcitationRequired(1), PortExcitationRequired(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +110,23 @@ std::vector<Trace *> TraceModel::getTraces()
|
|||
return traces;
|
||||
}
|
||||
|
||||
bool TraceModel::PortExcitationRequired(int port)
|
||||
{
|
||||
for(auto t : traces) {
|
||||
if(t->isLive() && !t->isPaused()) {
|
||||
// this trace needs measurements from VNA, check if port has to be excited for its measurement
|
||||
auto param = t->liveParameter();
|
||||
if(port == 1 && (param == Trace::LiveParameter::S11 || param == Trace::LiveParameter::S21)) {
|
||||
return true;
|
||||
} else if(port == 2 && (param == Trace::LiveParameter::S22 || param == Trace::LiveParameter::S12)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// checked all traces, none requires this port to be excited
|
||||
return false;
|
||||
}
|
||||
|
||||
void TraceModel::clearVNAData()
|
||||
{
|
||||
for(auto t : traces) {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@ public:
|
|||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
std::vector<Trace*> getTraces();
|
||||
|
||||
bool PortExcitationRequired(int port);
|
||||
signals:
|
||||
void traceAdded(Trace *t);
|
||||
void traceRemoved(Trace *t);
|
||||
void requiredExcitation(bool excitePort1, bool excitePort2);
|
||||
|
||||
public slots:
|
||||
void clearVNAData();
|
||||
|
|
|
|||
|
|
@ -43,13 +43,9 @@
|
|||
|
||||
VNA::VNA(AppWindow *window)
|
||||
: Mode(window, "Vector Network Analyzer"),
|
||||
pref(window->getPreferenceRef()),
|
||||
central(new TileWidget(traceModel))
|
||||
{
|
||||
QCoreApplication::setOrganizationName("VNA");
|
||||
QCoreApplication::setApplicationName("Application");
|
||||
|
||||
pref.load();
|
||||
|
||||
averages = 1;
|
||||
calValid = false;
|
||||
calMeasuring = false;
|
||||
|
|
@ -79,6 +75,8 @@ VNA::VNA(AppWindow *window)
|
|||
auto tracebode2 = new TraceBodePlot(traceModel);
|
||||
tracebode2->enableTrace(tS21, true);
|
||||
|
||||
connect(&traceModel, &TraceModel::requiredExcitation, this, &VNA::ExcitationRequired);
|
||||
|
||||
central->splitVertically();
|
||||
central->Child1()->splitHorizontally();
|
||||
central->Child2()->splitHorizontally();
|
||||
|
|
@ -422,6 +420,13 @@ VNA::VNA(AppWindow *window)
|
|||
qRegisterMetaType<Protocol::Datapoint>("Datapoint");
|
||||
|
||||
// Set initial sweep settings
|
||||
if(pref.Acquisition.alwaysExciteBothPorts) {
|
||||
settings.excitePort1 = 1;
|
||||
settings.excitePort2 = 1;
|
||||
} else {
|
||||
settings.excitePort1 = traceModel.PortExcitationRequired(1);
|
||||
settings.excitePort2 = traceModel.PortExcitationRequired(2);
|
||||
}
|
||||
if(pref.Startup.RememberSweepSettings) {
|
||||
LoadSweepSettings();
|
||||
} else {
|
||||
|
|
@ -654,6 +659,22 @@ void VNA::SetAveraging(unsigned int averages)
|
|||
SettingsChanged();
|
||||
}
|
||||
|
||||
void VNA::ExcitationRequired(bool port1, bool port2)
|
||||
{
|
||||
qDebug() << pref.Acquisition.alwaysExciteBothPorts;
|
||||
if(pref.Acquisition.alwaysExciteBothPorts) {
|
||||
port1 = true;
|
||||
port2 = true;
|
||||
}
|
||||
// check if settings actually changed
|
||||
if(settings.excitePort1 != port1
|
||||
|| settings.excitePort2 != port2) {
|
||||
settings.excitePort1 = port1;
|
||||
settings.excitePort2 = port2;
|
||||
SettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void VNA::DisableCalibration(bool force)
|
||||
{
|
||||
if(calValid || force) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ private slots:
|
|||
void SetPoints(unsigned int points);
|
||||
void SetIFBandwidth(double bandwidth);
|
||||
void SetAveraging(unsigned int averages);
|
||||
void ExcitationRequired(bool port1, bool port2);
|
||||
// Calibration
|
||||
void DisableCalibration(bool force = false);
|
||||
void ApplyCalibration(Calibration::Type type);
|
||||
|
|
@ -47,9 +48,8 @@ private:
|
|||
void LoadSweepSettings();
|
||||
void StoreSweepSettings();
|
||||
|
||||
Preferences pref;
|
||||
Preferences &pref;
|
||||
|
||||
QActionGroup *deviceActionGroup;
|
||||
Protocol::SweepSettings settings;
|
||||
unsigned int averages;
|
||||
TraceModel traceModel;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
}
|
||||
});
|
||||
connect(ui->actionPreferences, &QAction::triggered, [=](){
|
||||
qDebug() << pref.Acquisition.alwaysExciteBothPorts;
|
||||
pref.edit();
|
||||
qDebug() << pref.Acquisition.alwaysExciteBothPorts;
|
||||
});
|
||||
|
||||
setWindowTitle("VNA");
|
||||
|
|
@ -248,6 +250,11 @@ void AppWindow::CreateToolbars()
|
|||
addToolBar(tb_reference);
|
||||
}
|
||||
|
||||
Preferences &AppWindow::getPreferenceRef()
|
||||
{
|
||||
return pref;
|
||||
}
|
||||
|
||||
int AppWindow::UpdateDeviceList()
|
||||
{
|
||||
deviceActionGroup->setExclusive(true);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public:
|
|||
QStackedWidget *getCentral() const;
|
||||
Device *getDevice() const;
|
||||
|
||||
Preferences &getPreferenceRef();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
private slots:
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
|
|||
p->Startup.DefaultSweep.bandwidth = ui->StartupSweepBandwidth->value();
|
||||
p->Startup.DefaultSweep.points = ui->StartupSweepPoints->value();
|
||||
p->Startup.DefaultSweep.excitation = ui->StartupSweepLevel->value();
|
||||
p->Acquisition.alwaysExciteBothPorts = ui->AcquisitionAlwaysExciteBoth->isChecked();
|
||||
accept();
|
||||
});
|
||||
|
||||
|
|
@ -90,6 +91,8 @@ void PreferencesDialog::setInitialGUIState()
|
|||
ui->StartupSweepBandwidth->setValueQuiet(p->Startup.DefaultSweep.bandwidth);
|
||||
ui->StartupSweepPoints->setValue(p->Startup.DefaultSweep.points);
|
||||
ui->StartupSweepLevel->setValue(p->Startup.DefaultSweep.excitation);
|
||||
|
||||
ui->AcquisitionAlwaysExciteBoth->setChecked(p->Acquisition.alwaysExciteBothPorts);
|
||||
}
|
||||
|
||||
void Preferences::load()
|
||||
|
|
|
|||
|
|
@ -46,13 +46,16 @@ public:
|
|||
double excitation;
|
||||
} DefaultSweep;
|
||||
} Startup;
|
||||
struct {
|
||||
bool alwaysExciteBothPorts;
|
||||
} Acquisition;
|
||||
private:
|
||||
using SettingDescription = struct {
|
||||
QPointerVariant var;
|
||||
QString name;
|
||||
QVariant def;
|
||||
};
|
||||
const std::array<SettingDescription, 7> descr = {{
|
||||
const std::array<SettingDescription, 8> descr = {{
|
||||
{&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true},
|
||||
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
|
||||
{&Startup.DefaultSweep.start, "Startup.DefaultSweep.start", 1000000.0},
|
||||
|
|
@ -60,6 +63,7 @@ private:
|
|||
{&Startup.DefaultSweep.points, "Startup.DefaultSweep.points", 501},
|
||||
{&Startup.DefaultSweep.bandwidth, "Startup.DefaultSweep.bandwidth", 1000.0},
|
||||
{&Startup.DefaultSweep.excitation, "Startup.DefaultSweep.excitation", -10.00},
|
||||
{&Acquisition.alwaysExciteBothPorts, "Acquisition.alwaysExciteBothPorts", false},
|
||||
}};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@
|
|||
<widget class="QWidget" name="Acquisition">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="AcquisitionAlwaysExciteBoth">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If only S11/S21 or S22/S12 are enabled, faster sweeps are possible by only exciting one port. Checking this option forces the device to always excite both ports even when the measurements from one port will not be used.</p></body></html></string>
|
||||
</property>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue