Post Go back to editing

AD9081+ZCU102 reference design RX to TX loop back not working

Thread Summary

The user is unable to get the AD9081 ADC to DAC loopback working in loopback mode 1 using the pyadi-iio 0.0.19 library and AD9081+ZCU102 reference design with the m8_l4 configuration. The support engineer confirmed that loopback mode 2 does not exist and suggested checking the JESD204 status. The user reported that the issue persists with the latest Kuiper image 2023_R2 Patch1. The loopback mode 1 is intended to feed the RX data back to the TX path, but it is not functioning as expected.
AI Generated Content
Category: Software
Product Number: AD9081

Hello,  I cannot get AD9081 ADC to DAC loop back working using pyadi-iio 0.0.19 and AD9081+ZCU102 reference design 

This is the reference design image file i am using is image_2024-06-18-ADI-Kuiper-full and using the m8_l4 config

Below is the code 

I added a TX section to check the functionality of TX and TX section works.

dev.loopback_mode = 0  # working

dev.loopback_mode = 1  # not working
dev.loopback_mode = 2  # can't set this - will gives an error

<

import time
import numpy as np
import adi

def gen_tone(fc, fs, N):
    fc = int(fc / (fs / N)) * (fs / N)  # Align frequency to sampling rate
    ts = 1 / float(fs)
    t = np.arange(0, N * ts, ts)
    i = np.cos(2 * np.pi * t * fc) * 2 ** 14
    q = np.sin(2 * np.pi * t * fc) * 2 ** 14
    return i + 1j * q

def dbfs(raw_data, adc_bits=14):
    NumSamples = len(raw_data)
    win = np.hamming(NumSamples)
    y = raw_data * win
    s_fft = np.fft.fft(y) / np.sum(win)
    s_shift = np.fft.fftshift(s_fft)
    adc_full_scale = 2 ** (adc_bits - 1)
    s_dbfs = 20 * np.log10(np.abs(s_shift) / adc_full_scale + 1e-12)
    return s_dbfs

FS_REF = 2**15
def fft_peak_dbfs_and_freq(x, fs, fs_ref=FS_REF):
    x = x.astype(np.complex64, copy=False)
    x -= np.mean(x)
    n   = x.size
    win = np.hamming(n).astype(np.float32)
    S   = np.fft.fftshift(np.fft.fft(x * win) / np.sum(win))
    P   = 20.0 * np.log10(np.abs(S) / (fs_ref + 1e-20) + 1e-20)
    f   = np.fft.fftshift(np.fft.fftfreq(n, d=1.0/fs))
    k   = int(np.argmax(P))
    return float(P[k]), float(f[k])

dev = adi.ad9081(uri = "ip:192.168.0.11")

dev.loopback_mode = 0
fs_rx = dev.rx_sample_rate
fs_tx = dev.rx_sample_rate
print(fs_rx)
print(fs_rx)
dev.rx_channel_nco_frequencies = [0] * 4
dev.tx_channel_nco_frequencies = [0] * 4
dev.rx_main_nco_frequencies = [100000000] * 4
dev.tx_main_nco_frequencies = [100000000] * 4
dev.rx_enabled_channels = [0, 1, 2, 3]
dev.tx_enabled_channels = [0, 1, 2, 3]
dev.rx_nyquist_zone = ["odd"] * 4
dev.tx_main_6dB_digital_gains = [1] * 4
dev.rx_buffer_size = 2 ** 16
dev.tx_cyclic_buffer = True

status = dev.jesd204_device_status_check
state = dev.jesd204_fsm_state
print(f'Status {status}')
print(f'state {state}')

N = 1024
tone_freq = 10000e3  # 10 MHz baseband
iq1 = gen_tone(tone_freq, fs_rx, N)
dev.tx_ddr_offload = 1
amplitude = .5
scaled_iq_data = iq1 * amplitude

dev.tx([scaled_iq_data, scaled_iq_data, scaled_iq_data, scaled_iq_data])
print(f"[TX sanity] Transmitting RF ≈ MHz "
      f"+  MHz baseband for 3 s… "
      "(loopback OFF)")
time.sleep(3)

# So Here was able to see the TX tone  - So TX path is working.

dev.tx_destroy_buffer()
dev.tx_cyclic_buffer = False
dev.tx_ddr_offload = 0   # disabled DDR offload so loopback can feed TX
dev.rx_enabled_channels = [0]
dev.tx_enabled_channels = [0]
dev.rx_channel_nco_frequencies = [0]
dev.tx_channel_nco_frequencies = [0]
dev.rx_main_nco_frequencies = [100_000_000]
dev.tx_main_nco_frequencies = [100_000_000]
dev.rx_nyquist_zone = ["even"]
BUF_LEN = 1 << 14
dev.rx_buffer_size = BUF_LEN
fs = float(dev.rx_sample_rate)

#check JESD status
try:
    print(str(dev.jesd204_device_status))
    if getattr(dev, "jesd204_device_status_check", False):
        raise RuntimeError("JESD reports errors; fix link before loopback.")
except Exception:
    pass

#RX to TX
dev.loopback_mode = 1  # not working
dev.loopback_mode = 2  # can't set this - will gives an error

print(f"Loopback enabled. fs_rx={fs:,.0f} Hz, N={BUF_LEN}. Ctrl-C to stop.")

def fft_peak_dbfs_and_freq(x, fs, fs_ref=2**15):
    x = x.astype(np.complex64, copy=False)
    x -= np.mean(x)
    n   = x.size
    win = np.hamming(n).astype(np.float32)
    S   = np.fft.fftshift(np.fft.fft(x * win) / np.sum(win))
    P   = 20.0 * np.log10(np.abs(S) / (fs_ref + 1e-20) + 1e-20)
    f   = np.fft.fftshift(np.fft.fftfreq(n, d=1.0 / fs))
    k   = int(np.argmax(P))
    return float(P[k]), float(f[k])

try:
    while True:
        s = dev.rx()
        pk_dbfs, pk_hz = fft_peak_dbfs_and_freq(s, fs)
        print(f"Peak: {pk_dbfs:6.2f} dBFS @ {pk_hz/1e6:9.4f} MHz", flush=True)
        time.sleep(0.05)
except KeyboardInterrupt:
    pass
finally:
    try:
        dev.loopback_mode = 0
    except Exception:
        pass
    print("Loopback disabled. Done.")

/>

Thread Notes

Parents Reply Children
No Data

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.