Skip to content

Commit

Permalink
vna_qt: wip
Browse files Browse the repository at this point in the history
* calibration file import/export working
* s1p and s2p export working
  • Loading branch information
xaxaxa committed Mar 4, 2018
1 parent 57ef062 commit f98b533
Show file tree
Hide file tree
Showing 8 changed files with 512 additions and 52 deletions.
2 changes: 1 addition & 1 deletion generate_source_tarball
@@ -1,5 +1,5 @@
#!/bin/bash

rm -rf xavna-src
rsync -a ./ xavna-src --exclude xavna-src --exclude '*.gz' --exclude 'lib/*' --exclude vhdl --exclude pcb --exclude 'build-*' --exclude pictures --exclude '*.cache' --exclude .git --exclude '*~'
rsync -a ./ xavna-src --exclude xavna-src --exclude 'xavna_windows*' --exclude '*.gz' --exclude 'lib/*' --exclude vhdl --exclude pcb --exclude 'build-*' --exclude pictures --exclude '*.cache' --exclude .git --exclude '*~'
tar cfz xavna-src.tar.gz xavna-src
76 changes: 44 additions & 32 deletions libxavna/calibration.C
@@ -1,59 +1,71 @@
#include "include/calibration.H"
namespace xaxaxa {
class SOLCalibration: public VNACalibration {
public:
// return the name of this calibration type
string name() const override {
return "SOL (1 port)";
}
// get a list of calibration standards required
vector<array<string, 2> > getRequiredStandards() const override {
return {{"short1","Short"},{"open1","Open"},{"load1","Load"}};
}
// given the measurements for each of the calibration standards, compute the coefficients
MatrixXcd computeCoefficients(const vector<VNARawValue>& measurements) const override {
auto tmp = SOL_compute_coefficients(measurements[0](0,0), measurements[1](0,0), measurements[2](0,0));
Vector3cd ret(tmp[0],tmp[1],tmp[2]);
return ret;
}
// given cal coefficients and a raw value, compute S parameters
VNACalibratedValue computeValue(MatrixXcd coeffs, VNARawValue val) const override {
array<complex<double>, 3> tmp {coeffs(0), coeffs(1), coeffs(2)};
VNACalibratedValue ret = val;
ret(0,0) = SOL_compute_reflection(tmp, val(0,0));
return ret;
}
};

typedef Matrix<complex<double>,5,1> Vector5cd;
typedef Matrix<complex<double>,6,1> Vector6cd;

namespace xaxaxa {
// T/R SOLT calibration and one port SOL calibration
class SOLTCalibrationTR: public VNACalibration {
public:
bool noThru;
SOLTCalibrationTR(bool noThru=false): noThru(noThru) {

}
// return the name of this calibration type
string name() const override {
return "SOLT (T/R)";
virtual string name() const override {
return noThru?"sol_1":"solt_tr";
}
string description() const override {
return noThru?"SOL (1 port)":"SOLT (T/R)";
}
// get a list of calibration standards required
vector<array<string, 2> > getRequiredStandards() const override {
return {{"short1","Short"},{"open1","Open"},{"load1","Load"},{"thru","Thru"}};
if(noThru) return {{"short1","Short"},{"open1","Open"},{"load1","Load"}};
else return {{"short1","Short"},{"open1","Open"},{"load1","Load"},{"thru","Thru"}};
}
// given the measurements for each of the calibration standards, compute the coefficients
MatrixXcd computeCoefficients(const vector<VNARawValue>& measurements) const override {
auto tmp = SOL_compute_coefficients(measurements[0](0,0), measurements[1](0,0), measurements[2](0,0));
Vector4cd ret(tmp[0],tmp[1],tmp[2],measurements[3](1,0));
auto tmp = SOL_compute_coefficients(measurements.at(0)(0,0), measurements.at(1)(0,0), measurements.at(2)(0,0));

auto x1 = measurements[2](0,0),
y1 = measurements[2](1,0),
x2 = measurements[1](0,0),
y2 = measurements[1](1,0);
complex<double> cal_thru_leak_r = (y1-y2)/(x1-x2);
complex<double> cal_thru_leak = y2-cal_thru_leak_r*x2;

complex<double> thru = 1.;
if(!noThru) thru = measurements.at(3)(1,0);

Vector6cd ret;
ret << tmp[0],tmp[1],tmp[2], cal_thru_leak, cal_thru_leak_r, thru;
return ret;
}
// given cal coefficients and a raw value, compute S parameters
VNACalibratedValue computeValue(MatrixXcd coeffs, VNARawValue val) const override {
array<complex<double>, 3> tmp {coeffs(0), coeffs(1), coeffs(2)};
VNACalibratedValue ret = val;
ret(0,0) = SOL_compute_reflection(tmp, val(0,0));

complex<double> cal_thru_leak_r = coeffs(4);
complex<double> cal_thru_leak = coeffs(3);

complex<double> thru = val(1,0) - (cal_thru_leak + val(0,0)*cal_thru_leak_r);
complex<double> refThru = coeffs(5) - (cal_thru_leak + val(0,0)*cal_thru_leak_r);

ret(1,0) = thru/refThru;
return ret;
}
};


class SOLTCalibration: public VNACalibration {
public:
// return the name of this calibration type
string name() const override {
virtual string name() const override {
return "solt";
}
string description() const override {
return "SOLT (two port)";
}
// get a list of calibration standards required
Expand All @@ -79,7 +91,7 @@ public:
};

vector<const VNACalibration*> initCalTypes() {
return {new SOLCalibration(), new SOLTCalibrationTR(), new SOLTCalibration()};
return {new SOLTCalibrationTR(true), new SOLTCalibrationTR(false), new SOLTCalibration()};
}


Expand Down
6 changes: 6 additions & 0 deletions libxavna/include/calibration.H
Expand Up @@ -53,10 +53,16 @@ class VNACalibration
public:
// return the name of this calibration type
virtual string name() const=0;

// return the descriptive name of this calibration type
virtual string description() const=0;

// get a list of calibration standards required
virtual vector<array<string, 2> > getRequiredStandards() const=0;

// given the measurements for each of the calibration standards, compute the coefficients
virtual MatrixXcd computeCoefficients(const vector<VNARawValue>& measurements) const=0;

// given cal coefficients and a raw value, compute S parameters
virtual VNACalibratedValue computeValue(MatrixXcd coeffs, VNARawValue val) const=0;
};
Expand Down

0 comments on commit f98b533

Please sign in to comment.