I'm trying to make a spectral analyzer with adalm pluto Rev B, but the values are no equals. The conections are made how the image show:
For processing de data I used this code:
import numpy as np import adi import matplotlib.pyplot as plt import time # Setting Parameter sample_rate = 10e6 # Hz center_freq = 3e9 # Hz #Configuration of Pluto sdr = adi.Pluto("ip:192.168.2.1") sdr.sample_rate = int(sample_rate) sdr.rx_rf_bandwidth = int(sample_rate) # filter cutoff, just set it to the same as sample rate sdr.rx_lo = int(center_freq) sdr.rx_buffer_size = 1024 # this is the buffer the Pluto uses to buffer samples sdr.gain_control_mode_chan0 = 'manual' sdr.rx_hardwaregain_chan0 = -40.0 # dB # FFT setup fft_size = 1024 nSweep = 100 spectrogram = np.zeros((nSweep, fft_size)) # Take samples start_time = time.time() for i in range(nSweep): sample = sdr.rx() # receive samples off Pluto window = np.hamming(1024) filter_sample = sample*window fft_sample = np.fft.fftshift(np.fft.fft(filter_sample)) s_mag = np.abs(fft_sample) / (np.sum(window)/2) # Scale FFT by window and /2 since we are using half the FFT spectrum spectrogram[i,:] = 20*np.log10(s_mag/(2**12)) + 6.6943 # Pluto is a 12 bit ADC, so use that to convert to dBFS end_time = time.time() print('seconds elapsed:', end_time - start_time) peak = np.max(np.max(spectrogram, axis=0)) plt.figure(figsize=(5, 6.5)) plt.plot(np.linspace(sample_rate/-2/1e6, sample_rate/2/1e6, spectrogram.shape[1]),np.max(spectrogram, axis=0)) plt.text(0, peak,str(round(peak,2))+' dBm', fontsize = 12) plt.xlabel("Frequency [MHz]") #plt.ylabel("PSD dBm") plt.title('Centre: 3000MHz'.ljust(40)+ "Span: 10Mhz\nRBW: 10MHz".ljust(55)+"VBW: 10MHz\nAtt:20dB".ljust(78)) plt.grid(color = "grey", linestyle = "--",linewidth = "1.4", alpha=0.4) plt.xticks([-5,-4,-3,-2,-1,0,1,2,3,4,5]) plt.show()
Expain the code:
But in processing data I not sure about scale by window length /2. That is a code copy from Pluto Rev. C
Results
The values obtain are close to spectrum analyzer, but I don't how justify why are divide by 2. On the left side, the result obtained by the TTi PSA6005 spectrum analyzer is shown, and on the right side, the sample obtained by the ADALM PLUTO is observed.
srimoyi - Moved from Design Support AD9361/AD9363/AD9364 to Virtual Classroom for ADI University Program. Post date updated from Thursday, July 11, 2024 9:47 PM UTC to Friday, July 12, 2024 11:56 AM UTC to reflect the move.
srimoyi - Moved from Design Support AD9361/AD9363/AD9364 to Virtual Classroom for ADI University Program. Post date updated from Friday, July 12, 2024 11:56 AM UTC to Friday, July 12, 2024 11:56 AM UTC to reflect the move.
Moving to appropriate forum
Which is the appropiate forum?
Hello,
here is another example of spectrogram python code you can try: https://pysdr.org/content/frequency_domain.html
In order to make a spectrum analyzer with pluto, a calibration of gain vs frequency on the rx channel should be done first.
- Valentin
I used this code when I first started, but it calculates the Power Spectral Density (PSD). What I need is a method to measure power instead. How could calibrate gain vs frequency?
Anyone has an idea how to do?