mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-21 06:13:41 +00:00
Working source and receiver calibration
This commit is contained in:
parent
875f3b0170
commit
026fffd588
23 changed files with 722 additions and 68 deletions
|
|
@ -1,8 +1,47 @@
|
|||
#include "sourcecaldialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
SourceCalDialog::SourceCalDialog(Device *dev)
|
||||
: AmplitudeCalDialog(dev)
|
||||
{
|
||||
setWindowTitle("Source Calibration Dialog");
|
||||
LoadFromDevice();
|
||||
}
|
||||
|
||||
void SourceCalDialog::SelectedPoint(double frequency, bool port2)
|
||||
{
|
||||
Protocol::PacketInfo p;
|
||||
p.type = Protocol::PacketType::Generator;
|
||||
|
||||
p.generator.frequency = frequency;
|
||||
p.generator.cdbm_level = excitationAmplitude * 100.0;
|
||||
if(frequency > 0) {
|
||||
if(port2) {
|
||||
p.generator.activePort = 2;
|
||||
} else {
|
||||
p.generator.activePort = 1;
|
||||
}
|
||||
} else {
|
||||
// invalid frequency, disable both ports
|
||||
p.generator.activePort = 0;
|
||||
}
|
||||
p.generator.applyAmplitudeCorrection = 0;
|
||||
dev->SendPacket(p);
|
||||
}
|
||||
|
||||
void SourceCalDialog::AmplitudeChanged(AmplitudeCalDialog::CorrectionPoint &point, bool port2)
|
||||
{
|
||||
auto *factor = port2 ? &point.correctionPort2 : &point.correctionPort1;
|
||||
const auto *amplitude = port2 ? &point.amplitudePort2 : &point.amplitudePort1;
|
||||
// calculate correction factor by comparing expected with measured amplitude
|
||||
*factor = (excitationAmplitude - *amplitude) * 100.0;
|
||||
}
|
||||
|
||||
void SourceCalDialog::UpdateAmplitude(AmplitudeCalDialog::CorrectionPoint &point)
|
||||
{
|
||||
point.amplitudePort1 = excitationAmplitude - (double) point.correctionPort1 / 100.0;
|
||||
point.amplitudePort2 = excitationAmplitude - (double) point.correctionPort2 / 100.0;
|
||||
point.port1set = true;
|
||||
point.port2set = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue