From 9776b81b45fae7bdd676d0d74435ec873bcd5c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sat, 14 Jan 2023 19:56:03 +0100 Subject: [PATCH 1/4] Fix min calibration frequency after taking measurement --- .../LibreVNA-GUI/Calibration/calibration.cpp | 7 ++++++- .../LibreVNA-GUI/Calibration/calibrationmeasurement.h | 4 ++++ .../LibreVNA-GUI/Calibration/calstandard.cpp | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp index c5c64a4..01aa638 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp @@ -603,6 +603,11 @@ void Calibration::edit() std::set m; auto selected = ui->table->selectionModel()->selectedRows(); for(auto s : selected) { + auto meas = measurements[s.row()]; + if(!meas->readyForMeasurement()) { + InformationBox::ShowError("Unable to measure", CalibrationMeasurement::Base::TypeToString(meas->getType())+" measurement is not ready, please check that a valid calibration standard is selected"); + return; + } m.insert(measurements[s.row()]); } if(!CalibrationMeasurement::Base::canMeasureSimultaneously(m)) { @@ -1659,7 +1664,7 @@ bool Calibration::canCompute(Calibration::CalType type, double *startFreq, doubl // missing measurement return false; } else if (!meas->readyForCalculation()){ - // measurement not ready (either not calkit standard definded or no measurements + // measurement not ready (either not calkit standard definded or no measurements) return false; } else { foundMeasurements.push_back(meas); diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibrationmeasurement.h b/Software/PC_Application/LibreVNA-GUI/Calibration/calibrationmeasurement.h index e6b58f2..7050bf4 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibrationmeasurement.h +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibrationmeasurement.h @@ -38,6 +38,7 @@ public: virtual double minFreq() = 0; virtual double maxFreq() = 0; virtual unsigned int numPoints() = 0; + virtual bool readyForMeasurement() {return false;} virtual bool readyForCalculation() {return false;} static std::vector availableTypes(); @@ -80,6 +81,7 @@ public: virtual double minFreq() override; virtual double maxFreq() override; virtual unsigned int numPoints() override {return points.size();} + virtual bool readyForMeasurement() override {return standard != nullptr;} virtual bool readyForCalculation() override {return standard && points.size() > 0;} virtual void clearPoints() override; @@ -194,6 +196,7 @@ public: virtual double minFreq() override; virtual double maxFreq() override; virtual unsigned int numPoints() override {return points.size();} + virtual bool readyForMeasurement() override {return standard != nullptr;} virtual bool readyForCalculation() override {return standard && points.size() > 0;} virtual void clearPoints() override; @@ -265,6 +268,7 @@ public: virtual double minFreq() override; virtual double maxFreq() override; virtual unsigned int numPoints() override; + virtual bool readyForMeasurement() override {return true;} virtual bool readyForCalculation() override {return points.size() > 0;} virtual void clearPoints() override; diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calstandard.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calstandard.cpp index 0c84a11..ea0f26c 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calstandard.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calstandard.cpp @@ -120,7 +120,7 @@ void OnePort::clearMeasurement() delete touchstone; touchstone = nullptr; minFreq = std::numeric_limits::lowest(); - minFreq = std::numeric_limits::max(); + maxFreq = std::numeric_limits::max(); } nlohmann::json OnePort::toJSON() @@ -538,7 +538,7 @@ void TwoPort::clearMeasurement() delete touchstone; touchstone = nullptr; minFreq = std::numeric_limits::lowest(); - minFreq = std::numeric_limits::max(); + maxFreq = std::numeric_limits::max(); } nlohmann::json TwoPort::toJSON() From ea4c637842c65fd7572dd1a65af4e46f778cbd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 10 Feb 2023 11:41:53 +0100 Subject: [PATCH 2/4] improve touchstone parsing robustness --- Software/PC_Application/LibreVNA-GUI/touchstone.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/touchstone.cpp b/Software/PC_Application/LibreVNA-GUI/touchstone.cpp index e30ce20..8e5081e 100644 --- a/Software/PC_Application/LibreVNA-GUI/touchstone.cpp +++ b/Software/PC_Application/LibreVNA-GUI/touchstone.cpp @@ -1,6 +1,7 @@ #include "touchstone.h" #include "Util/util.h" +#include "unit.h" #include #include @@ -162,14 +163,16 @@ Touchstone Touchstone::fromFile(string filename) Datapoint point; string line; + unsigned int lineCnt = 0; while(getline(file, line)) { + lineCnt++; // remove comments auto comment = line.find_first_of('!'); if(comment != string::npos) { line.erase(comment); } // remove leading whitespace - size_t first = line.find_first_not_of(" \t"); + size_t first = line.find_first_not_of(" \t\r\n"); if (string::npos == first) { // string does only contain whitespace, skip line continue; @@ -231,10 +234,11 @@ Touchstone Touchstone::fromFile(string filename) if(!option_line_found) { throw runtime_error("First dataline before option line"); } - auto parseDatapoint = [format](istream &in) -> complex { + auto parseDatapoint = [format, &point, &lineCnt](istream &in) -> complex { double part1, part2; - in >> part1; - in >> part2; + if(!(in >> part1) || !(in >> part2)) { + throw runtime_error("Failed to parse parameters on line "+std::to_string(lineCnt)+" with frequency "+Unit::ToString(point.frequency,"Hz", " kMG", 10).toStdString()); + } complex ret; switch(format) { case Format::MagnitudeAngle: From 169d51d5baa9214ea7b8a3d680b1a4d154faf0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 10 Feb 2023 12:20:35 +0100 Subject: [PATCH 3/4] LM3370 initialization fix --- Software/VNA_embedded/Src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Software/VNA_embedded/Src/main.c b/Software/VNA_embedded/Src/main.c index 1ab5992..f9e790d 100644 --- a/Software/VNA_embedded/Src/main.c +++ b/Software/VNA_embedded/Src/main.c @@ -110,13 +110,14 @@ int main(void) SystemClock_Config(); /* USER CODE BEGIN SysInit */ - + MX_I2C2_Init(); + uint8_t ctrl = 0x0A; + HAL_I2C_Mem_Write(&hi2c2, 0x42, 0x01, I2C_MEMADD_SIZE_8BIT, &ctrl, 1, 100); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); - MX_I2C2_Init(); MX_SPI1_Init(); MX_SPI2_Init(); MX_UCPD1_Init(); From a0fbd3ba8fe814ba1face9b5cbe2b4d89091041b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 10 Feb 2023 12:32:14 +0100 Subject: [PATCH 4/4] v1.4.1 changes added --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e556715..3628c19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ - made USB communication more robust - PLL locking issue fixed +## v1.4.1 +- Bugfix: Configure voltage regulator for correct voltage at startup + ## v1.4.0 - New features: