2 Commits

Author SHA1 Message Date
3b12c21e20 typing + flake8
Some checks failed
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Failing after -53s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been skipped
2025-07-16 22:00:07 -06:00
1170da8b04 plots 2025-07-16 21:56:30 -06:00
2 changed files with 18 additions and 3 deletions

View File

@@ -137,7 +137,7 @@ class Charon:
self.ctrl = ctx.find_device("ad9361-phy")
# raw ad9361 register accesss:
# https://ez.analog.com/linux-software-drivers/f/q-a/120853/control-fmcomms3-s-gpo-with-python
# https://www.analog.com/media/cn/technical-documentation/user-guides/ad9364_register_map_reference_manual_ug-672.pdf # noqa: E501
# https://www.analog.com/media/cn/technical-documentation/user-guides/ad9364_register_map_reference_manual_ug-672.pdf
self.ctrl.reg_write(AD9361Register.EXTERNAL_LNA_CONTROL, 0x90) # bit 7: AuxDAC Manual, bit 4: GPO Manual
self.ctrl.reg_write(AD9361Register.AUXDAC_ENABLE_CONTROL, 0x3F)
@@ -205,7 +205,12 @@ class Charon:
# https://www.analog.com/media/cn/technical-documentation/user-guides/ad9364_register_map_reference_manual_ug-672.pdf
# page 13
# vout = 0.97 * vref + (0.000738 + 9e-6 * (vref * 1.6 - 2)) * auxdac_word[9:0] * step_factor - 0.3572 * step_factor + 0.05
# vout = (
# 0.97 * vref
# + (0.000738 + 9e-6 * (vref * 1.6 - 2)) * auxdac_word[9:0] * step_factor
# - 0.3572 * step_factor
# + 0.05
# )
# vout ~= (vref - 0.3572 * step_factor) + 0.000738 * auxdac_word[9:0] * step_factor
# which gives a 1.5V swing with step_factor == 2 and 0.75V swing with step_factor == 1
# vref basically just changes the minimum voltage with negligible impact on output scaling
@@ -308,7 +313,7 @@ class Charon:
def capture(
self,
callback: Callable[int, int] | None = None,
callback: Callable[[int, int], None] | None = None,
*,
measurements: List[Tuple[int, int]] = None,
):

View File

@@ -1,6 +1,7 @@
# %% imports
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.ticker import EngFormatter
from charon_vna.util import db20, net2s, s2net
from charon_vna.vna import Charon
@@ -46,8 +47,13 @@ for m in s.m.data:
plt.plot(s2.frequency, db20(s2.sel(m=m, n=n)), label="$S_{" + str(m) + str(n) + "}$ (calibrated)")
plt.grid(True)
plt.legend()
plt.xlabel("Frequency [Hz]")
plt.ylabel("Magnitude [dB]")
# plt.ylim(-30, 5)
plt.ylim(-25, 5)
plt.xlim(s.frequency[0], s.frequency[-1])
plt.gca().xaxis.set_major_formatter(EngFormatter())
plt.tight_layout()
plt.show()
for m in s.m.data:
@@ -66,6 +72,10 @@ for m in s.m.data:
plt.grid(True)
plt.legend()
plt.ylabel("Phase [deg]")
plt.xlabel("Frequency [Hz]")
plt.xlim(s.frequency[0], s.frequency[-1])
plt.gca().xaxis.set_major_formatter(EngFormatter())
plt.tight_layout()
plt.show()
# %%