mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Working dwell time feature
- Bugfixes: - improve SPI timing in FPGA - fix markers and reduce CPU load when using markers with fast traces - New features: - dwell time configurable in acquisition toolbar - PLL settling delay in device configuration - device configuration persistent across power cycles
This commit is contained in:
parent
24314e2361
commit
a4faeb28b0
35 changed files with 516 additions and 289 deletions
|
|
@ -71,6 +71,7 @@ void DeviceConfigurationDialogV1::updateGUI(const Protocol::DeviceConfig &c)
|
|||
ui->IF1->setEnabled(true);
|
||||
ui->ADCpresc->setValue(c.V1.ADCprescaler);
|
||||
ui->ADCphaseInc->setValue(c.V1.DFTphaseInc);
|
||||
ui->PLLSettlingDelay->setValue(c.V1.PLLSettlingDelay);
|
||||
}
|
||||
|
||||
void DeviceConfigurationDialogV1::updateDevice()
|
||||
|
|
@ -80,5 +81,6 @@ void DeviceConfigurationDialogV1::updateDevice()
|
|||
p.deviceConfig.V1.IF1 = ui->IF1->value();
|
||||
p.deviceConfig.V1.ADCprescaler = ui->ADCpresc->value();
|
||||
p.deviceConfig.V1.DFTphaseInc = ui->ADCphaseInc->value();
|
||||
p.deviceConfig.V1.PLLSettlingDelay = ui->PLLSettlingDelay->value();
|
||||
dev.SendPacket(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,24 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>487</width>
|
||||
<height>356</height>
|
||||
<width>454</width>
|
||||
<height>464</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Device Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>This dialog contains advanced system settings. It is recommended to leave them at default values unless you know what you are doing.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_15">
|
||||
<property name="title">
|
||||
|
|
@ -23,26 +33,13 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_34">
|
||||
<property name="text">
|
||||
<string>This section contains advanced system settings. It is recommended to leave them at default values unless you know what you are doing. Slight changes of the IF frequencies can be used to shift possible spikes to less problematic frequencies. Large changes of these frequencies may severely impact device performance.</string>
|
||||
<string>Slight changes of the IF frequencies can be used to shift possible spikes to less problematic frequencies. Large changes of these frequencies may severely impact device performance.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
|
|
@ -138,6 +135,32 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Other settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>PLL settling delay [us]:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="PLLSettlingDelay">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
|
|
|||
|
|
@ -684,7 +684,6 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet)
|
|||
info.Limits.VNA.maxIFBW = packet.info.limits_maxIFBW;
|
||||
info.Limits.VNA.mindBm = (double) packet.info.limits_cdbm_min / 100;
|
||||
info.Limits.VNA.maxdBm = (double) packet.info.limits_cdbm_max / 100;
|
||||
info.Limits.VNA.minDwellTime = (double) packet.info.limits_minDwellTime * 1e-6;
|
||||
info.Limits.VNA.maxDwellTime = (double) packet.info.limits_maxDwellTime * 1e-6;
|
||||
|
||||
info.Limits.Generator.ports = packet.info.num_ports;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ LibreVNAUSBDriver::LibreVNAUSBDriver()
|
|||
dataBuffer = nullptr;
|
||||
logBuffer = nullptr;
|
||||
m_receiveThread = nullptr;
|
||||
lastTimestamp = QDateTime::currentDateTime();
|
||||
byteCnt = 0;
|
||||
|
||||
specificSettings.push_back(Savable::SettingDescription(&captureRawReceiverValues, "LibreVNAUSBDriver.captureRawReceiverValues", false));
|
||||
specificSettings.push_back(Savable::SettingDescription(&harmonicMixing, "LibreVNAUSBDriver.harmonicMixing", false));
|
||||
|
|
@ -183,11 +185,19 @@ void LibreVNAUSBDriver::ReceivedData()
|
|||
case Protocol::PacketType::Nack:
|
||||
emit receivedAnswer(TransmissionResult::Nack);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
// pass on to LibreVNADriver class
|
||||
emit receivedPacket(packet);
|
||||
break;
|
||||
}
|
||||
// byteCnt += handled_len;
|
||||
// auto now = QDateTime::currentDateTime();
|
||||
// if(lastTimestamp.time().msecsTo(now.time()) > 1000) {
|
||||
// lastTimestamp = now;
|
||||
// constexpr unsigned int maxThroughput = 12000000 / 8;
|
||||
// qDebug() << "USB throughput: " << byteCnt << "(" << (double) byteCnt * 100.0 / maxThroughput << "%)";
|
||||
// byteCnt = 0;
|
||||
// }
|
||||
} while (handled_len > 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
|
||||
class LibreVNAUSBDriver : public LibreVNADriver
|
||||
{
|
||||
|
|
@ -76,6 +77,11 @@ private:
|
|||
std::thread *m_receiveThread;
|
||||
|
||||
std::mutex accessMutex;
|
||||
|
||||
// USB throughput indicator
|
||||
QDateTime lastTimestamp;
|
||||
unsigned long byteCnt;
|
||||
|
||||
};
|
||||
|
||||
#endif // LIBREVNAUSBDRIVER_H
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ DeviceDriver::Info::Info()
|
|||
Limits.VNA.minIFBW = 1;
|
||||
Limits.VNA.maxIFBW = 100000000;
|
||||
Limits.VNA.maxPoints = 65535;
|
||||
Limits.VNA.minDwellTime = 0;
|
||||
Limits.VNA.maxDwellTime = 1;
|
||||
|
||||
Limits.Generator.ports = 2;
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ public:
|
|||
unsigned int maxPoints;
|
||||
// Stimulus level limits in dBm
|
||||
double mindBm, maxdBm;
|
||||
// dwell time limts
|
||||
double minDwellTime, maxDwellTime;
|
||||
// dwell time limit
|
||||
double maxDwellTime;
|
||||
} VNA;
|
||||
struct {
|
||||
// Number of ports
|
||||
|
|
|
|||
|
|
@ -788,8 +788,10 @@ void Marker::parentTraceDeleted(Trace *t)
|
|||
}
|
||||
}
|
||||
|
||||
void Marker::traceDataChanged()
|
||||
void Marker::traceDataChanged(unsigned int begin, unsigned int end)
|
||||
{
|
||||
Q_UNUSED(begin)
|
||||
Q_UNUSED(end)
|
||||
complex<double> newdata;
|
||||
if(!parentTrace || parentTrace->numSamples() == 0) {
|
||||
// no data, invalidate
|
||||
|
|
@ -1088,7 +1090,7 @@ void Marker::constrainPosition()
|
|||
position = parentTrace->sample(parentTrace->index(position)).x;
|
||||
}
|
||||
}
|
||||
traceDataChanged();
|
||||
traceDataChanged(0, parentTrace->size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ signals:
|
|||
|
||||
private slots:
|
||||
void parentTraceDeleted(Trace *t);
|
||||
void traceDataChanged();
|
||||
void traceDataChanged(unsigned int begin, unsigned int end);
|
||||
void updateSymbol();
|
||||
void checkDeltaMarker();
|
||||
void deltaDeleted();
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ void Math::DFT::inputSamplesChanged(unsigned int begin, unsigned int end)
|
|||
{
|
||||
Q_UNUSED(begin);
|
||||
Q_UNUSED(end);
|
||||
if(input->getData().size() < 2) {
|
||||
if(input->numSamples() < 2) {
|
||||
// not enough input data
|
||||
clearOutput();
|
||||
warning("Not enough input samples");
|
||||
|
|
@ -161,7 +161,7 @@ void Math::DFT::inputSamplesChanged(unsigned int begin, unsigned int end)
|
|||
void Math::DFT::updateDFT()
|
||||
{
|
||||
if(dataType != DataType::Invalid) {
|
||||
inputSamplesChanged(0, input->getData().size());
|
||||
inputSamplesChanged(0, input->numSamples());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,6 @@ void Math::Expression::expressionChanged()
|
|||
break;
|
||||
}
|
||||
if(input) {
|
||||
inputSamplesChanged(0, input->getData().size());
|
||||
inputSamplesChanged(0, input->numSamples());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ void TDR::setMode(Mode m)
|
|||
}
|
||||
mode = m;
|
||||
if(input) {
|
||||
inputSamplesChanged(0, input->getData().size());
|
||||
inputSamplesChanged(0, input->numSamples());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ void TDR::inputSamplesChanged(unsigned int begin, unsigned int end)
|
|||
{
|
||||
Q_UNUSED(begin);
|
||||
Q_UNUSED(end);
|
||||
if(input->getData().size() >= 2) {
|
||||
if(input->numSamples() >= 2) {
|
||||
// trigger calculation in thread
|
||||
semphr.release();
|
||||
success();
|
||||
|
|
@ -227,7 +227,7 @@ void TDR::inputSamplesChanged(unsigned int begin, unsigned int end)
|
|||
void TDR::updateTDR()
|
||||
{
|
||||
if(dataType != DataType::Invalid) {
|
||||
inputSamplesChanged(0, input->getData().size());
|
||||
inputSamplesChanged(0, input->numSamples());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -324,3 +324,29 @@ std::vector<TraceMath::Data> TraceMath::getData()
|
|||
dataMutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
double TraceMath::minX()
|
||||
{
|
||||
double ret;
|
||||
dataMutex.lock();
|
||||
if(data.size() > 0) {
|
||||
ret = data.front().x;
|
||||
} else {
|
||||
ret = std::numeric_limits<double>::max();
|
||||
}
|
||||
dataMutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
double TraceMath::maxX()
|
||||
{
|
||||
double ret;
|
||||
dataMutex.lock();
|
||||
if(data.size() > 0) {
|
||||
ret = data.back().x;
|
||||
} else {
|
||||
ret = std::numeric_limits<double>::min();
|
||||
}
|
||||
dataMutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
class Trace;
|
||||
|
||||
class TraceMath : public QObject, public Savable {
|
||||
friend class Trace;
|
||||
Q_OBJECT
|
||||
public:
|
||||
TraceMath();
|
||||
|
|
@ -112,6 +113,8 @@ public:
|
|||
|
||||
DataType getDataType() const;
|
||||
virtual std::vector<Data> getData();
|
||||
virtual double minX();
|
||||
virtual double maxX();
|
||||
Status getStatus() const;
|
||||
QString getStatusDescription() const;
|
||||
virtual Type getType() = 0;
|
||||
|
|
|
|||
|
|
@ -1354,19 +1354,19 @@ void Trace::clearDeembedding()
|
|||
|
||||
double Trace::minX()
|
||||
{
|
||||
if(lastMath->numSamples() > 0) {
|
||||
return lastMath->getData().front().x;
|
||||
if(lastMath == this) {
|
||||
return TraceMath::minX();
|
||||
} else {
|
||||
return numeric_limits<double>::max();
|
||||
return lastMath->minX();
|
||||
}
|
||||
}
|
||||
|
||||
double Trace::maxX()
|
||||
{
|
||||
if(lastMath->numSamples() > 0) {
|
||||
return lastMath->getData().back().x;
|
||||
if(lastMath == this) {
|
||||
return TraceMath::maxX();
|
||||
} else {
|
||||
return numeric_limits<double>::lowest();
|
||||
return lastMath->maxX();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1620,12 +1620,16 @@ double Trace::getGroupDelay(double frequency)
|
|||
|
||||
int Trace::index(double x)
|
||||
{
|
||||
auto lower = lower_bound(lastMath->getData().begin(), lastMath->getData().end(), x, [](const Data &lhs, const double x) -> bool {
|
||||
int ret;
|
||||
lastMath->dataMutex.lock();
|
||||
auto lower = lower_bound(lastMath->data.begin(), lastMath->data.end(), x, [](const Data &lhs, const double x) -> bool {
|
||||
return lhs.x < x;
|
||||
});
|
||||
if(lower == lastMath->getData().end()) {
|
||||
if(lower == lastMath->data.end()) {
|
||||
// actually beyond the last sample, return the index of the last anyway to avoid access past data
|
||||
return lastMath->getData().size() - 1;
|
||||
ret = lastMath->data.size() - 1;
|
||||
}
|
||||
return lower - lastMath->getData().begin();
|
||||
ret = lower - lastMath->data.begin();
|
||||
lastMath->dataMutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public:
|
|||
void setDeembeddingActive(bool active);
|
||||
void clearDeembedding();
|
||||
|
||||
double minX();
|
||||
double maxX();
|
||||
double minX() override;
|
||||
double maxX() override;
|
||||
double findExtremum(bool max, double xmin = std::numeric_limits<double>::lowest(), double xmax = std::numeric_limits<double>::max());
|
||||
/* Searches for peaks in the trace data and returns the peak frequencies in ascending order.
|
||||
* Up to maxPeaks will be returned, with higher level peaks taking priority over lower level peaks.
|
||||
|
|
|
|||
|
|
@ -653,6 +653,7 @@ VNA::VNA(AppWindow *window, QString name)
|
|||
SetPowerSweepFrequency(pref.Startup.DefaultSweep.dbm_freq);
|
||||
SetIFBandwidth(pref.Startup.DefaultSweep.bandwidth);
|
||||
SetAveraging(pref.Startup.DefaultSweep.averaging);
|
||||
SetDwellTime(pref.Startup.DefaultSweep.dwellTime);
|
||||
SetPoints(pref.Startup.DefaultSweep.points);
|
||||
if(pref.Startup.DefaultSweep.type == "Power Sweep") {
|
||||
SetSweepType(SweepType::Power);
|
||||
|
|
@ -836,6 +837,7 @@ void VNA::resetSettings()
|
|||
SetStopPower(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxdBm);
|
||||
SetPowerSweepFrequency(DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxFreq);
|
||||
SetIFBandwidth(1000);
|
||||
SetDwellTime(0);
|
||||
SetAveraging(1);
|
||||
SetPoints(501);
|
||||
SetSweepType(SweepType::Frequency);
|
||||
|
|
@ -1246,8 +1248,6 @@ void VNA::SetSourceLevel(double level)
|
|||
void VNA::SetDwellTime(double time) {
|
||||
if(time > DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxDwellTime) {
|
||||
time = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxDwellTime;
|
||||
} else if(time < DeviceDriver::getInfo(window->getDevice()).Limits.VNA.minDwellTime) {
|
||||
time = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.minDwellTime;
|
||||
}
|
||||
emit dwellTimeChanged(time);
|
||||
settings.dwellTime = time;
|
||||
|
|
@ -1640,6 +1640,7 @@ void VNA::LoadSweepSettings()
|
|||
SetPoints(s.value("SweepPoints", pref.Startup.DefaultSweep.points).toInt());
|
||||
SetIFBandwidth(s.value("SweepBandwidth", pref.Startup.DefaultSweep.bandwidth).toUInt());
|
||||
SetAveraging(s.value("SweepAveraging", pref.Startup.DefaultSweep.averaging).toInt());
|
||||
SetDwellTime(s.value("SweepDwellTime", pref.Startup.DefaultSweep.dwellTime).toDouble());
|
||||
ConstrainAndUpdateFrequencies();
|
||||
auto typeString = s.value("SweepType", pref.Startup.DefaultSweep.type).toString();
|
||||
if(typeString == "Power") {
|
||||
|
|
@ -1663,6 +1664,7 @@ void VNA::StoreSweepSettings()
|
|||
s.setValue("SweepBandwidth", settings.bandwidth);
|
||||
s.setValue("SweepPoints", settings.npoints);
|
||||
s.setValue("SweepAveraging", averages);
|
||||
s.setValue("SweepDwellTime", settings.dwellTime);
|
||||
}
|
||||
|
||||
void VNA::UpdateCalWidget()
|
||||
|
|
@ -1680,13 +1682,12 @@ void VNA::ConstrainAllSettings()
|
|||
auto maxIFBW = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxIFBW;
|
||||
auto minIFBW = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.minIFBW;
|
||||
auto maxDwell = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxDwellTime;
|
||||
auto minDwell = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.minDwellTime;
|
||||
auto maxPoints = DeviceDriver::getInfo(window->getDevice()).Limits.VNA.maxPoints;
|
||||
Util::constrain(settings.Freq.start, minFreq, maxFreq);
|
||||
Util::constrain(settings.Freq.stop, minFreq, maxFreq);
|
||||
Util::constrain(settings.Freq.excitation_power, minPower, maxPower);
|
||||
Util::constrain(settings.bandwidth, minIFBW, maxIFBW);
|
||||
Util::constrain(settings.dwellTime, minDwell, maxDwell);
|
||||
Util::constrain(settings.dwellTime, 0.0, maxDwell);
|
||||
Util::constrain(settings.npoints, (unsigned int) 0, maxPoints);
|
||||
Util::constrain(settings.Power.frequency, minFreq, maxFreq);
|
||||
Util::constrain(settings.Power.start, minPower, maxPower);
|
||||
|
|
@ -1832,7 +1833,7 @@ void VNA::preset()
|
|||
|
||||
void VNA::deviceInfoUpdated()
|
||||
{
|
||||
if(DeviceDriver::getInfo(window->getDevice()).supportedFeatures.count(DeviceDriver::Feature::VNADwellTime)) {
|
||||
if(window->getDevice()->supports(DeviceDriver::Feature::VNADwellTime)) {
|
||||
acquisitionDwellTime->setEnabled(true);
|
||||
} else {
|
||||
acquisitionDwellTime->setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
|
|||
ui->StartupSweepPowerFrequency->setPrefixes(" kMG");
|
||||
ui->StartupSweepBandwidth->setUnit("Hz");
|
||||
ui->StartupSweepBandwidth->setPrefixes(" k");
|
||||
ui->StartupSweepDwellTime->setUnit("s");
|
||||
ui->StartupSweepDwellTime->setPrefixes("um ");
|
||||
ui->StartupSweepDwellTime->setPrecision(3);
|
||||
ui->StartupGeneratorFrequency->setUnit("Hz");
|
||||
ui->StartupGeneratorFrequency->setPrefixes(" kMG");
|
||||
ui->StartupSAStart->setUnit("Hz");
|
||||
|
|
@ -246,6 +249,7 @@ void PreferencesDialog::setInitialGUIState()
|
|||
ui->StartupGeneratorFrequency->setValue(p->Startup.Generator.frequency);
|
||||
ui->StartupGeneratorLevel->setValue(p->Startup.Generator.level);
|
||||
ui->StartupSweepAveraging->setValue(p->Startup.DefaultSweep.averaging);
|
||||
ui->StartupSweepDwellTime->setValue(p->Startup.DefaultSweep.dwellTime);
|
||||
ui->StartupSAStart->setValue(p->Startup.SA.start);
|
||||
ui->StartupSAStop->setValue(p->Startup.SA.stop);
|
||||
ui->StartupSARBW->setValue(p->Startup.SA.RBW);
|
||||
|
|
@ -360,6 +364,7 @@ void PreferencesDialog::updateFromGUI()
|
|||
p->Startup.DefaultSweep.bandwidth = ui->StartupSweepBandwidth->value();
|
||||
p->Startup.DefaultSweep.points = ui->StartupSweepPoints->value();
|
||||
p->Startup.DefaultSweep.averaging = ui->StartupSweepAveraging->value();
|
||||
p->Startup.DefaultSweep.dwellTime = ui->StartupSweepDwellTime->value();
|
||||
p->Startup.Generator.frequency = ui->StartupGeneratorFrequency->value();
|
||||
p->Startup.Generator.level = ui->StartupGeneratorLevel->value();
|
||||
p->Startup.SA.start = ui->StartupSAStart->value();
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public:
|
|||
int points;
|
||||
double bandwidth;
|
||||
int averaging;
|
||||
double dwellTime;
|
||||
} DefaultSweep;
|
||||
struct {
|
||||
double frequency;
|
||||
|
|
@ -232,6 +233,7 @@ private:
|
|||
{&Startup.DefaultSweep.points, "Startup.DefaultSweep.points", 501},
|
||||
{&Startup.DefaultSweep.bandwidth, "Startup.DefaultSweep.bandwidth", 1000.0},
|
||||
{&Startup.DefaultSweep.averaging, "Startup.DefaultSweep.averaging", 1},
|
||||
{&Startup.DefaultSweep.dwellTime, "Startup.DefaultSweep.dwellTime", 60e-6},
|
||||
{&Startup.Generator.frequency, "Startup.Generator.frequency", 1000000000.0},
|
||||
{&Startup.Generator.level, "Startup.Generator.level", -10.00},
|
||||
{&Startup.SA.start, "Startup.SA.start", 950000000.0},
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Startup">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
|
|
@ -111,9 +111,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-206</y>
|
||||
<width>679</width>
|
||||
<height>836</height>
|
||||
<y>0</y>
|
||||
<width>683</width>
|
||||
<height>928</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
|
|
@ -167,7 +167,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -201,7 +201,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -268,7 +268,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -493,6 +493,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_63">
|
||||
<property name="text">
|
||||
<string>Dwell Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="SIUnitEdit" name="StartupSweepDwellTime"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
@ -673,7 +683,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -703,8 +713,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>696</width>
|
||||
<height>564</height>
|
||||
<width>564</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
|
|
@ -867,7 +877,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -898,7 +908,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -916,7 +926,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -943,9 +953,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-400</y>
|
||||
<width>679</width>
|
||||
<height>992</height>
|
||||
<y>0</y>
|
||||
<width>683</width>
|
||||
<height>1118</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_22">
|
||||
|
|
@ -1233,7 +1243,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1257,7 +1267,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1291,7 +1301,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1436,7 +1446,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1466,8 +1476,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>402</width>
|
||||
<height>540</height>
|
||||
<width>683</width>
|
||||
<height>605</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
|
|
@ -1684,7 +1694,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1711,7 +1721,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="MarkerInterpolate">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
<enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
|
|
@ -1782,7 +1792,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1812,8 +1822,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>138</width>
|
||||
<height>112</height>
|
||||
<width>697</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
|
|
@ -1859,7 +1869,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -1874,7 +1884,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -2056,7 +2066,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -2071,7 +2081,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -2095,8 +2105,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>696</width>
|
||||
<height>564</height>
|
||||
<width>697</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_19">
|
||||
|
|
@ -2156,7 +2166,7 @@
|
|||
<item>
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -2171,7 +2181,7 @@
|
|||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
|
@ -2193,10 +2203,10 @@
|
|||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Ok|QDialogButtonBox::Open|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Save</set>
|
||||
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Ok|QDialogButtonBox::StandardButton::Open|QDialogButtonBox::StandardButton::RestoreDefaults|QDialogButtonBox::StandardButton::Save</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ inline void App_Process() {
|
|||
}
|
||||
break;
|
||||
case Protocol::PacketType::DeviceConfiguration:
|
||||
HW::setAcquisitionFrequencies(recv_packet.deviceConfig);
|
||||
HW::setDeviceConfig(recv_packet.deviceConfig);
|
||||
Communication::SendWithoutPayload(Protocol::PacketType::Ack);
|
||||
break;
|
||||
case Protocol::PacketType::SetTrigger:
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ using DeviceInfo = struct _deviceInfo {
|
|||
uint8_t limits_maxAmplitudePoints;
|
||||
uint64_t limits_maxFreqHarmonic;
|
||||
uint8_t num_ports;
|
||||
uint16_t limits_minDwellTime;
|
||||
uint16_t limits_maxDwellTime;
|
||||
};
|
||||
|
||||
|
|
@ -440,6 +439,7 @@ using DeviceConfig = struct _deviceconfig {
|
|||
uint32_t IF1;
|
||||
uint8_t ADCprescaler;
|
||||
uint16_t DFTphaseInc;
|
||||
uint8_t PLLSettlingDelay;
|
||||
} V1;
|
||||
struct {
|
||||
uint32_t ip;
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ void FPGA::SetMode(Mode mode) {
|
|||
Low(AUX2);
|
||||
Delay::us(1);
|
||||
High(CS);
|
||||
// Configure SPI to use faster speed of 32MHz
|
||||
// Configure SPI to use faster speed of 42.5MHz
|
||||
FPGA_SPI.Instance->CR1 = (FPGA_SPI.Instance->CR1 & ~SPI_CR1_BR_Msk) | SPI_BAUDRATEPRESCALER_4;
|
||||
break;
|
||||
case Mode::SourcePLL:
|
||||
|
|
@ -361,15 +361,15 @@ void FPGA::SetMode(Mode mode) {
|
|||
Low(AUX2);
|
||||
Delay::us(1);
|
||||
High(AUX1);
|
||||
// Configure SPI to use slower speed of 16MHz (MAX2871 is limited to 20MHz)
|
||||
FPGA_SPI.Instance->CR1 = (FPGA_SPI.Instance->CR1 & ~SPI_CR1_BR_Msk) | SPI_BAUDRATEPRESCALER_8;
|
||||
// Configure SPI to use slower speed of 10.625MHz (MAX2871 is limited to 20MHz)
|
||||
FPGA_SPI.Instance->CR1 = (FPGA_SPI.Instance->CR1 & ~SPI_CR1_BR_Msk) | SPI_BAUDRATEPRESCALER_16;
|
||||
break;
|
||||
case Mode::LOPLL:
|
||||
Low(CS);
|
||||
Low(AUX1);
|
||||
Delay::us(1);
|
||||
High(AUX2);
|
||||
// Configure SPI to use slower speed of 16MHz (MAX2871 is limited to 20MHz)
|
||||
// Configure SPI to use slower speed of 10.625MHz (MAX2871 is limited to 20MHz)
|
||||
FPGA_SPI.Instance->CR1 = (FPGA_SPI.Instance->CR1 & ~SPI_CR1_BR_Msk) | SPI_BAUDRATEPRESCALER_8;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#include "stm.hpp"
|
||||
|
||||
#define LOG_LEVEL LOG_LEVEL_INFO
|
||||
#define LOG_MODULE "STM"
|
||||
#include "Log.h"
|
||||
|
||||
using Callback = void(*)(void);
|
||||
static constexpr uint8_t numCallbacks = 10;
|
||||
static Callback callbacks[numCallbacks];
|
||||
|
|
@ -34,6 +38,7 @@ bool STM::DispatchToInterrupt(void (*cb)(void)) {
|
|||
return true;
|
||||
} else {
|
||||
// already at limit
|
||||
LOG_ERR("Interrupt dispatch queue full");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,17 @@ static bool StatusUpdateFlag = true;
|
|||
static Protocol::ReferenceSettings ref;
|
||||
static volatile uint64_t lastISR;
|
||||
|
||||
static uint32_t IF1 = HW::DefaultIF1;
|
||||
static uint32_t IF2 = HW::DefaultIF2;
|
||||
static uint32_t ADCsamplerate = HW::DefaultADCSamplerate;
|
||||
static uint8_t ADCprescaler = HW::DefaultADCprescaler;
|
||||
static uint16_t DFTphaseInc = HW::DefaultDFTphaseInc;
|
||||
// increment when device config struct format changed. If a wrong version is found in flash, it will revert to default values
|
||||
static constexpr uint16_t deviceConfigVersion = 0x001;
|
||||
|
||||
using DeviceConfig = struct _devicConfig {
|
||||
uint16_t version;
|
||||
Protocol::DeviceConfig config;
|
||||
uint32_t IF2;
|
||||
uint32_t ADCsamplerate;
|
||||
};
|
||||
|
||||
static DeviceConfig deviceConfig;
|
||||
|
||||
using namespace HWHAL;
|
||||
|
||||
|
|
@ -100,6 +106,8 @@ bool HW::Init() {
|
|||
|
||||
activeMode = Mode::Idle;
|
||||
|
||||
LoadDeviceConfig();
|
||||
|
||||
Si5351.Init();
|
||||
|
||||
// Use Si5351 to generate reference frequencies for other PLLs and ADC
|
||||
|
|
@ -152,12 +160,12 @@ bool HW::Init() {
|
|||
FPGA::DisableHardwareOverwrite();
|
||||
|
||||
// Set default ADC samplerate
|
||||
FPGA::WriteRegister(FPGA::Reg::ADCPrescaler, ADCprescaler);
|
||||
FPGA::WriteRegister(FPGA::Reg::ADCPrescaler, deviceConfig.config.V1.ADCprescaler);
|
||||
// Set phase increment according to
|
||||
FPGA::WriteRegister(FPGA::Reg::PhaseIncrement, DFTphaseInc);
|
||||
FPGA::WriteRegister(FPGA::Reg::PhaseIncrement, deviceConfig.config.V1.DFTphaseInc);
|
||||
|
||||
// Set default settling time
|
||||
FPGA::SetSettlingTime(HW::DefaultDwellTime);
|
||||
FPGA::SetSettlingTime(deviceConfig.config.V1.PLLSettlingDelay);
|
||||
|
||||
Exti::SetCallback(FPGA_INTR_GPIO_Port, FPGA_INTR_Pin, Exti::EdgeType::Rising, Exti::Pull::Down, FPGA_Interrupt);
|
||||
|
||||
|
|
@ -190,7 +198,7 @@ bool HW::Init() {
|
|||
} else {
|
||||
LOG_INFO("LO1 VCO map complete");
|
||||
}
|
||||
LO1.SetFrequency(1000000000 + IF1);
|
||||
LO1.SetFrequency(1000000000 + deviceConfig.config.V1.IF1);
|
||||
LO1.UpdateFrequency();
|
||||
LOG_DEBUG("LO temp: %u", LO1.GetTemp());
|
||||
|
||||
|
|
@ -428,37 +436,39 @@ Si5351C::PLLSource HW::Ref::getSource() {
|
|||
}
|
||||
}
|
||||
|
||||
void HW::setAcquisitionFrequencies(Protocol::DeviceConfig s) {
|
||||
IF1 = s.V1.IF1;
|
||||
ADCprescaler = s.V1.ADCprescaler;
|
||||
DFTphaseInc = s.V1.DFTphaseInc;
|
||||
float ADCrate = (float) FPGA::Clockrate / ADCprescaler;
|
||||
IF2 = ADCrate * DFTphaseInc / 4096;
|
||||
ADCsamplerate = ADCrate;
|
||||
static void updateOtherParametersFromProtocolDeviceConfig() {
|
||||
float ADCrate = (float) FPGA::Clockrate / deviceConfig.config.V1.ADCprescaler;
|
||||
deviceConfig.IF2 = ADCrate * deviceConfig.config.V1.DFTphaseInc / 4096;
|
||||
deviceConfig.ADCsamplerate = ADCrate;
|
||||
}
|
||||
|
||||
void HW::setDeviceConfig(Protocol::DeviceConfig s) {
|
||||
deviceConfig.config = s;
|
||||
if(deviceConfig.config.V1.PLLSettlingDelay < HW::MinPLLSettlingDelay) {
|
||||
deviceConfig.config.V1.PLLSettlingDelay = HW::MinPLLSettlingDelay;
|
||||
}
|
||||
updateOtherParametersFromProtocolDeviceConfig();
|
||||
SaveDeviceConfig();
|
||||
}
|
||||
|
||||
Protocol::DeviceConfig HW::getDeviceConfig() {
|
||||
Protocol::DeviceConfig s;
|
||||
s.V1.ADCprescaler = ADCprescaler;
|
||||
s.V1.DFTphaseInc = DFTphaseInc;
|
||||
s.V1.IF1 = IF1;
|
||||
return s;
|
||||
return deviceConfig.config;
|
||||
}
|
||||
|
||||
uint32_t HW::getIF1() {
|
||||
return IF1;
|
||||
return deviceConfig.config.V1.IF1;
|
||||
}
|
||||
|
||||
uint32_t HW::getIF2() {
|
||||
return IF2;
|
||||
return deviceConfig.IF2;
|
||||
}
|
||||
|
||||
uint32_t HW::getADCRate() {
|
||||
return ADCsamplerate;
|
||||
return deviceConfig.ADCsamplerate;
|
||||
}
|
||||
|
||||
uint8_t HW::getADCPrescaler() {
|
||||
return ADCprescaler;
|
||||
return deviceConfig.config.V1.ADCprescaler;
|
||||
}
|
||||
|
||||
uint64_t HW::getLastISRTimestamp() {
|
||||
|
|
@ -496,6 +506,44 @@ void HW::updateDeviceStatus() {
|
|||
}
|
||||
|
||||
uint16_t HW::getDFTPhaseInc() {
|
||||
return DFTphaseInc;
|
||||
return deviceConfig.config.V1.DFTphaseInc;
|
||||
}
|
||||
|
||||
uint8_t HW::getPLLSettlingDelay() {
|
||||
return deviceConfig.config.V1.PLLSettlingDelay;
|
||||
}
|
||||
|
||||
bool HW::LoadDeviceConfig() {
|
||||
HWHAL::flash.read(flash_address, sizeof(deviceConfig), &deviceConfig);
|
||||
if(deviceConfig.version != deviceConfigVersion) {
|
||||
LOG_WARN("Invalid version in flash, expected %u, got %u", deviceConfigVersion, deviceConfig.version);
|
||||
SetDefaultDeviceConfig();
|
||||
return false;
|
||||
} else {
|
||||
LOG_INFO("Device config loaded from flash");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool HW::SaveDeviceConfig() {
|
||||
if(!HWHAL::flash.eraseRange(flash_address, flash_size)) {
|
||||
return false;
|
||||
}
|
||||
uint32_t write_size = sizeof(deviceConfig);
|
||||
if(write_size % Flash::PageSize != 0) {
|
||||
// round up to next page
|
||||
write_size += Flash::PageSize - write_size % Flash::PageSize;
|
||||
}
|
||||
return HWHAL::flash.write(flash_address, write_size, &deviceConfig);
|
||||
}
|
||||
|
||||
void HW::SetDefaultDeviceConfig() {
|
||||
memset(&deviceConfig, 0, sizeof(deviceConfig));
|
||||
deviceConfig.version = deviceConfigVersion;
|
||||
deviceConfig.config.V1.IF1 = HW::DefaultIF1;
|
||||
deviceConfig.config.V1.ADCprescaler = HW::DefaultADCprescaler;
|
||||
deviceConfig.config.V1.DFTphaseInc = HW::DefaultDFTphaseInc;
|
||||
deviceConfig.config.V1.PLLSettlingDelay = HW::DefaultPLLSettlingDelay;
|
||||
updateOtherParametersFromProtocolDeviceConfig();
|
||||
LOG_INFO("Device config set to default");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ static constexpr uint32_t BandSwitchFrequency = 25000000;
|
|||
static constexpr uint32_t DefaultLO2 = DefaultIF1 - DefaultIF2;
|
||||
static constexpr uint8_t LO2Multiplier = 13;
|
||||
static constexpr uint32_t SI5351CPLLAlignedFrequency = DefaultLO2 * LO2Multiplier;
|
||||
static constexpr uint16_t DefaultDwellTime = 60;
|
||||
static constexpr uint16_t DefaultPLLSettlingDelay = 60;
|
||||
static constexpr uint16_t MinPLLSettlingDelay = 10;
|
||||
|
||||
static constexpr uint8_t DefaultADCprescaler = FPGA::Clockrate / DefaultADCSamplerate;
|
||||
static_assert(DefaultADCprescaler * DefaultADCSamplerate == FPGA::Clockrate, "ADCSamplerate can not be reached exactly");
|
||||
|
|
@ -87,7 +88,6 @@ static constexpr Protocol::DeviceInfo Info = {
|
|||
.limits_maxAmplitudePoints = Cal::maxPoints,
|
||||
.limits_maxFreqHarmonic = 18000000000,
|
||||
.num_ports = 2,
|
||||
.limits_minDwellTime = 0,
|
||||
.limits_maxDwellTime = 10239,
|
||||
};
|
||||
|
||||
|
|
@ -135,13 +135,21 @@ namespace Ref {
|
|||
Si5351C::PLLSource getSource();
|
||||
}
|
||||
|
||||
// Acquisition frequency settings
|
||||
void setAcquisitionFrequencies(Protocol::DeviceConfig s);
|
||||
// Device configuration settings
|
||||
constexpr uint32_t flash_address = Firmware::maxSize + Cal::flash_size; // stored directly behind calibration in flash
|
||||
constexpr uint32_t flash_size = 4096; // reserve one sector for now
|
||||
|
||||
bool LoadDeviceConfig();
|
||||
bool SaveDeviceConfig();
|
||||
void SetDefaultDeviceConfig();
|
||||
|
||||
void setDeviceConfig(Protocol::DeviceConfig s);
|
||||
Protocol::DeviceConfig getDeviceConfig();
|
||||
uint32_t getIF1();
|
||||
uint32_t getIF2();
|
||||
uint32_t getADCRate();
|
||||
uint8_t getADCPrescaler();
|
||||
uint16_t getDFTPhaseInc();
|
||||
uint8_t getPLLSettlingDelay();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ static_assert(alternativePhaseInc * alternativeSamplerate == 4096 * HW::DefaultI
|
|||
|
||||
// Constants for USB buffer overflow prevention
|
||||
static constexpr uint16_t maxPointsBetweenHalts = 40;
|
||||
static constexpr uint32_t reservedUSBbuffer = maxPointsBetweenHalts * (sizeof(Protocol::Datapoint) + 8 /*USB packet overhead*/);
|
||||
static constexpr uint16_t full2portDatapointSize = 66;// See Protocol::VNADatapoint::
|
||||
static constexpr uint32_t reservedUSBbuffer = (maxPointsBetweenHalts + 2 /*additional buffer*/) * (full2portDatapointSize + 8 /*USB packet overhead*/);
|
||||
|
||||
using namespace HWHAL;
|
||||
|
||||
|
|
@ -118,6 +119,9 @@ bool VNA::Setup(Protocol::SweepSettings s) {
|
|||
if(settings.points > FPGA::MaxPoints) {
|
||||
settings.points = FPGA::MaxPoints;
|
||||
}
|
||||
if(settings.dwell_time > HW::Info.limits_maxDwellTime) {
|
||||
settings.dwell_time = HW::Info.limits_maxDwellTime;
|
||||
}
|
||||
settings = s;
|
||||
// calculate factor between adjacent points for log sweep for faster calculation when sweeping
|
||||
logMultiplier = pow((double) settings.f_stop / settings.f_start, 1.0 / (settings.points-1));
|
||||
|
|
@ -132,7 +136,7 @@ bool VNA::Setup(Protocol::SweepSettings s) {
|
|||
// has to be one less than actual number of samples
|
||||
FPGA::SetSamplesPerPoint(samplesPerPoint);
|
||||
|
||||
FPGA::SetSettlingTime(s.dwell_time);
|
||||
FPGA::SetSettlingTime(s.dwell_time + HW::getPLLSettlingDelay());
|
||||
|
||||
// reset unlevel flag if it was set from a previous sweep/mode
|
||||
HW::SetOutputUnlevel(false);
|
||||
|
|
@ -216,6 +220,7 @@ bool VNA::Setup(Protocol::SweepSettings s) {
|
|||
pointsWithoutHalt++;
|
||||
if(pointsWithoutHalt > maxPointsBetweenHalts) {
|
||||
needs_halt = true;
|
||||
pointsWithoutHalt = 0;
|
||||
}
|
||||
} else {
|
||||
pointsWithoutHalt = 0;
|
||||
|
|
@ -304,7 +309,9 @@ static void PassOnData() {
|
|||
Protocol::PacketInfo info;
|
||||
info.type = Protocol::PacketType::VNADatapoint;
|
||||
info.VNAdatapoint = &data;
|
||||
Communication::Send(info);
|
||||
if(!Communication::Send(info)) {
|
||||
LOG_ERR("Failed to transmit VNADatapoint");
|
||||
}
|
||||
data.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue