Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibration standarts fix and improve #450

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions NanoVNASaver/Calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,38 +235,36 @@ def gamma_short(self, freq: int) -> complex:
g = Calibration.IDEAL_SHORT
if not self.useIdealShort:
logger.debug("Using short calibration set values.")
Zsp = complex(0, 1) * 2 * math.pi * freq * (
Zsp = complex(0, 2 * math.pi * freq * (
self.shortL0 + self.shortL1 * freq +
self.shortL2 * freq**2 + self.shortL3 * freq**3)
self.shortL2 * freq**2 + self.shortL3 * freq**3))
# Referencing https://arxiv.org/pdf/1606.02446.pdf (18) - (21)
g = (Zsp / 50 - 1) / (Zsp / 50 + 1) * cmath.exp(
complex(0, 1) * 2 * math.pi * 2 * freq *
self.shortLength * -1)
complex(0, 2 * math.pi * 2 * freq * self.shortLength * -1))
return g

def gamma_open(self, freq: int) -> complex:
g = Calibration.IDEAL_OPEN
if not self.useIdealOpen:
logger.debug("Using open calibration set values.")
divisor = (2 * math.pi * freq * (
Zop = complex(0, 2 * math.pi * freq * (
self.openC0 + self.openC1 * freq +
self.openC2 * freq**2 + self.openC3 * freq**3))
if divisor != 0:
Zop = complex(0, -1) / divisor
g = ((Zop / 50 - 1) / (Zop / 50 + 1)) * cmath.exp(
complex(0, 1) * 2 * math.pi *
2 * freq * self.openLength * -1)
g = ((1 - 50 * Zop) / (1 + 50 * Zop)) * cmath.exp(
complex(0, 2 * math.pi * 2 * freq * self.openLength * -1))
return g

def gamma_load(self, freq: int) -> complex:
g = Calibration.IDEAL_LOAD
if not self.useIdealLoad:
logger.debug("Using load calibration set values.")
Zl = self.loadR + (complex(0, 1) * 2 *
math.pi * freq * self.loadL)
Zl = complex(self.loadR, 0)
if self.loadC > 0:
Zl = self.loadR / complex(1, 2 * self.loadR * math.pi * freq * self.loadC)
if self.loadL > 0:
Zl = Zl + complex(0, 2 * math.pi * freq * self.loadL)
g = (Zl / 50 - 1) / (Zl / 50 + 1) * cmath.exp(
complex(0, 1) * 2 * math.pi *
2 * freq * self.loadLength * -1)
complex(0, 2 * math.pi * 2 * freq * self.loadLength * -1))
return g

def gamma_through(self, freq: int) -> complex:
Expand Down
20 changes: 9 additions & 11 deletions NanoVNASaver/Windows/CalibrationSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ def __init__(self, app: QtWidgets.QWidget):
self.load_resistance.setMinimumHeight(20)
self.load_inductance = QtWidgets.QLineEdit("0")
self.load_inductance.setMinimumHeight(20)
# self.load_capacitance = QtWidgets.QLineEdit("0")
# self.load_capacitance.setMinimumHeight(20)
# self.load_capacitance.setDisabled(True) # Not yet implemented
self.load_capacitance = QtWidgets.QLineEdit("0")
self.load_capacitance.setMinimumHeight(20)
#self.load_capacitance.setDisabled(True) # Not yet implemented
self.load_length = QtWidgets.QLineEdit("0")
self.load_length.setMinimumHeight(20)
cal_load_form.addRow("Resistance (\N{OHM SIGN})", self.load_resistance)
cal_load_form.addRow("Inductance (H(e-12))", self.load_inductance)
# cal_load_form.addRow("Capacitance (F(e-12))", self.load_capacitance)
cal_load_form.addRow("Capacitance (F(e-15))", self.load_capacitance)
cal_load_form.addRow("Offset Delay (ps)", self.load_length)

self.cal_through_box = QtWidgets.QGroupBox("Through")
Expand Down Expand Up @@ -313,7 +313,7 @@ def saveCalibrationStandard(self):

self.app.settings.setValue("LoadR", self.load_resistance.text())
self.app.settings.setValue("LoadL", self.load_inductance.text())
# self.app.settings.setValue("LoadC", self.load_capacitance.text())
self.app.settings.setValue("LoadC", self.load_capacitance.text())
self.app.settings.setValue("LoadDelay", self.load_length.text())

self.app.settings.setValue("ThroughDelay", self.through_length.text())
Expand Down Expand Up @@ -348,7 +348,7 @@ def loadCalibrationStandard(self):

self.load_resistance.setText(str(self.app.settings.value("LoadR", 50)))
self.load_inductance.setText(str(self.app.settings.value("LoadL", 0)))
# self.load_capacitance.setText(str(self.app.settings.value("LoadC", 0)))
self.load_capacitance.setText(str(self.app.settings.value("LoadC", 0)))
self.load_length.setText(str(self.app.settings.value("LoadDelay", 0)))

self.through_length.setText(str(self.app.settings.value("ThroughDelay", 0)))
Expand Down Expand Up @@ -511,8 +511,6 @@ def calculate(self):
try:
self.app.calibration.openC0 = self.getFloatValue(
self.open_c0_input.text())/10**15
if self.app.calibration.openC0 == 0:
raise ValueError("C0 cannot be 0.")
self.app.calibration.openC1 = self.getFloatValue(
self.open_c1_input.text())/10**27
self.app.calibration.openC2 = self.getFloatValue(
Expand All @@ -531,9 +529,9 @@ def calculate(self):
self.app.calibration.loadR = self.getFloatValue(
self.load_resistance.text())
self.app.calibration.loadL = self.getFloatValue(
self.load_inductance.text())/10**12
# self.app.calibration.loadC = self.getFloatValue(
# self.load_capacitance.text()) / 10 ** 12
self.load_inductance.text()) / 10**12
self.app.calibration.loadC = self.getFloatValue(
self.load_capacitance.text()) / 10 ** 15
self.app.calibration.loadLength = self.getFloatValue(
self.load_length.text())/10**12
self.app.calibration.useIdealLoad = False
Expand Down