diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.cpp new file mode 100644 index 0000000..f684f95 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.cpp @@ -0,0 +1,72 @@ +#include "deviceconfigurationdialogvd0.h" +#include "ui_deviceconfigurationdialogvd0.h" + +DeviceConfigurationDialogVD0::DeviceConfigurationDialogVD0(LibreVNADriver &dev, QWidget *parent) : + QDialog(parent), + ui(new Ui::DeviceConfigurationDialogVD0), + dev(dev) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emit dev.acquireControl(); + + auto updateIF = [=]() { + auto ADCrate = ui->ADCRate->value(); + ui->IF->setValue(ADCrate * ui->ADCphaseInc->value() / 65536); + }; + + connect(ui->ADCRate, &SIUnitEdit::valueChanged, this, updateIF); + connect(ui->ADCphaseInc, qOverload(&QSpinBox::valueChanged), this, updateIF); + + ui->ADCRate->setUnit("Hz"); + ui->ADCRate->setPrefixes(" kM"); + ui->ADCRate->setPrecision(5); + ui->IF->setUnit("Hz"); + ui->IF->setPrefixes(" kM"); + ui->IF->setPrecision(5); + + ui->ADCRate->setValue(1496000); + ui->ADCphaseInc->setValue(10240); + + updateIF(); + + connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p) { + if(p.type == Protocol::PacketType::DeviceConfiguration) { + updateGUI(p.deviceConfig); + } + }); + + dev.sendWithoutPayload(Protocol::PacketType::RequestDeviceConfiguration); + + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=](){ + updateDevice(); + accept(); + }); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=](){ + reject(); + }); +} + +DeviceConfigurationDialogVD0::~DeviceConfigurationDialogVD0() +{ + dev.releaseControl(); + delete ui; +} + +void DeviceConfigurationDialogVD0::updateGUI(const Protocol::DeviceConfig &c) +{ + ui->ADCRate->setValue(c.VD0.ADCrate); + ui->ADCphaseInc->setValue(c.VD0.DFTphaseInc); + ui->PLLSettlingDelay->setValue(c.VD0.PLLSettlingDelay); +} + +void DeviceConfigurationDialogVD0::updateDevice() +{ + Protocol::PacketInfo p; + p.type = Protocol::PacketType::DeviceConfiguration; + p.deviceConfig.VD0.ADCrate = ui->ADCRate->value(); + p.deviceConfig.VD0.DFTphaseInc = ui->ADCphaseInc->value(); + p.deviceConfig.VD0.PLLSettlingDelay = ui->PLLSettlingDelay->value(); + dev.SendPacket(p); +} diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.h new file mode 100644 index 0000000..641b420 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.h @@ -0,0 +1,28 @@ +#ifndef DEVICECONFIGURATIONDIALOGVD0_H +#define DEVICECONFIGURATIONDIALOGVD0_H + +#include + +#include "librevnadriver.h" + +namespace Ui { +class DeviceConfigurationDialogVD0; +} + +class DeviceConfigurationDialogVD0 : public QDialog +{ + Q_OBJECT + +public: + explicit DeviceConfigurationDialogVD0(LibreVNADriver &dev, QWidget *parent = nullptr); + ~DeviceConfigurationDialogVD0(); + +private: + void updateGUI(const Protocol::DeviceConfig &c); + void updateDevice(); + + Ui::DeviceConfigurationDialogVD0 *ui; + LibreVNADriver &dev; +}; + +#endif // DEVICECONFIGURATIONDIALOGVD0_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.ui new file mode 100644 index 0000000..f4abffd --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.ui @@ -0,0 +1,138 @@ + + + DeviceConfigurationDialogVD0 + + + + 0 + 0 + 421 + 314 + + + + Device Configuration + + + + + + This dialog contains advanced system settings. It is recommended to leave them at default values unless you know what you are doing. + + + true + + + + + + + IF and ADC frequencies + + + + + + + + ADC sample rate: + + + + + + + true + + + + + + + DFT Phase increment: + + + + + + + <html><head/><body><p>Phase increment per ADC sample. Together with the ADC sample rate this determines the frequency of the second IF</p></body></html> + + + 1 + + + 65535 + + + 10240 + + + + + + + IF: + + + + + + + false + + + + + + + + + + + + Other settings + + + + + + PLL settling delay [us]: + + + + + + + 10 + + + 255 + + + 60 + + + + + + + + + + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + + + + + + SIUnitEdit + QLineEdit +
CustomWidgets/siunitedit.h
+
+
+ + +
diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp index 6b4bae8..16f964a 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp @@ -219,6 +219,21 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addInteger(VFE, "MCU temperature", sFE.temp_MCU); addDouble(VFE, "eCal temperature", (double) sFE.temp_eCal / 100.0); addDouble(VFE, "eCal heater power", (double) sFE.power_heater / 1000.0); + + auto sD0 = e.p->status.VD0; + auto VD0 = new QTreeWidgetItem(); + VD0->setData(2, Qt::DisplayRole, "VD0"); + item->addChild(VD0); + addBool(VD0, "External reference available", sD0.extRefAvailable); + addBool(VD0, "External reference in use", sD0.extRefInUse); + addBool(VD0, "FPGA configured", sD0.FPGA_configured); + addBool(VD0, "Source locked", sD0.source_locked); + addBool(VD0, "LO locked", sD0.LO_locked); + addBool(VD0, "ADC overload", sD0.ADC_overload); + addBool(VD0, "Unlevel", sD0.unlevel); + addInteger(VD0, "MCU temperature", sD0.temp_MCU); + addInteger(VD0, "Supply voltage", sD0.supply_voltage); + addInteger(VD0, "Supply current", sD0.supply_current); } break; case Protocol::PacketType::DeviceInfo: { @@ -311,6 +326,32 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addEnum(VFE, "Reference gain", s.VFE.RefGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"}); addEnum(VFE, "eCal state", s.VFE.eCal_state, {"Port", "Open", "Short", "Load"}); addDouble(VFE, "eCal target temperature", (double) s.VFE.eCal_target / 100.0); + + auto VD0 = new QTreeWidgetItem(); + VD0->setData(2, Qt::DisplayRole, "VD0"); + item->addChild(VD0); + addBool(VD0, "High Source chip enable", s.VD0.SourceHighCE); + addInteger(VD0, "High Source power", s.VD0.SourceHighPower); + addEnum(VD0, "High Source lowpass", s.VD0.SourceHighLowpass, {"947 MHz", "1880 MHz", "3550 MHz", "None"}); + addDouble(VD0, "High Source frequency", s.VD0.SourceHighFrequency); + addBool(VD0, "Low Source enable", s.VD0.SourceLowEN); + addEnum(VD0, "Low Source power", s.VD0.SourceLowPower, {"2 mA", "4 mA", "6 mA", "8 mA"}); + addDouble(VD0, "Low Source frequency", s.VD0.SourceLowFrequency); + addDouble(VD0, "Attenuator", s.VD0.attenuator * 0.25); + addEnum(VD0, "Source band selection", s.VD0.SourceHighband, {"Low Source", "High Source"}); + addEnum(VD0, "Port switch", s.VD0.PortSwitch, {"Port 1", "Port 2"}); + addBool(VD0, "High LO chip enable", s.VD0.LOHighCE); + addDouble(VD0, "High LO frequency", s.VD0.LOHighFrequency); + addInteger(VD0, "High LO power", s.VD0.LOHighPower); + addBool(VD0, "Low LO enable", s.VD0.LOLowEN); + addEnum(VD0, "Low LO power", s.VD0.LOLowPower, {"2 mA", "4 mA", "6 mA", "8 mA"}); + addDouble(VD0, "Low LO frequency", s.VD0.LOLowFrequency); + addEnum(VD0, "LO band selection", s.VD0.LOHighband, {"Low Source", "High Source"}); + addBool(VD0, "Port 1 receiver enable", s.VD0.Port1EN); + addBool(VD0, "Port 2 receiver enable", s.VD0.Port2EN); + addBool(VD0, "Reference receiver enable", s.VD0.RefEN); + addInteger(VD0, "Samples", s.VD0.Samples); + addEnum(VD0, "Window type", s.VD0.WindowType, {"None", "Kaiser", "Hann", "Flattop"}); } break; case Protocol::PacketType::ManualStatus: { @@ -364,6 +405,24 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addBool(VFE, "LO locked", s.VFE.LO_locked); addDouble(VFE, "eCal temperature", (double) s.VFE.temp_eCal / 100.0); addDouble(VFE, "eCal heater power", (double) s.VFE.power_heater / 1000.0); + + auto VD0 = new QTreeWidgetItem(); + VD0->setData(2, Qt::DisplayRole, "VD0"); + item->addChild(VD0); + addInteger(VD0, "ADC port 1 minimum", s.VD0.port1min); + addInteger(VD0, "ADC port 1 maximum", s.VD0.port1max); + addInteger(VD0, "ADC port 2 minimum", s.VD0.port2min); + addInteger(VD0, "ADC port 2 maximum", s.VD0.port2max); + addInteger(VD0, "ADC reference minimum", s.VD0.refmin); + addInteger(VD0, "ADC reference maximum", s.VD0.refmax); + addDouble(VD0, "Port 1 real", s.VD0.port1real); + addDouble(VD0, "Port 1 imaginary", s.VD0.port1imag); + addDouble(VD0, "Port 2 real", s.VD0.port2real); + addDouble(VD0, "Port 2 imaginary", s.VD0.port2imag); + addDouble(VD0, "Reference real", s.VD0.refreal); + addDouble(VD0, "Reference imaginary", s.VD0.refimag); + addBool(VD0, "Source locked", s.VD0.source_locked); + addBool(VD0, "LO1 locked", s.VD0.LO_locked); } break; case Protocol::PacketType::SpectrumAnalyzerSettings: { @@ -453,6 +512,7 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addDouble(V1, "1.IF", s1.IF1, "Hz"); addInteger(V1, "ADC prescaler", s1.ADCprescaler); addInteger(V1, "DFT phase increment", s1.DFTphaseInc); + addInteger(V1, "PLL settling delay", s1.PLLSettlingDelay); auto sFF = e.p->deviceConfig.VFF; auto VFF = new QTreeWidgetItem(); @@ -473,6 +533,14 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addBool(VFE, "PGA autogain", sFE.autogain); addInteger(VFE, "Port gain", sFE.portGain); addInteger(VFE, "Reference gain", sFE.refGain); + + auto sD0 = e.p->deviceConfig.VD0; + auto VD0 = new QTreeWidgetItem(); + VD0->setData(2, Qt::DisplayRole, "VD0"); + item->addChild(VD0); + addInteger(VD0, "ADC rate", sD0.ADCrate); + addInteger(VD0, "DFT phase increment", sD0.DFTphaseInc); + addInteger(VD0, "PLL settling delay", sD0.PLLSettlingDelay); } break; default: diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp index 71b29c2..7bda5b8 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp @@ -8,6 +8,7 @@ #include "deviceconfigurationdialogv1.h" #include "deviceconfigurationdialogvff.h" #include "deviceconfigurationdialogvfe.h" +#include "deviceconfigurationdialogvd0.h" #include "firmwareupdatedialog.h" #include "frequencycaldialog.h" #include "sourcecaldialog.h" @@ -161,6 +162,9 @@ LibreVNADriver::LibreVNADriver() case 1: d = new DeviceConfigurationDialogV1(*this); break; + case 0xD0: + d = new DeviceConfigurationDialogVD0(*this); + break; case 0xFE: d = new DeviceConfigurationDialogVFE(*this); break; @@ -236,7 +240,7 @@ LibreVNADriver::LibreVNADriver() // set available actions for each hardware version availableActions[0x01] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log}; - availableActions[0xD0] = {manual, update, sep, srccal, recvcal, freqcal, sep2, log}; + availableActions[0xD0] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log}; availableActions[0xE0] = {manual, update, sep, srccal, recvcal, freqcal, internalAlignment, sep2, log}; availableActions[0xFD] = {manual, update, sep, srccal, recvcal, freqcal, sep2, log}; availableActions[0xFE] = {manual, config, update, sep, srccal, recvcal, freqcal, sep2, log}; diff --git a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro index 86d6a2d..15b5b56 100644 --- a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro @@ -25,6 +25,7 @@ HEADERS += \ Device/LibreVNA/Compound/compounddriver.h \ Device/LibreVNA/amplitudecaldialog.h \ Device/LibreVNA/deviceconfigurationdialogv1.h \ + Device/LibreVNA/deviceconfigurationdialogvd0.h \ Device/LibreVNA/deviceconfigurationdialogvfe.h \ Device/LibreVNA/deviceconfigurationdialogvff.h \ Device/LibreVNA/devicepacketlog.h \ @@ -194,6 +195,7 @@ SOURCES += \ Device/LibreVNA/Compound/compounddriver.cpp \ Device/LibreVNA/amplitudecaldialog.cpp \ Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + Device/LibreVNA/deviceconfigurationdialogvd0.cpp \ Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ Device/LibreVNA/deviceconfigurationdialogvff.cpp \ Device/LibreVNA/devicepacketlog.cpp \ @@ -361,6 +363,7 @@ FORMS += \ Device/LibreVNA/amplitudecaldialog.ui \ Device/LibreVNA/automaticamplitudedialog.ui \ Device/LibreVNA/deviceconfigurationdialogv1.ui \ + Device/LibreVNA/deviceconfigurationdialogvd0.ui \ Device/LibreVNA/deviceconfigurationdialogvfe.ui \ Device/LibreVNA/deviceconfigurationdialogvff.ui \ Device/LibreVNA/devicepacketlogview.ui \ diff --git a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro index ab4a429..0b0e024 100644 --- a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro +++ b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro @@ -28,6 +28,7 @@ SOURCES += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \ @@ -219,6 +220,7 @@ HEADERS += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \ @@ -396,6 +398,7 @@ FORMS += \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.ui \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.ui \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \ diff --git a/Software/VNA_embedded/Application/Communication/Protocol.hpp b/Software/VNA_embedded/Application/Communication/Protocol.hpp index de12395..1409b02 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.hpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.hpp @@ -553,6 +553,11 @@ using DeviceConfig = struct _deviceconfig { uint16_t portGain :4; uint16_t refGain :4; } VFE; + struct { + uint16_t DFTphaseInc; + uint32_t ADCrate; + uint8_t PLLSettlingDelay; + } VD0; }; };