KCC's Quizzes AQQ306 about a fish stick challenge
1. First the quote of the month: " I am so clever that sometimes I don't understand a single word of what I am saying" - Oscar Wilde
2. New quiz AQQ306 about a fish stick challenge:
Here below is a pseudo fish diagram swimming to the right.
Question
View All
October Monthly Blog Quiz! Read the blog, take the quiz, and you could win a gift card
Finding Your Circuit Chi — EMC Quiz!
Think you know EMC? Test your knowledge with our 5-question quiz!
Read the blog first, then take the challenge: Finding Your Circuit Chi
Every current flowing creates electromagnetic fields.
Strong EMC design
View All
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.")
/>
elenahadarau - Moved from FPGA Reference Designs to Software Interface Tools. Post date updated from Saturday, August 9, 2025 5:04 PM UTC to Monday, August 11, 2025 12:44 PM UTC to reflect the move.
elenahadarau - Moved from FPGA Reference Designs to Software Interface Tools. Post date updated from Monday, August 11, 2025 12:44 PM UTC to Monday, August 11, 2025 12:44 PM UTC to reflect the move.
Hi,
Could you try reproducing this with the latest Kuiper image 2023_R2 Patch1?
You can find the release here:
GitHub: https://github.com/analogdevicesinc/adi-kuiper-gen/releases/tag/2023_r2_p1
Release notes: https://wiki.analog.com/resources/tools-software/linux-software/adi-kuiper_images/release_notes
I will move this topic to the Software Interface Tools , as it seems to fit better there.
Regards, Elena
Hi Elena,
Thank you for the replay. Kuiper image 2023_R2 Patch1 behaves the very same way as the image_2024-06-18-ADI-Kuiper-full. Its not looping back any rx tone received to tx. (I am still using pyadi-iio 0.0.19/same code above/Kuiper image 2023_R2 Patch1/m8_l4 config)
Thank you!
Hi,
Apologies for the delayed reply.
dev.loopback_mode = 2 # can't set this - will gives an error
This mode 2 does not exist, so it's expected to give an error. Please check the comment from here: pyadi-iio/adi/ad9081.py at main · analogdevicesinc/pyadi-iio (line 617). It works just 0/1.
If you enable this attribute, it would mean it's not using the RF I/O, but circle back what's in the RX path already, if there's any data.
Is this what you want? Or could you explain a little bit more detailed?
Regards, Elena
Hi dm100 ,
Were all your questions answered, or is there anything else we can help with?
Regards, Elena
Hi,
Is there anything we can help with or can we close the thread?
Regards, Elena
Closing this thread due to inactivity.
Closing this thread due to inactivity.