diff --git a/Documentation/UserManual/manual.pdf b/Documentation/UserManual/manual.pdf index 56e8cc5..ce21abd 100644 Binary files a/Documentation/UserManual/manual.pdf and b/Documentation/UserManual/manual.pdf differ diff --git a/Documentation/UserManual/manual.tex b/Documentation/UserManual/manual.tex index 0a02c64..061fdc0 100644 --- a/Documentation/UserManual/manual.tex +++ b/Documentation/UserManual/manual.tex @@ -314,7 +314,7 @@ The control elements are mostly identical to the vector network analyzer mode, a \end{center} \begin{itemize} \item \textbf{RBW:} Resolution bandwidth. Lower values allow differentiating between signals at closer frequencies. Lower values also result in a reduced noisefloor but significantly increase sweep time. -\item \textbf{Window:} Window type used in the DFT of the final IF. Can be left at "Kaiser" for almost all applications. +\item \textbf{Window:} Window type used in the DFT of the final IF. \item \textbf{Detector:} For every point displayed, several measurements are taken. The detector type determines which one of these measurement will be displayed. \item \textbf{Signal ID:} Signal identification. This can help to determine whether a displayed signal is actually present or the result from internal imaging. When enabled, the \vna{} changes the LO frequencies for every measurement point and observes how the final IF signal is affected by that. This removes almost all of the mirror images but at the cost of increased sweep time. diff --git a/Software/PC_Application/Generator/generator.cpp b/Software/PC_Application/Generator/generator.cpp index fa3659d..866ae37 100644 --- a/Software/PC_Application/Generator/generator.cpp +++ b/Software/PC_Application/Generator/generator.cpp @@ -1,13 +1,35 @@ #include "generator.h" +#include Generator::Generator(AppWindow *window) : Mode(window, "Signal Generator") { central = new SignalgeneratorWidget(); + + // set initial values + if(pref.Startup.RememberSweepSettings) { + QSettings s; + central->setFrequency(s.value("GeneratorFrequency", pref.Startup.Generator.frequency).toDouble()); + central->setLevel(s.value("GeneratorLevel", pref.Startup.Generator.level).toDouble()); + } else { + central->setFrequency(pref.Startup.Generator.frequency); + central->setLevel(pref.Startup.Generator.level); + } + finalize(central); connect(central, &SignalgeneratorWidget::SettingsChanged, this, &Generator::updateDevice); } +void Generator::deactivate() +{ + // store current settings + QSettings s; + auto settings = central->getDeviceStatus(); + s.setValue("GeneratorFrequency", static_cast(settings.frequency)); + s.setValue("GeneratorLevel", static_cast((double) settings.cdbm_level / 100.0)); + Mode::deactivate(); +} + void Generator::initializeDevice() { updateDevice(); @@ -16,7 +38,7 @@ void Generator::initializeDevice() void Generator::updateDevice() { if(!window->getDevice()) { - // can't updat if not connected + // can't update if not connected return; } // TODO comment in once status is filled with valid values diff --git a/Software/PC_Application/Generator/generator.h b/Software/PC_Application/Generator/generator.h index fe123d9..b884b89 100644 --- a/Software/PC_Application/Generator/generator.h +++ b/Software/PC_Application/Generator/generator.h @@ -8,6 +8,7 @@ class Generator : public Mode { public: Generator(AppWindow *window); + void deactivate() override; void initializeDevice() override; private slots: void updateDevice(); diff --git a/Software/PC_Application/Generator/signalgenwidget.cpp b/Software/PC_Application/Generator/signalgenwidget.cpp index 25ce633..2ae95de 100644 --- a/Software/PC_Application/Generator/signalgenwidget.cpp +++ b/Software/PC_Application/Generator/signalgenwidget.cpp @@ -68,3 +68,8 @@ void SignalgeneratorWidget::setLevel(double level) SettingsChanged(); } +void SignalgeneratorWidget::setFrequency(double frequency) +{ + ui->frequency->setValue(frequency); +} + diff --git a/Software/PC_Application/Generator/signalgenwidget.h b/Software/PC_Application/Generator/signalgenwidget.h index 4e91aff..909d474 100644 --- a/Software/PC_Application/Generator/signalgenwidget.h +++ b/Software/PC_Application/Generator/signalgenwidget.h @@ -21,8 +21,9 @@ public: signals: void SettingsChanged(); -private slots: +public slots: void setLevel(double level); + void setFrequency(double frequency); private: Ui::SignalgeneratorWidget *ui; }; diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index f31a117..b5a9636 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -43,7 +43,6 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) : Mode(window, "Spectrum Analyzer"), - pref(window->getPreferenceRef()), central(new TileWidget(traceModel)) { averages = 1; @@ -130,7 +129,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) tb_acq->addWidget(eBandwidth); tb_acq->addWidget(new QLabel("Window:")); - auto cbWindowType = new QComboBox(); + cbWindowType = new QComboBox(); cbWindowType->addItem("None"); cbWindowType->addItem("Kaiser"); cbWindowType->addItem("Hann"); @@ -143,7 +142,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) tb_acq->addWidget(cbWindowType); tb_acq->addWidget(new QLabel("Detector:")); - auto cbDetector = new QComboBox(); + cbDetector = new QComboBox(); cbDetector->addItem("+Peak"); cbDetector->addItem("-Peak"); cbDetector->addItem("Sample"); @@ -156,7 +155,7 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) }); tb_acq->addWidget(cbDetector); - auto cbSignalID = new QCheckBox("Signal ID"); + cbSignalID = new QCheckBox("Signal ID"); connect(cbSignalID, &QCheckBox::toggled, [=](bool enabled) { settings.SignalID = enabled; SettingsChanged(); @@ -185,19 +184,18 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) qRegisterMetaType("SpectrumResult"); // Set initial sweep settings - // TODO -// if(pref.Startup.RememberSweepSettings) { -// LoadSweepSettings(); -// } else { - settings.f_start = 950000000; - settings.f_stop = 1050000000; + if(pref.Startup.RememberSweepSettings) { + LoadSweepSettings(); + } else { + settings.f_start = pref.Startup.SA.start; + settings.f_stop = pref.Startup.SA.stop; ConstrainAndUpdateFrequencies(); - SetRBW(10000); + SetRBW(pref.Startup.SA.RBW); settings.pointNum = 1001; - settings.WindowType = 1; - settings.Detector = 0; - settings.SignalID = 0; -// } + cbWindowType->setCurrentIndex(pref.Startup.SA.window); + cbDetector->setCurrentIndex(pref.Startup.SA.detector); + cbSignalID->setChecked(pref.Startup.SA.signalID); + } finalize(central); } @@ -365,23 +363,24 @@ void SpectrumAnalyzer::ConstrainAndUpdateFrequencies() void SpectrumAnalyzer::LoadSweepSettings() { - // TODO -// QSettings s; -// settings.f_start = s.value("SweepStart", pref.Startup.DefaultSweep.start).toULongLong(); -// settings.f_stop = s.value("SweepStop", pref.Startup.DefaultSweep.stop).toULongLong(); -// ConstrainAndUpdateFrequencies(); -// SetIFBandwidth(s.value("SweepBandwidth", pref.Startup.DefaultSweep.bandwidth).toUInt()); -// SetPoints(s.value("SweepPoints", pref.Startup.DefaultSweep.points).toInt()); -// SetSourceLevel(s.value("SweepLevel", pref.Startup.DefaultSweep.excitation).toDouble()); + QSettings s; + settings.f_start = s.value("SAStart", pref.Startup.SA.start).toULongLong(); + settings.f_stop = s.value("SAStop", pref.Startup.SA.stop).toULongLong(); + ConstrainAndUpdateFrequencies(); + SetRBW(s.value("SARBW", pref.Startup.SA.RBW).toUInt()); + settings.pointNum = 1001; + cbWindowType->setCurrentIndex(s.value("SAWindow", pref.Startup.SA.window).toInt()); + cbDetector->setCurrentIndex(s.value("SADetector", pref.Startup.SA.detector).toInt()); + cbSignalID->setChecked(s.value("SASignalID", pref.Startup.SA.signalID).toBool()); } void SpectrumAnalyzer::StoreSweepSettings() { - // TODO -// QSettings s; -// s.setValue("SweepStart", static_cast(settings.f_start)); -// s.setValue("SweepStop", static_cast(settings.f_stop)); -// s.setValue("SweepBandwidth", settings.if_bandwidth); -// s.setValue("SweepPoints", settings.points); -// s.setValue("SweepLevel", (double) settings.cdbm_excitation / 100.0); + QSettings s; + s.setValue("SAStart", static_cast(settings.f_start)); + s.setValue("SAStop", static_cast(settings.f_stop)); + s.setValue("SARBW", settings.RBW); + s.setValue("SAWindow", settings.WindowType); + s.setValue("SADetector", settings.Detector); + s.setValue("SASignalID", static_cast(settings.SignalID)); } diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h index d64db7b..b67f020 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h @@ -6,6 +6,8 @@ #include "appwindow.h" #include "mode.h" #include "CustomWidgets/tilewidget.h" +#include +#include class SpectrumAnalyzer : public Mode { @@ -39,8 +41,6 @@ private: void LoadSweepSettings(); void StoreSweepSettings(); - Preferences &pref; - Protocol::SpectrumAnalyzerSettings settings; unsigned int averages; TraceModel traceModel; @@ -48,6 +48,8 @@ private: Averaging average; TileWidget *central; + QCheckBox *cbSignalID; + QComboBox *cbWindowType, *cbDetector; signals: void dataChanged(); diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index db99eb8..ef683d1 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -44,7 +44,6 @@ VNA::VNA(AppWindow *window) : Mode(window, "Vector Network Analyzer"), - pref(window->getPreferenceRef()), central(new TileWidget(traceModel)) { averages = 1; diff --git a/Software/PC_Application/VNA/vna.h b/Software/PC_Application/VNA/vna.h index 66eaa6f..0aa89fb 100644 --- a/Software/PC_Application/VNA/vna.h +++ b/Software/PC_Application/VNA/vna.h @@ -48,8 +48,6 @@ private: void LoadSweepSettings(); void StoreSweepSettings(); - Preferences &pref; - Protocol::SweepSettings settings; unsigned int averages; TraceModel traceModel; diff --git a/Software/PC_Application/mode.cpp b/Software/PC_Application/mode.cpp index 977c981..5b05762 100644 --- a/Software/PC_Application/mode.cpp +++ b/Software/PC_Application/mode.cpp @@ -10,6 +10,7 @@ QButtonGroup* Mode::modeButtonGroup = nullptr; Mode::Mode(AppWindow *window, QString name) : window(window), + pref(window->getPreferenceRef()), name(name), central(nullptr) { diff --git a/Software/PC_Application/mode.h b/Software/PC_Application/mode.h index d747c53..eeb558d 100644 --- a/Software/PC_Application/mode.h +++ b/Software/PC_Application/mode.h @@ -29,6 +29,8 @@ protected: std::set toolbars; std::set docks; + Preferences &pref; + private: static Mode *activeMode; static QWidget *cornerWidget; diff --git a/Software/PC_Application/preferences.cpp b/Software/PC_Application/preferences.cpp index 32ee833..e4457b1 100644 --- a/Software/PC_Application/preferences.cpp +++ b/Software/PC_Application/preferences.cpp @@ -22,6 +22,14 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSweepPoints->setEnabled(false); ui->StartupSweepLevel->setEnabled(false); ui->StartupSweepBandwidth->setEnabled(false); + ui->StartupGeneratorFrequency->setEnabled(false); + ui->StartupGeneratorLevel->setEnabled(false); + ui->StartupSAStart->setEnabled(false); + ui->StartupSAStop->setEnabled(false); + ui->StartupSARBW->setEnabled(false); + ui->StartupSAWindow->setEnabled(false); + ui->StartupSADetector->setEnabled(false); + ui->StartupSASignalID->setEnabled(false); }); connect(ui->StartupSweepDefault, &QPushButton::clicked, [=](){ ui->StartupSweepStart->setEnabled(true); @@ -29,6 +37,14 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSweepPoints->setEnabled(true); ui->StartupSweepLevel->setEnabled(true); ui->StartupSweepBandwidth->setEnabled(true); + ui->StartupGeneratorFrequency->setEnabled(true); + ui->StartupGeneratorLevel->setEnabled(true); + ui->StartupSAStart->setEnabled(true); + ui->StartupSAStop->setEnabled(true); + ui->StartupSARBW->setEnabled(true); + ui->StartupSAWindow->setEnabled(true); + ui->StartupSADetector->setEnabled(true); + ui->StartupSASignalID->setEnabled(true); }); ui->StartupSweepStart->setUnit("Hz"); ui->StartupSweepStart->setPrefixes(" kMG"); @@ -36,6 +52,14 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : ui->StartupSweepStop->setPrefixes(" kMG"); ui->StartupSweepBandwidth->setUnit("Hz"); ui->StartupSweepBandwidth->setPrefixes(" k"); + ui->StartupGeneratorFrequency->setUnit("Hz"); + ui->StartupGeneratorFrequency->setPrefixes(" kMG"); + ui->StartupSAStart->setUnit("Hz"); + ui->StartupSAStart->setPrefixes(" kMG"); + ui->StartupSAStop->setUnit("Hz"); + ui->StartupSAStop->setPrefixes(" kMG"); + ui->StartupSARBW->setUnit("Hz"); + ui->StartupSARBW->setPrefixes(" k"); // Page selection connect(ui->treeWidget, &QTreeWidget::currentItemChanged, [=](QTreeWidgetItem *current, QTreeWidgetItem *) { @@ -66,6 +90,14 @@ 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->Startup.Generator.frequency = ui->StartupGeneratorFrequency->value(); + p->Startup.Generator.level = ui->StartupGeneratorLevel->value(); + p->Startup.SA.start = ui->StartupSAStart->value(); + p->Startup.SA.stop = ui->StartupSAStop->value(); + p->Startup.SA.RBW = ui->StartupSARBW->value(); + p->Startup.SA.window = ui->StartupSAWindow->currentIndex(); + p->Startup.SA.detector = ui->StartupSADetector->currentIndex(); + p->Startup.SA.signalID = ui->StartupSASignalID->isChecked(); p->Acquisition.alwaysExciteBothPorts = ui->AcquisitionAlwaysExciteBoth->isChecked(); p->Acquisition.suppressPeaks = ui->AcquisitionSuppressPeaks->isChecked(); accept(); @@ -92,6 +124,14 @@ 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->StartupGeneratorFrequency->setValue(p->Startup.Generator.frequency); + ui->StartupGeneratorLevel->setValue(p->Startup.Generator.level); + ui->StartupSAStart->setValue(p->Startup.SA.start); + ui->StartupSAStop->setValue(p->Startup.SA.stop); + ui->StartupSARBW->setValue(p->Startup.SA.RBW); + ui->StartupSAWindow->setCurrentIndex(p->Startup.SA.window); + ui->StartupSADetector->setCurrentIndex(p->Startup.SA.detector); + ui->StartupSASignalID->setChecked(p->Startup.SA.signalID); ui->AcquisitionAlwaysExciteBoth->setChecked(p->Acquisition.alwaysExciteBothPorts); ui->AcquisitionSuppressPeaks->setChecked(p->Acquisition.suppressPeaks); diff --git a/Software/PC_Application/preferences.h b/Software/PC_Application/preferences.h index aa26efe..7c2bdde 100644 --- a/Software/PC_Application/preferences.h +++ b/Software/PC_Application/preferences.h @@ -45,6 +45,18 @@ public: double bandwidth; double excitation; } DefaultSweep; + struct { + double frequency; + double level; + } Generator; + struct { + double start; + double stop; + double RBW; + int window; + int detector; + bool signalID; + } SA; } Startup; struct { bool alwaysExciteBothPorts; @@ -56,7 +68,7 @@ private: QString name; QVariant def; }; - const std::array descr = {{ + const std::array descr = {{ {&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true}, {&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false}, {&Startup.DefaultSweep.start, "Startup.DefaultSweep.start", 1000000.0}, @@ -64,8 +76,16 @@ private: {&Startup.DefaultSweep.points, "Startup.DefaultSweep.points", 501}, {&Startup.DefaultSweep.bandwidth, "Startup.DefaultSweep.bandwidth", 1000.0}, {&Startup.DefaultSweep.excitation, "Startup.DefaultSweep.excitation", -10.00}, + {&Startup.Generator.frequency, "Startup.Generator.frequency", 1000000000.0}, + {&Startup.Generator.level, "Startup.Generator.level", -10.00}, + {&Startup.SA.start, "Startup.SA.start", 950000000.0}, + {&Startup.SA.stop, "Startup.SA.stop", 1050000000.0}, + {&Startup.SA.RBW, "Startup.SA.RBW", 10000.0}, + {&Startup.SA.window, "Startup.SA.window", 1}, + {&Startup.SA.detector, "Startup.SA.detector", 0}, + {&Startup.SA.signalID, "Startup.SA.signalID", true}, {&Acquisition.alwaysExciteBothPorts, "Acquisition.alwaysExciteBothPorts", true}, - {&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true}, + {&Acquisition.suppressPeaks, "Acquisition.suppressPeaks", true}, }}; }; diff --git a/Software/PC_Application/preferencesdialog.ui b/Software/PC_Application/preferencesdialog.ui index 6588806..14e3a3f 100644 --- a/Software/PC_Application/preferencesdialog.ui +++ b/Software/PC_Application/preferencesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 646 - 543 + 619 + 730 @@ -67,32 +67,35 @@ 16777215 + + 0 + - + - - - When starting the application... - - - - - - Autoconnect to the first device available - - - - - - - Set sweep settings to... - - - - - + + + + + When starting the application... + + - + + + Autoconnect to the first device available + + + + + + + Set to... + + + + + @@ -115,114 +118,294 @@ - - - - - - - - Start: + + + + Qt::Horizontal - - - - - - - - - Stop: + + + 40 + 20 + - - - - - - - - - Level: - - - - - - - dbm - - - -42.000000000000000 - - - -10.000000000000000 - - - 0.250000000000000 - - - - - - - Points: - - - - - - - 1 - - - 4501 - - - 501 - - - - - - - IF bandwitdh: - - - - - + - - - Qt::Horizontal + + + Vector Network Analyzer - - - 40 - 20 - + + + + + Start: + + + + + + + + + + Stop: + + + + + + + + + + Simulus level: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + Points: + + + + + + + 1 + + + 4501 + + + 501 + + + + + + + IF bandwitdh: + + + + + + + + + + + + + Signal Generator - + + + + + Frequency: + + + + + + + + + + Output level: + + + + + + + dbm + + + -42.000000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + + + + Spectrum Analyzer + + + + + + Start: + + + + + + + + + + Stop: + + + + + + + + + + RBW: + + + + + + + + + + Window: + + + + + + + + None + + + + + Kaiser + + + + + Hann + + + + + Flat Top + + + + + + + + Detector: + + + + + + + + +Peak + + + + + -Peak + + + + + Sample + + + + + Normal + + + + + Average + + + + + + + + Signal Identification: + + + + + + + + + + + + - - - + + + + + + Qt::Vertical + + + + 17 + 37 + + + + + - + - Qt::Vertical + Qt::Horizontal - 20 - 40 + 48 + 20 @@ -244,7 +427,7 @@ - <html><head/><body><p>Due to limited fractional divider settings, the source and 1.LO PLLs are not able to reach every frequency exactly. At some specific frequencies this causes the final IF to shift. At these frequencies there will be a positive or negative peak in the trace measurement that is not actually there.<br/><br/>Checking this option shifts the 2.LO for points where this could be an issue. This will remove the peaks but slow down the sweep slightly.</p></body></html> + <html><head/><body><p>Due to limited fractional divider settings, the source and 1.LO PLLs are not able to reach every frequency exactly. At some specific frequencies this causes the final IF to shift. At these frequencies there will be a positive or negative peak in the trace measurement that is not actually there.<br/><br/>Checking this option shifts the 2.LO for points where this could be an issue. This will remove the peaks but slows down the sweep slightly.</p></body></html> Suppress invalid peaks