display error flags in statusbar (overload/unlock/unlevel)

This commit is contained in:
Jan Käberich 2021-02-11 22:49:47 +01:00
parent 6d6f0843e9
commit e3f072b307
15 changed files with 89 additions and 13 deletions

View File

@ -124,6 +124,7 @@ static constexpr Protocol::DeviceInfo defaultInfo = {
.source_locked = 0, .source_locked = 0,
.LO1_locked = 0, .LO1_locked = 0,
.ADC_overload = 0, .ADC_overload = 0,
.unlevel = 0,
.temp_source = 0, .temp_source = 0,
.temp_LO1 = 0, .temp_LO1 = 0,
.temp_MCU = 0, .temp_MCU = 0,

View File

@ -11,6 +11,7 @@ Trace::Trace(QString name, QColor color, LiveParameter live)
_color(color), _color(color),
_liveType(LivedataType::Overwrite), _liveType(LivedataType::Overwrite),
_liveParam(live), _liveParam(live),
vFactor(0.66),
reflection(true), reflection(true),
visible(true), visible(true),
paused(false), paused(false),
@ -103,6 +104,11 @@ void Trace::setName(QString name) {
emit nameChanged(); emit nameChanged();
} }
void Trace::setVelocityFactor(double v)
{
vFactor = v;
}
void Trace::fillFromTouchstone(Touchstone &t, unsigned int parameter) void Trace::fillFromTouchstone(Touchstone &t, unsigned int parameter)
{ {
if(parameter >= t.ports()*t.ports()) { if(parameter >= t.ports()*t.ports()) {
@ -249,8 +255,7 @@ const std::vector<Trace::MathInfo>& Trace::getMathOperations() const
double Trace::velocityFactor() double Trace::velocityFactor()
{ {
// TODO make changeable return vFactor;
return 0.66;
} }
double Trace::timeToDistance(double time) double Trace::timeToDistance(double time)
@ -293,8 +298,9 @@ nlohmann::json Trace::toJSON()
j["filename"] = filename.toStdString(); j["filename"] = filename.toStdString();
j["parameter"] = fileParemeter; j["parameter"] = fileParemeter;
} }
j["velocityFactor"] = vFactor;
j["reflection"] = reflection; j["reflection"] = reflection;
// TODO how to save assigned markers?
nlohmann::json mathList; nlohmann::json mathList;
for(auto m : mathOps) { for(auto m : mathOps) {
if(m.math->getType() == Type::Last) { if(m.math->getType() == Type::Last) {
@ -343,6 +349,7 @@ void Trace::fromJSON(nlohmann::json j)
throw runtime_error("Failed to create from file:" + what); throw runtime_error("Failed to create from file:" + what);
} }
} }
vFactor = j.value("velocityFactor", 0.66);
reflection = j.value("reflection", false); reflection = j.value("reflection", false);
for(auto jm : j["math"]) { for(auto jm : j["math"]) {
QString operation = QString::fromStdString(jm.value("operation", "")); QString operation = QString::fromStdString(jm.value("operation", ""));

View File

@ -44,6 +44,7 @@ public:
void addData(const Data& d, const Protocol::SweepSettings& s); void addData(const Data& d, const Protocol::SweepSettings& s);
void addData(const Data& d, const Protocol::SpectrumAnalyzerSettings& s); void addData(const Data& d, const Protocol::SpectrumAnalyzerSettings& s);
void setName(QString name); void setName(QString name);
void setVelocityFactor(double v);
void fillFromTouchstone(Touchstone &t, unsigned int parameter); void fillFromTouchstone(Touchstone &t, unsigned int parameter);
QString fillFromCSV(CSV &csv, unsigned int parameter); // returns the suggested trace name (not yet set in member data) QString fillFromCSV(CSV &csv, unsigned int parameter); // returns the suggested trace name (not yet set in member data)
void fromLivedata(LivedataType type, LiveParameter param); void fromLivedata(LivedataType type, LiveParameter param);
@ -146,6 +147,7 @@ private:
QColor _color; QColor _color;
LivedataType _liveType; LivedataType _liveType;
LiveParameter _liveParam; LiveParameter _liveParam;
double vFactor;
bool reflection; bool reflection;
bool visible; bool visible;
bool paused; bool paused;

View File

@ -10,8 +10,10 @@ TraceEditDialog::TraceEditDialog(Trace &t, QWidget *parent) :
trace(t) trace(t)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->vFactor->setPrecision(3);
ui->name->setText(t.name()); ui->name->setText(t.name());
ui->color->setColor(trace.color()); ui->color->setColor(trace.color());
ui->vFactor->setValue(t.velocityFactor());
connect(ui->color, &ColorPickerButton::colorChanged, [=](const QColor& color){ connect(ui->color, &ColorPickerButton::colorChanged, [=](const QColor& color){
trace.setColor(color); trace.setColor(color);
}); });
@ -109,6 +111,7 @@ TraceEditDialog::~TraceEditDialog()
void TraceEditDialog::on_buttonBox_accepted() void TraceEditDialog::on_buttonBox_accepted()
{ {
trace.setName(ui->name->text()); trace.setName(ui->name->text());
trace.setVelocityFactor(ui->vFactor->value());
if(!trace.isCalibration()) { if(!trace.isCalibration()) {
// only apply changes if it is not a calibration trace // only apply changes if it is not a calibration trace
if (ui->bFile->isChecked()) { if (ui->bFile->isChecked()) {

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>282</width> <width>282</width>
<height>355</height> <height>365</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -63,6 +63,16 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Velocity Factor:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SIUnitEdit" name="vFactor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -181,6 +191,11 @@
<extends>QPushButton</extends> <extends>QPushButton</extends>
<header>CustomWidgets/colorpickerbutton.h</header> <header>CustomWidgets/colorpickerbutton.h</header>
</customwidget> </customwidget>
<customwidget>
<class>SIUnitEdit</class>
<extends>QLineEdit</extends>
<header>CustomWidgets/siunitedit.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>

View File

@ -75,7 +75,7 @@ void TwoThru::updateGUI()
+Unit::ToString(measurements2xthru.front().frequency, "Hz", " kMG", 4)+" to " +Unit::ToString(measurements2xthru.front().frequency, "Hz", " kMG", 4)+" to "
+Unit::ToString(measurements2xthru.back().frequency, "Hz", " kMG", 4)); +Unit::ToString(measurements2xthru.back().frequency, "Hz", " kMG", 4));
} else { } else {
ui->l2xthru->setText("Not available, not de-embedding"); ui->l2xthru->setText("Not available");
} }
if(measurementsDUT.size() > 0) { if(measurementsDUT.size() > 0) {
@ -83,7 +83,7 @@ void TwoThru::updateGUI()
+Unit::ToString(measurementsDUT.front().frequency, "Hz", " kMG", 4)+" to " +Unit::ToString(measurementsDUT.front().frequency, "Hz", " kMG", 4)+" to "
+Unit::ToString(measurementsDUT.back().frequency, "Hz", " kMG", 4)); +Unit::ToString(measurementsDUT.back().frequency, "Hz", " kMG", 4));
} else { } else {
ui->lDUT->setText("Not available, not de-embedding"); ui->lDUT->setText("Not available");
} }
if(points.size() > 0) { if(points.size() > 0) {
@ -91,7 +91,7 @@ void TwoThru::updateGUI()
+Unit::ToString(points.front().freq, "Hz", " kMG", 4)+" to " +Unit::ToString(points.front().freq, "Hz", " kMG", 4)+" to "
+Unit::ToString(points.back().freq, "Hz", " kMG", 4)); +Unit::ToString(points.back().freq, "Hz", " kMG", 4));
} else { } else {
ui->lPoints->setText("Not available, not de-embedding"); ui->lPoints->setText("No values calculated, not de-embedding");
} }
if (measurementsDUT.size() > 0 && measurements2xthru.size() > 0) { if (measurementsDUT.size() > 0 && measurements2xthru.size() > 0) {

View File

@ -72,6 +72,21 @@ AppWindow::AppWindow(QWidget *parent)
ui->statusbar->addWidget(div1); ui->statusbar->addWidget(div1);
ui->statusbar->addWidget(&lDeviceInfo); ui->statusbar->addWidget(&lDeviceInfo);
ui->statusbar->addWidget(new QLabel, 1); ui->statusbar->addWidget(new QLabel, 1);
lADCOverload.setStyleSheet("color : red");
lADCOverload.setText("ADC overload");
lADCOverload.setVisible(false);
ui->statusbar->addWidget(&lADCOverload);
lUnlevel.setStyleSheet("color : red");
lUnlevel.setText("Unlevel");
lUnlevel.setVisible(false);
ui->statusbar->addWidget(&lUnlevel);
lUnlock.setStyleSheet("color : red");
lUnlock.setText("Unlock");
lUnlock.setVisible(false);
ui->statusbar->addWidget(&lUnlock);
//ui->statusbar->setStyleSheet("QStatusBar::item { border: 1px solid black; };"); //ui->statusbar->setStyleSheet("QStatusBar::item { border: 1px solid black; };");
CreateToolbars(); CreateToolbars();
@ -219,6 +234,9 @@ void AppWindow::ConnectToDevice(QString serial)
connect(device, &Device::ConnectionLost, this, &AppWindow::DeviceConnectionLost); connect(device, &Device::ConnectionLost, this, &AppWindow::DeviceConnectionLost);
connect(device, &Device::DeviceInfoUpdated, [this]() { connect(device, &Device::DeviceInfoUpdated, [this]() {
lDeviceInfo.setText(device->getLastDeviceInfoString()); lDeviceInfo.setText(device->getLastDeviceInfoString());
lADCOverload.setVisible(device->Info().ADC_overload);
lUnlevel.setVisible(device->Info().unlevel);
lUnlock.setVisible(!device->Info().LO1_locked || !device->Info().source_locked);
}); });
connect(device, &Device::NeedsFirmwareUpdate, this, &AppWindow::DeviceNeedsUpdate); connect(device, &Device::NeedsFirmwareUpdate, this, &AppWindow::DeviceNeedsUpdate);
ui->actionDisconnect->setEnabled(true); ui->actionDisconnect->setEnabled(true);

View File

@ -78,6 +78,10 @@ private:
// Status bar widgets // Status bar widgets
QLabel lConnectionStatus; QLabel lConnectionStatus;
QLabel lDeviceInfo; QLabel lDeviceInfo;
// Error flag labels
QLabel lADCOverload;
QLabel lUnlevel;
QLabel lUnlock;
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };

View File

@ -29,7 +29,7 @@
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1502405410" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=" parent="fr.ac6.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="Generating hex and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot; &amp;&amp; arm-none-eabi-objcopy -O ihex &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.hex&quot; &amp;&amp; arm-none-eabi-size &quot;${BuildArtifactFileName}&quot;"> <configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1502405410" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="fr.ac6.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="Generating hex and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot; &amp;&amp; arm-none-eabi-objcopy -O ihex &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.hex&quot; &amp;&amp; arm-none-eabi-size &quot;${BuildArtifactFileName}&quot;">
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1502405410." name="/" resourcePath=""> <folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.1502405410." name="/" resourcePath="">

View File

@ -252,6 +252,7 @@ static Protocol::DeviceInfo DecodeDeviceInfo(uint8_t *buf) {
d.source_locked = e.getBits(1); d.source_locked = e.getBits(1);
d.LO1_locked = e.getBits(1); d.LO1_locked = e.getBits(1);
d.ADC_overload = e.getBits(1); d.ADC_overload = e.getBits(1);
d.unlevel = e.getBits(1);
e.get(d.temp_source); e.get(d.temp_source);
e.get(d.temp_LO1); e.get(d.temp_LO1);
e.get(d.temp_MCU); e.get(d.temp_MCU);
@ -283,6 +284,7 @@ static int16_t EncodeDeviceInfo(Protocol::DeviceInfo d, uint8_t *buf,
e.addBits(d.source_locked, 1); e.addBits(d.source_locked, 1);
e.addBits(d.LO1_locked, 1); e.addBits(d.LO1_locked, 1);
e.addBits(d.ADC_overload, 1); e.addBits(d.ADC_overload, 1);
e.addBits(d.unlevel, 1);
e.add(d.temp_source); e.add(d.temp_source);
e.add(d.temp_LO1); e.add(d.temp_LO1);
e.add(d.temp_MCU); e.add(d.temp_MCU);

View File

@ -53,6 +53,7 @@ using DeviceInfo = struct _deviceInfo {
uint8_t source_locked:1; uint8_t source_locked:1;
uint8_t LO1_locked:1; uint8_t LO1_locked:1;
uint8_t ADC_overload:1; uint8_t ADC_overload:1;
uint8_t unlevel:1;
uint8_t temp_source; uint8_t temp_source;
uint8_t temp_LO1; uint8_t temp_LO1;
uint8_t temp_MCU; uint8_t temp_MCU;

View File

@ -44,6 +44,7 @@ void Generator::Setup(Protocol::GeneratorSettings g) {
} }
} }
auto amplitude = HW::GetAmplitudeSettings(g.cdbm_level, g.frequency, g.applyAmplitudeCorrection, g.activePort == 2); auto amplitude = HW::GetAmplitudeSettings(g.cdbm_level, g.frequency, g.applyAmplitudeCorrection, g.activePort == 2);
HW::SetOutputUnlevel(amplitude.unlevel);
// Select correct source // Select correct source
if(g.frequency < HW::BandSwitchFrequency) { if(g.frequency < HW::BandSwitchFrequency) {
m.SourceLowEN = 1; m.SourceLowEN = 1;

View File

@ -16,6 +16,7 @@
static uint32_t extOutFreq = 0; static uint32_t extOutFreq = 0;
static bool extRefInUse = false; static bool extRefInUse = false;
HW::Mode activeMode; HW::Mode activeMode;
static bool unlevel = false;
static Protocol::ReferenceSettings ref; static Protocol::ReferenceSettings ref;
static uint32_t lastISR; static uint32_t lastISR;
@ -186,6 +187,7 @@ void HW::SetMode(Mode mode) {
// already the correct mode // already the correct mode
return; return;
} }
unlevel = false;
switch(activeMode) { switch(activeMode) {
case Mode::Manual: case Mode::Manual:
Manual::Stop(); Manual::Stop();
@ -215,6 +217,7 @@ bool HW::GetTemps(uint8_t *source, uint8_t *lo) {
} }
void HW::SetIdle() { void HW::SetIdle() {
unlevel = false;
FPGA::AbortSweep(); FPGA::AbortSweep();
FPGA::SetMode(FPGA::Mode::FPGA); FPGA::SetMode(FPGA::Mode::FPGA);
FPGA::Enable(FPGA::Periphery::SourceChip, false); FPGA::Enable(FPGA::Periphery::SourceChip, false);
@ -283,6 +286,10 @@ bool HW::TimedOut() {
} }
} }
void HW::SetOutputUnlevel(bool unlev) {
unlevel = unlev;
}
void HW::fillDeviceInfo(Protocol::DeviceInfo *info, bool updateEvenWhenBusy) { void HW::fillDeviceInfo(Protocol::DeviceInfo *info, bool updateEvenWhenBusy) {
// copy constant default values // copy constant default values
memcpy(info, &HW::Info, sizeof(HW::Info)); memcpy(info, &HW::Info, sizeof(HW::Info));
@ -311,6 +318,7 @@ void HW::fillDeviceInfo(Protocol::DeviceInfo *info, bool updateEvenWhenBusy) {
info->source_locked = (status & (int) FPGA::Interrupt::SourceUnlock) ? 0 : 1; info->source_locked = (status & (int) FPGA::Interrupt::SourceUnlock) ? 0 : 1;
info->extRefAvailable = Ref::available(); info->extRefAvailable = Ref::available();
info->extRefInUse = extRefInUse; info->extRefInUse = extRefInUse;
info->unlevel = unlevel;
info->temp_LO1 = tempLO; info->temp_LO1 = tempLO;
info->temp_source = tempSource; info->temp_source = tempSource;
FPGA::ResetADCLimits(); FPGA::ResetADCLimits();

View File

@ -60,6 +60,7 @@ static constexpr Protocol::DeviceInfo Info = {
.source_locked = 0, .source_locked = 0,
.LO1_locked = 0, .LO1_locked = 0,
.ADC_overload = 0, .ADC_overload = 0,
.unlevel = 0,
.temp_source = 0, .temp_source = 0,
.temp_LO1 = 0, .temp_LO1 = 0,
.temp_MCU = 0, .temp_MCU = 0,
@ -89,6 +90,8 @@ void SetIdle();
void Work(); void Work();
bool TimedOut(); bool TimedOut();
void SetOutputUnlevel(bool unlev);
using AmplitudeSettings = struct _amplitudeSettings { using AmplitudeSettings = struct _amplitudeSettings {
uint8_t attenuator; uint8_t attenuator;
union { union {

View File

@ -64,6 +64,10 @@ static void StartNextSample() {
if(trackingFreq > 0 && trackingFreq <= (int64_t) HW::Info.limits_maxFreq) { if(trackingFreq > 0 && trackingFreq <= (int64_t) HW::Info.limits_maxFreq) {
// tracking frequency is valid, calculate required settings and select band // tracking frequency is valid, calculate required settings and select band
auto amplitude = HW::GetAmplitudeSettings(s.trackingPower, trackingFreq, s.applySourceCorrection, s.trackingGeneratorPort); auto amplitude = HW::GetAmplitudeSettings(s.trackingPower, trackingFreq, s.applySourceCorrection, s.trackingGeneratorPort);
// only set the flag here, it is reset at the beginning of each sweep (this makes sure it is set if any of the points are not reached by the TG)
if(amplitude.unlevel) {
HW::SetOutputUnlevel(true);
}
attenuator = amplitude.attenuator; attenuator = amplitude.attenuator;
if(trackingFreq < HW::BandSwitchFrequency) { if(trackingFreq < HW::BandSwitchFrequency) {
Si5351.SetCLK(SiChannel::LowbandSource, trackingFreq, Si5351C::PLL::B, amplitude.lowBandPower); Si5351.SetCLK(SiChannel::LowbandSource, trackingFreq, Si5351C::PLL::B, amplitude.lowBandPower);
@ -161,6 +165,7 @@ static void StartNextSample() {
void SA::Setup(Protocol::SpectrumAnalyzerSettings settings) { void SA::Setup(Protocol::SpectrumAnalyzerSettings settings) {
LOG_DEBUG("Setting up..."); LOG_DEBUG("Setting up...");
HW::SetOutputUnlevel(false);
SA::Stop(); SA::Stop();
vTaskDelay(5); vTaskDelay(5);
s = settings; s = settings;
@ -369,11 +374,9 @@ void SA::Work() {
} }
// setup for next step // setup for next step
signalIDstep = 0; signalIDstep = 0;
if(pointCnt < points - DFTpoints) {
pointCnt += DFTpoints; if(pointCnt % 10 == 0) {
} else { // send device info every nth point
pointCnt = 0;
// sweep finished, extract device info
FPGA::Enable(FPGA::Periphery::SourceChip); // needs to enable the chip to get a valid temperature reading FPGA::Enable(FPGA::Periphery::SourceChip); // needs to enable the chip to get a valid temperature reading
Protocol::PacketInfo packet; Protocol::PacketInfo packet;
packet.type = Protocol::PacketType::DeviceInfo; packet.type = Protocol::PacketType::DeviceInfo;
@ -381,6 +384,14 @@ void SA::Work() {
FPGA::Disable(FPGA::Periphery::SourceChip); FPGA::Disable(FPGA::Periphery::SourceChip);
Communication::Send(packet); Communication::Send(packet);
} }
if(pointCnt < points - DFTpoints) {
pointCnt += DFTpoints;
} else {
pointCnt = 0;
// reset possibly active unlevel flag before next sweep
HW::SetOutputUnlevel(false);
}
} else { } else {
// more measurements required for signal ID // more measurements required for signal ID
signalIDstep++; signalIDstep++;