def testPlutoDDS(self): # See if we can tone from Pluto using DMAs sdr = Pluto() sdr.tx_lo = 1000000000 sdr.rx_lo = 1000000000 sdr.tx_cyclic_buffer = True sdr.tx_hardwaregain = -30 sdr.gain_control_mode = "slow_attack" sdr.rx_buffer_size = 2**20 sdr.sample_rate = 4000000 sdr.loopback = 1 # Create a sinewave waveform RXFS = int(sdr.sample_rate) sdr.dds_enabled = [1, 1, 1, 1] fc = 2000 sdr.dds_frequencies = [fc, 0, fc, 0] sdr.dds_scales = [1, 0, 1, 0] sdr.dds_phases = [90000, 0, 0, 0] # Pass through SDR for _ in range(5): data = sdr.rx() # Turn off loopback (for other tests) sdr.loopback = 0 tone_freq = self.freq_est(data, RXFS) # if self.do_plots: # import matplotlib.pyplot as plt # # reals = np.real(data) # plt.plot(reals) # imags = np.imag(data) # plt.plot(imags) # plt.xlabel("Samples") # plt.ylabel("Amplitude [dbFS]") # plt.show() diff = np.abs(tone_freq - fc) del sdr self.assertGreater(fc * 0.01, diff, "Frequency offset")
def testPlutoDAC(self): # See if we can tone from Pluto using DMAs sdr = Pluto() sdr.tx_lo = 1000000000 sdr.rx_lo = 1000000000 sdr.tx_cyclic_buffer = True sdr.tx_hardwaregain = -30 sdr.gain_control_mode = "slow_attack" sdr.rx_buffer_size = 2**20 # Create a sinewave waveform RXFS = int(sdr.sample_rate) fc = RXFS * 0.1 N = 2**15 ts = 1 / float(RXFS) t = np.arange(0, N * ts, ts) i = np.cos(2 * np.pi * t * fc) * 2**15 * 0.5 q = np.sin(2 * np.pi * t * fc) * 2**15 * 0.5 iq = i + 1j * q # Pass through SDR sdr.tx(iq) for _ in range(5): data = sdr.rx() tone_freq = self.freq_est(data, RXFS) # if self.do_plots: # import matplotlib.pyplot as plt # # reals = np.real(data) # plt.plot(reals) # imags = np.imag(data) # plt.plot(imags) # plt.xlabel("Samples") # plt.ylabel("Amplitude [dbFS]") # plt.show() diff = np.abs(tone_freq - fc) del sdr self.assertGreater(fc * 0.01, diff, "Frequency offset")