mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-07 23:43:42 +00:00
Log option for frequency sweep
This commit is contained in:
parent
0379040a05
commit
6fd2598ae8
5 changed files with 50 additions and 11 deletions
|
|
@ -298,6 +298,12 @@ VNA::VNA(AppWindow *window)
|
|||
connect(bZoomOut, &QPushButton::clicked, this, &VNA::SpanZoomOut);
|
||||
frequencySweepActions.push_back(tb_sweep->addWidget(bZoomOut));
|
||||
|
||||
auto cbLogSweep = new QCheckBox("Log");
|
||||
cbLogSweep->setToolTip("Logarithmic sweep");
|
||||
connect(cbLogSweep, &QCheckBox::toggled, this, &VNA::SetLogSweep);
|
||||
connect(this, &VNA::logSweepChanged, cbLogSweep, &QCheckBox::setChecked);
|
||||
frequencySweepActions.push_back(tb_sweep->addWidget(cbLogSweep));
|
||||
|
||||
// power sweep widgets
|
||||
auto sbPowerLow = new QDoubleSpinBox();
|
||||
width = QFontMetrics(sbPowerLow->font()).width("-30.00dBm") + 20;
|
||||
|
|
@ -700,6 +706,7 @@ nlohmann::json VNA::toJSON()
|
|||
freq["start"] = settings.Freq.start;
|
||||
freq["stop"] = settings.Freq.stop;
|
||||
freq["power"] = settings.Freq.excitation_power;
|
||||
freq["log"] = settings.Freq.logSweep;
|
||||
sweep["frequency"] = freq;
|
||||
nlohmann::json power;
|
||||
power["start"] = settings.Power.start;
|
||||
|
|
@ -750,6 +757,7 @@ void VNA::fromJSON(nlohmann::json j)
|
|||
SetStartFreq(freq.value("start", settings.Freq.start));
|
||||
SetStopFreq(freq.value("stop", settings.Freq.stop));
|
||||
SetSourceLevel(freq.value("power", settings.Freq.excitation_power));
|
||||
SetLogSweep(freq.value("log", settings.Freq.logSweep));
|
||||
}
|
||||
if(sweep.contains("power")) {
|
||||
auto power = sweep["power"];
|
||||
|
|
@ -850,6 +858,7 @@ void VNA::SettingsChanged(std::function<void (Device::TransmissionResult)> cb)
|
|||
s.if_bandwidth = settings.bandwidth;
|
||||
s.cdbm_excitation_start = settings.Freq.excitation_power * 100;
|
||||
s.cdbm_excitation_stop = settings.Freq.excitation_power * 100;
|
||||
s.logSweep = settings.Freq.logSweep;
|
||||
} else if(settings.sweepType == SweepType::Power) {
|
||||
s.fixedPowerSetting = 0;
|
||||
s.f_start = settings.Power.frequency;
|
||||
|
|
@ -858,6 +867,7 @@ void VNA::SettingsChanged(std::function<void (Device::TransmissionResult)> cb)
|
|||
s.if_bandwidth = settings.bandwidth;
|
||||
s.cdbm_excitation_start = settings.Power.start * 100;
|
||||
s.cdbm_excitation_stop = settings.Power.stop * 100;
|
||||
s.logSweep = false;
|
||||
}
|
||||
if(window->getDevice() && Mode::getActiveMode() == this) {
|
||||
if(s.excitePort1 == 0 && s.excitePort2 == 0) {
|
||||
|
|
@ -979,6 +989,16 @@ void VNA::SpanZoomOut()
|
|||
ConstrainAndUpdateFrequencies();
|
||||
}
|
||||
|
||||
void VNA::SetLogSweep(bool log)
|
||||
{
|
||||
if(settings.Freq.logSweep != log) {
|
||||
settings.Freq.logSweep = log;
|
||||
emit logSweepChanged(log);
|
||||
SettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VNA::SetSourceLevel(double level)
|
||||
{
|
||||
if(level > Device::Info().limits_cdbm_max / 100.0) {
|
||||
|
|
@ -1500,3 +1520,4 @@ VNA::SweepType VNA::SweepTypeFromString(QString s)
|
|||
// not found
|
||||
return SweepType::Last;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public:
|
|||
double start;
|
||||
double stop;
|
||||
double excitation_power;
|
||||
bool logSweep;
|
||||
} Freq;
|
||||
struct {
|
||||
double start;
|
||||
|
|
@ -70,6 +71,8 @@ private slots:
|
|||
void SetFullSpan();
|
||||
void SpanZoomIn();
|
||||
void SpanZoomOut();
|
||||
|
||||
void SetLogSweep(bool log);
|
||||
// Acquisition control
|
||||
void SetSourceLevel(double level);
|
||||
// Power sweep settings
|
||||
|
|
@ -146,6 +149,7 @@ signals:
|
|||
void stopFreqChanged(double freq);
|
||||
void centerFreqChanged(double freq);
|
||||
void spanChanged(double span);
|
||||
void logSweepChanged(bool log);
|
||||
|
||||
void sourceLevelChanged(double level);
|
||||
void pointsChanged(unsigned int points);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public:
|
|||
QString type;
|
||||
double f_start;
|
||||
double f_stop;
|
||||
bool logSweep;
|
||||
double f_excitation;
|
||||
|
||||
double dbm_start;
|
||||
|
|
@ -103,12 +104,13 @@ private:
|
|||
QString name;
|
||||
QVariant def;
|
||||
};
|
||||
const std::array<SettingDescription, 40> descr = {{
|
||||
const std::array<SettingDescription, 41> descr = {{
|
||||
{&Startup.ConnectToFirstDevice, "Startup.ConnectToFirstDevice", true},
|
||||
{&Startup.RememberSweepSettings, "Startup.RememberSweepSettings", false},
|
||||
{&Startup.DefaultSweep.type, "Startup.DefaultSweep.type", "Frequency"},
|
||||
{&Startup.DefaultSweep.f_start, "Startup.DefaultSweep.start", 1000000.0},
|
||||
{&Startup.DefaultSweep.f_stop, "Startup.DefaultSweep.stop", 6000000000.0},
|
||||
{&Startup.DefaultSweep.logSweep, "Startup.DefaultSweep.logSweep", false},
|
||||
{&Startup.DefaultSweep.f_excitation, "Startup.DefaultSweep.excitation", -10.00},
|
||||
{&Startup.DefaultSweep.dbm_start, "Startup.DefaultSweep.dbm_start", -30.00},
|
||||
{&Startup.DefaultSweep.dbm_stop, "Startup.DefaultSweep.dbm_stop", -10.0},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue