Compare commits
5 Commits
c5dc320989
...
main
Author | SHA1 | Date | |
---|---|---|---|
2a5f1657f4 | |||
7644cbe0ad | |||
92c5876b23 | |||
3b12c21e20 | |||
1170da8b04 |
481
examples/spectral_purity.ipynb
Normal file
481
examples/spectral_purity.ipynb
Normal file
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@ description = "RF Network Analyzer based on the Pluto SDR"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3"
|
requires-python = ">=3"
|
||||||
# keywords = ["one", "two"]
|
# keywords = ["one", "two"]
|
||||||
license = { text = "MIT License" }
|
license = "MIT"
|
||||||
classifiers = ["Programming Language :: Python :: 3"]
|
classifiers = ["Programming Language :: Python :: 3"]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"numpy",
|
"numpy",
|
||||||
@@ -34,7 +34,7 @@ charon-cli = "charon_vna.cli:main"
|
|||||||
charon-gui = "charon_vna.gui:main"
|
charon-gui = "charon_vna.gui:main"
|
||||||
|
|
||||||
[tool.setuptools_scm]
|
[tool.setuptools_scm]
|
||||||
version_file = "charon_vna/_version.py"
|
version_file = "src/charon_vna/_version.py"
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
|
@@ -137,7 +137,7 @@ class Charon:
|
|||||||
self.ctrl = ctx.find_device("ad9361-phy")
|
self.ctrl = ctx.find_device("ad9361-phy")
|
||||||
# raw ad9361 register accesss:
|
# raw ad9361 register accesss:
|
||||||
# https://ez.analog.com/linux-software-drivers/f/q-a/120853/control-fmcomms3-s-gpo-with-python
|
# 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.EXTERNAL_LNA_CONTROL, 0x90) # bit 7: AuxDAC Manual, bit 4: GPO Manual
|
||||||
self.ctrl.reg_write(AD9361Register.AUXDAC_ENABLE_CONTROL, 0x3F)
|
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
|
# https://www.analog.com/media/cn/technical-documentation/user-guides/ad9364_register_map_reference_manual_ug-672.pdf
|
||||||
# page 13
|
# 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
|
# 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
|
# 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
|
# vref basically just changes the minimum voltage with negligible impact on output scaling
|
||||||
@@ -308,7 +313,7 @@ class Charon:
|
|||||||
|
|
||||||
def capture(
|
def capture(
|
||||||
self,
|
self,
|
||||||
callback: Callable[int, int] | None = None,
|
callback: Callable[[int, int], None] | None = None,
|
||||||
*,
|
*,
|
||||||
measurements: List[Tuple[int, int]] = None,
|
measurements: List[Tuple[int, int]] = None,
|
||||||
):
|
):
|
@@ -1,6 +1,7 @@
|
|||||||
# %% imports
|
# %% imports
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
from matplotlib.ticker import EngFormatter
|
||||||
|
|
||||||
from charon_vna.util import db20, net2s, s2net
|
from charon_vna.util import db20, net2s, s2net
|
||||||
from charon_vna.vna import Charon
|
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.plot(s2.frequency, db20(s2.sel(m=m, n=n)), label="$S_{" + str(m) + str(n) + "}$ (calibrated)")
|
||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
plt.legend()
|
plt.legend()
|
||||||
|
plt.xlabel("Frequency [Hz]")
|
||||||
plt.ylabel("Magnitude [dB]")
|
plt.ylabel("Magnitude [dB]")
|
||||||
# plt.ylim(-30, 5)
|
# 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()
|
plt.show()
|
||||||
|
|
||||||
for m in s.m.data:
|
for m in s.m.data:
|
||||||
@@ -66,6 +72,10 @@ for m in s.m.data:
|
|||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.ylabel("Phase [deg]")
|
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()
|
plt.show()
|
||||||
|
|
||||||
# %%
|
# %%
|
Reference in New Issue
Block a user