Skip to content

Commit

Permalink
adi/fmc_4p_vna: Updates for RevB
Browse files Browse the repository at this point in the history
 * Removed AD5732
 * Added hi_low_sel GPIO cotntrols
 * Renamed adrf5720-lo -> adrf5720-rfin2
 * Renamed mux-rfin-freq-src-sel -> mux-rfin-low

Signed-off-by: Michael Hennerich <[email protected]>
  • Loading branch information
mhennerich committed Jan 20, 2023
1 parent e4998c6 commit 021881c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
13 changes: 7 additions & 6 deletions adi/fmc_4p_vna.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numpy as np
from adi.ad4858 import ad4858
from adi.ad5686 import ad5686
from adi.ad9083 import ad9083
from adi.ad9173 import ad9173
from adi.adf4371 import adf4371
from adi.adl5960 import adl5960
from adi.admv8818 import admv8818
from adi.adrf5720 import adrf5720
from adi.gen_mux import genmux
from adi.one_bit_adc_dac import one_bit_adc_dac
from adi.ad9173 import ad9173
from adi.ad5686 import ad5686
from adi.ad4858 import ad4858


class fmc_4p_vna(adrf5720, ad9083, admv8818, genmux, adf4371, adl5960, one_bit_adc_dac):
""" FMCVNA Scalable 4-port Vector Network Analyzer Board """
Expand All @@ -51,15 +52,15 @@ class fmc_4p_vna(adrf5720, ad9083, admv8818, genmux, adf4371, adl5960, one_bit_a
def __init__(self, uri):
self.lo = adf4371(uri)
self.rfin_attenuator = adrf5720(uri, device_name="adrf5720-rfin")
self.lo_attenuator = adrf5720(uri, device_name="adrf5720-lo")
self.rfin2_attenuator = adrf5720(uri, device_name="adrf5720-rfin2")
self.bpf = admv8818(uri, device_name="admv8818")
self.rfin_mux = genmux(uri, device_name="mux-rfin")
self.lo_mux = genmux(uri, device_name="mux-adf4371")
self.freq_src_sel_mux = genmux(uri, device_name="mux-freq-src-sel")
self.rfin_freq_src_sel_mux = genmux(uri, device_name="mux-rfin-freq-src-sel")
self.rfin_low = genmux(uri, device_name="mux-rfin-low")
self.hsdac = ad9173(uri)
self.ad4858 = ad4858(uri)
self.ad5732 = ad5686(uri)
# self.ad5732 = ad5686(uri)

for i in range(1, 5):
self.frontend[i - 1] = adl5960(uri, device_name=f"adl5960-{i}")
Expand Down
24 changes: 12 additions & 12 deletions examples/4p_vna.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def spec_est(x, fs, ref=2 ** 15, plot=False, title=""):

return ampl, freqs


def ad4858_plot(x, plot=False, title=""):

if plot:
Expand All @@ -109,6 +110,7 @@ def ad4858_plot(x, plot=False, title=""):

return r_avg


def ad4858_capture():
channels = []
x = vna.ad4858.rx()
Expand All @@ -132,24 +134,20 @@ def ad4858_capture():
# Capture all 8 channels
vna.ad4858.rx_enabled_channels = [0, 1, 2, 3, 4, 5, 6, 7]
vna.ad4858.rx_buffer_size = 128
#fs_ad4858 = int(vna.ad4858.rx_sample_rate)
# fs_ad4858 = int(vna.ad4858.rx_sample_rate)

# ADRF5720
vna.lo_attenuator.attenuation = 6
vna.rfin2_attenuator.attenuation = 6
vna.rfin_attenuator.attenuation = 6

# AD5732R values between -8192...8191

vna.ad5732.channel[0].raw = 0
vna.ad5732.channel[1].raw = 0

vna.lo_mux.select = "rf8"
vna.rfin_mux.select = "d1"
vna.lo.frequency = 3e9
vna.lo.rfaux8_vco_output_enable = False

vna.freq_src_sel_mux.select = "rf_dac0_direct"
vna.rfin_freq_src_sel_mux.select = "rf_dac1_direct"
vna.rfin_low.select = "d1"

# vna.hsdac.modulation_switch_mode
# 0 = Mode 0
Expand All @@ -167,6 +165,7 @@ def ad4858_capture():
vna.hsdac.main0_nco_frequency = 100000000
vna.hsdac.main1_nco_frequency = 100000000


# push shifted DC the out of spectrum
if_frequency = fs

Expand Down Expand Up @@ -211,10 +210,9 @@ def ad4858_capture():
# vna.lo.rfaux8_vco_output_enable = True
# vna.lo.rf16_frequency = f


vna.bpf.band_pass_center_frequency = int(f / 1e6)
vna.hsdac.main0_nco_frequency = int(f)
#vna.hsdac.main1_nco_frequency = int(f)
# vna.hsdac.main1_nco_frequency = int(f)

print("ADL5960-", i, "CT2 REG 0x21 =", vna.frontend[0].reg_read(0x21))
# ADMV8818 should update automatically as long as the LO doubler is not used
Expand All @@ -233,10 +231,11 @@ def ad4858_capture():
"MHz",
)

print (ad4858_capture())
print(ad4858_capture())

for r in range(2):
i = int(r / 2) + 1
vna.gpio_hi_low_sel = 0
vna.rfin_mux.select = f"d{i}"
x = vna.rx()
if r & 1:
Expand All @@ -248,11 +247,12 @@ def ad4858_capture():

for r in range(2):
i = int(r / 2) + 1
vna.gpio_hi_low_sel = 1
vna.rfin_mux.select = f"d{i}"
x = vna.ad4858.rx()
if r & 1:
dir = "Reflected"
else:
dir = "Forward"
ad4858_plot(x[r], plot=True, title=f"AD4858 {dir} Port-{i} f={f} Hz")

ad4858_plot(x[r], plot=True, title=f"AD4858 {dir} Port-{i} f={f} Hz")

0 comments on commit 021881c

Please sign in to comment.