add pluto example from adi
All checks were successful
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in 1m8s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been skipped

This commit is contained in:
Brendan Haines 2024-11-10 12:45:31 -07:00
parent 6fe1aaf51a
commit 83d495920a

View File

@ -0,0 +1,63 @@
# Copyright (C) 2019 Analog Devices, Inc.
#
# SPDX short identifier: ADIBSD
# I'm not sure why but sometimes I need to run this once to make the rest of my scripts work.
# Probably just me running things manually out of order or something but I'm throwing this in here until I verify.
import time
import adi
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
# Create radio
sdr = adi.Pluto(uri="ip:192.168.3.1")
# Configure properties
sdr.rx_rf_bandwidth = 4000000
sdr.rx_lo = 2000000000
sdr.tx_lo = 2000000000
sdr.tx_cyclic_buffer = True
sdr.tx_hardwaregain_chan0 = -30
sdr.gain_control_mode_chan0 = "slow_attack"
# Read properties
print("RX LO %s" % (sdr.rx_lo))
# Create a sinewave waveform
fs = int(sdr.sample_rate)
print(fs)
N = 1024
fc = int(-3000000 / (fs / N)) * (fs / N)
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
iq = i + 1j * q
# Send data
sdr.tx(iq)
# Collect data
for r in range(20):
x = sdr.rx()
f, Pxx_den = signal.periodogram(x, fs, return_onesided=False)
plt.clf()
plt.semilogy(f, Pxx_den)
plt.ylim([1e-7, 1e2])
plt.xlabel("frequency [Hz]")
plt.ylabel("PSD [V**2/Hz]")
plt.grid(True)
plt.draw()
plt.pause(0.05)
time.sleep(0.1)
plt.show()
plt.plot(np.real(x))
plt.plot(np.imag(x))
plt.show()