Hello!
I need to continously record IQ samples to file using pyadi-iio. My question is which is the recommended way to do it.
So far I succeeded for sdr.rx_buffer_size up to a limit, lets say 1M size.
However, how should I control this for a sample rate of lets say 1MSPS and an acquisition time of 30 minutes? (about 2Giga samples)
This is the sample code I've been using for short acquisitions (I also transmit samples so that I have sth useful to record). The question is which is the recommended way to extend the acquisition time without loosing samples.
I am using ubuntu 20.04.01
import numpy as np
import adi
import matplotlib.pyplot as plt
import scipy
from scipy.io import wavfile
sample_rate = 960000 # Hz
center_freq = 915000000 # Hz
acq_secs = 1 # acquisition length in seconds
num_samps = int(acq_secs * sample_rate) # number of samples per call to rx()
rf_bw = 200000 # Hz J
sdr = adi.Pluto("ip:192.168.2.1")
sdr.sample_rate = int(sample_rate)
# Config Tx
sdr.tx_rf_bandwidth = int(rf_bw) # filter cutoff, just set it to the same as sample rate
sdr.tx_lo = int(center_freq)
sdr.tx_hardwaregain_chan0 = -50 # Increase to increase tx power, valid range is -90 to 0 dB
# Config Rx
sdr.rx_lo = int(center_freq)
sdr.rx_rf_bandwidth = int(sample_rate)
sdr.rx_buffer_size = num_samps
sdr.gain_control_mode_chan0 = 'manual'
sdr.rx_hardwaregain_chan0 = 0.0 # dB, increase to increase the receive gain, but be careful not to saturate the ADC
# Create transmit waveform (QPSK, 16 samples per symbol)
num_symbols = 1000
x_int = np.random.randint(0, 4, num_symbols) # 0 to 3
x_degrees = x_int*360/4.0 + 45 # 45, 135, 225, 315 degrees
x_radians = x_degrees*np.pi/180.0 # sin() and cos() takes in radians
x_symbols = np.cos(x_radians) + 1j*np.sin(x_radians) # this produces our QPSK complex symbols
samples = np.repeat(x_symbols, 16) # 16 samples per symbol (rectangular pulses)
samples *= 2**14 # The PlutoSDR expects samples to be between -2^14 and +2^14, not -1 and +1 like some SDRs
# Start the transmitter
sdr.tx_cyclic_buffer = True # Enable cyclic buffers
sdr.tx(samples) # start transmitting
# Clear buffer just to be safe
for i in range (0, 10):
raw_data = sdr.rx()
# Receive samples
rx_samples = sdr.rx()
print(rx_samples)
# save IQ rec to disk
wav_samples = np.zeros((num_samps, 2), dtype=np.float32)
wav_samples[...,0] = rx_samples.real
wav_samples[...,1] = rx_samples.imag
scipy.io.wavfile.write('out.wav', int(sample_rate), wav_samples)
# Stop transmitting
sdr.tx_destroy_buffer()