From 4f6940f78f615464ff397f98bf08dc1bd311be2e Mon Sep 17 00:00:00 2001 From: PopPaul2021 Date: Wed, 23 Oct 2024 15:52:58 +0300 Subject: [PATCH] examples/pluto_tddn: Add a complete example This example was updated to transmit a sine wave and capture 100 data buffers, all synchronized by the TDDN. Signed-off-by: PopPaul2021 --- examples/pluto_tddn.py | 157 +++++++++++++++++++++++++++++++++++------ 1 file changed, 135 insertions(+), 22 deletions(-) diff --git a/examples/pluto_tddn.py b/examples/pluto_tddn.py index 7b9ea3216..a219c5437 100644 --- a/examples/pluto_tddn.py +++ b/examples/pluto_tddn.py @@ -1,27 +1,140 @@ -# Copyright (C) 2024 Analog Devices, Inc. -# -# SPDX short identifier: ADIBSD - -import time +'''TDD test with Pluto''' +'''Connect a SMA cable from Tx1 to Rx1''' +# https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/pluto_tddn.py +# https://github.com/analogdevicesinc/pyadi-iio/blob/main/adi/tddn.py +# %% +# Imports +import numpy as np +import matplotlib.pyplot as plt import adi -sdr = adi.Pluto() +plt.close('all') + +'''This script uses the new Pluto TDD engine + Make sure your Pluto firmware is updated to rev 0.39 (or later) + And PYADI-IIO is rev 0.18 or greater +''' + +print(adi.__version__) + +# %% Configuration Variables +sample_rate = 10e6 +center_freq = 2.1e9 +signal_freq = 500e3 +rx_gain = 20 +tx_gain = -10 + +# %% Setup SDR +sdr_ip = "ip:192.168.2.1" # usually "ip:192.168.2.1", or "ip:pluto.local" +gpio = adi.one_bit_adc_dac(sdr_ip) +my_sdr = adi.Pluto(uri=sdr_ip) +tddn = adi.tddn(sdr_ip) + +# If you want repeatable alignment between transmit and receive then the rx_lo, tx_lo and sample_rate can only be set once after power up +# But if you don't care about this, then program sample_rate and LO's as much as you want +# So after bootup, check if the default sample_rate and LOs are being used, if so then program new ones! +if 30719990