Hi everyone,
I am trying to schedule the transmitting frequency of the Pluto
For example, by scheduling in python, I would like to change the frequency from 900,1 MHz to 900,2 MHz and 900,3MHz automatically at a specific time using the schedule library python.
I have tried to set the lo_frequency at 900 MHz and created a single-tone signal at 100KHZ, which means the signal will transfer a single tone at 900,1MHz. Then I tried to change the frequency of the signal to 200Khz but it seem that the transmitter did not switch to the new frequency.
Can anyone show me how to change the frequency of the transmitter in python. Thanks
import numpy as np import adi import matplotlib.pyplot as plt import time import schedule #define parameter sample_rate = 2e6 ts = float(1/sample_rate) center_freq = 900e6 num_samples = 1024 #declare hardware object with ip address sdr = adi.Pluto("ip:192.168.2.1") sdr.sample_rate = int(sample_rate) # config TX sdr.tx_lo = int(center_freq) sdr.tx_rf_bandwidth = int(sample_rate) sdr.rx_hardwaregain_chan0 = -90 #dB #config rx sdr.rx_lo = int(center_freq) sdr.rx_rf_bandwidth = int(sample_rate) sdr.gain_control_mode_chan0 = 'manual' sdr.rx_hardwaregain_chan0 = -90 #dB sdr.rx_buffer_size = num_samples def create_signal(freq): ## Create a sinewave waveform with fc = freq print("fuction called") fs = int(sample_rate) fc = int(freq / (fs / num_samples)) * (fs / num_samples) ts = 1 / float(fs) t = np.arange(0, num_samples * ts, ts) #Return evenly spaced values within a given interval. i = np.cos(2 * np.pi * t * fc) * 2 ** 14 q = np.sin(2 * np.pi * t * fc) * 2 ** 14 samples = i + 1j * q return samples samples = create_signal(100000) # turn on buffer to transmit overlapping # sdr.tx_cyclic_buffer = True # sdr.tx(samples) #transmit the samples fig, ax = plt.subplots() freq_vector = np.fft.fftshift(np.fft.fftfreq(num_samples, d=ts)) line, = ax.plot(freq_vector, np.random.rand(num_samples),'-', lw=2) ax.set_xlabel('Frequency') ax.set_ylabel('Magnitude dB') ax.set_ylim(-80,60) fig.show() while True: #Receiving samples rx_samples = sdr.rx() # this will return received IQ samples into rx_samples rx_fft = np.fft.fftshift(np.fft.fft(rx_samples)) mag_dbfs = 20*np.log10((np.abs(rx_fft))/(2**12)) line.set_ydata(mag_dbfs) fig.canvas.draw() fig.canvas.flush_events()