USRP X310 streaming problem. I kept receiving the same signal

138 views Asked by At

Great afternoon from South Korea!

I am working on USRP X310 and trying to make a streaming of tx and rx. I have read the ettus.com manuals and started working on the streaming.

The problem that I am facing is that when I run the streamer object of Rx and Tx from the receiver, I get the same data over and over. I have put in 5 different data and expected it to have a small difference at least. However, the data is the same. About the streamer. I have sent 10000 tx data and sent it in five chunks and the receiver is only receiving the 2000 buffers every time. I want to know why I am getting the same data over and over.

import  numpy as np
import matplotlib.pyplot as plt
import uhd,threading, time
import dvbt2_detect,dvbt2_detectV2
from scipy.io import loadmat
import scipy.signal as sg
from fifoBuffer import FIFOBuffer

plt.close()
Fs = 50e6  # 20MHz sampling rate
Ts_dvbt2 = 7/64*1e-6        # DVB-T2 with sampling time = 7/64us (Table 65)
Fs_dvbt2 = 1/Ts_dvbt2


## Tx P1-Preamble Normalization
dvbt2_org = loadmat("./data/generatedP1.mat")['data'].flatten()
dvbt2_20MHz = sg.resample(dvbt2_org, int(len(dvbt2_org)*35/16))
real_data = np.real(dvbt2_20MHz)
imag_data = np.imag(dvbt2_20MHz)
max_value = np.max([np.abs(real_data).max(), np.abs(imag_data).max()])
real_data = (real_data -real_data.mean())/max_value
imag_data = (imag_data -imag_data.mean())/max_value

dvbt2_20MHz_norm = real_data+1j*imag_data

##Tx Data and Zero pad
num_signals = 10000
xs = np.zeros(num_signals, np.complex64)
real_part = np.random.uniform(-1, 1, 4480)
imaginary_part = np.random.uniform(-1, 1, 4480)
data_signal = real_part + 1j * imaginary_part

## xs formation
xs[:len(dvbt2_20MHz_norm)] = dvbt2_20MHz_norm
xs[len(dvbt2_20MHz_norm):len(dvbt2_20MHz_norm)+len(data_signal)] = data_signal

## xs DVBT2 Detection
dvbt2_9M143Hz_buffer = sg.resample(xs, int(len(xs)*16/35))
corr1 = dvbt2_detect.dvbt2_detect(dvbt2_9M143Hz_buffer)
print(corr1)
corr2 = dvbt2_detectV2.dvbt2_detectV2(xs)
print(corr2)


spp = 2000

debug = False
tx_flag=True

Ns=len(xs)
n1 = np.arange(Ns)
n2 = np.arange(2000)
ts1 = n1/Fs
ts2 = n2/Fs


def tx_func():
    global xs, tx_flag
    tx_cnt=0
    while tx_cnt<400:
        idx=tx_cnt%5
        num_tx_samps = tx_streamer.send(xs[idx*2000:(idx+1)*2000],tx_metadata)
        tx_cnt += 1
    tx_flag=False
    print('TxSent')

rf_freq = 2.62e9  # 2.62GHz carrier frequency
tx_channel = 0
txGain = 25  # dB
rx_channel = 0
rxGain = 10  # dB


# dev = uhd.libpyuhd.types.device_addr(addr=192.168.40.1)
myusrp = uhd.usrp.MultiUSRP()
num_samps = Ns

myusrp.set_tx_antenna("TX/RX")
myusrp.set_tx_rate(Fs)
myusrp.set_tx_bandwidth(Fs/2)
myusrp.set_tx_freq(uhd.libpyuhd.types.tune_request(rf_freq), tx_channel)
myusrp.set_tx_gain(txGain)

myusrp.set_rx_antenna("RX2")
myusrp.set_rx_rate(Fs)
myusrp.set_rx_bandwidth(Fs/2)
myusrp.set_rx_freq(uhd.libpyuhd.types.tune_request(rf_freq), rx_channel)
myusrp.set_rx_gain(rxGain)

# Tx Streamer
txstream_args = uhd.usrp.StreamArgs('fc32', 'sc16')
# txstream_args.args = f'spp={Ns}'  # samples per packet
txstream_args.args = f'spp={spp}'  # samples per packet
tx_streamer = myusrp.get_tx_stream(txstream_args)

# Set up the stream and receive bufferx
rxstream_args = uhd.usrp.StreamArgs('fc32', 'sc16')
# rxstream_args.args = f'spp={Ns}'  # samples per packet
rxstream_args.args = f'spp={spp}'  # samples per packet
rxstream_args.channels = [rx_channel]
rx_streamer = myusrp.get_rx_stream(rxstream_args)
recv_buffer = np.zeros((1, 2000), dtype=np.complex64)

# Start Stream
tx_metadata = uhd.types.TXMetadata()
rx_metadata = uhd.types.RXMetadata()
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)
stream_cmd.stream_now = True
rx_streamer.issue_stream_cmd(stream_cmd)
print("Finished Configuration")

rx_flag = True
usrp_configured = True


txT = threading.Thread(target=tx_func)
txT.start()
time.sleep(0.0001)
rx_cnt = 0
err_log=[]
while rx_cnt<100:
    nrsamp = rx_streamer.recv(recv_buffer, rx_metadata)
    err_log.append([rx_cnt,nrsamp,recv_buffer])
    rx_cnt += 1

stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont)
rx_streamer.issue_stream_cmd(stream_cmd)
while tx_flag:
    pass


print(Ns)
plt.figure()
plt.subplot(411)
plt.plot(xs.real)
plt.subplot(412)
plt.plot(xs.imag)
plt.subplot(413)
plt.plot(err_log[99][2][0].real)
plt.subplot(414)
plt.plot(err_log[99][2][0].imag)

# plt.plot(err_log[99][2][0].imag)
plt.show()

plt.figure()
plt.subplot(411)
plt.plot(err_log[12][2][0].real)
plt.subplot(412)
plt.plot(err_log[53][2][0].real)
plt.subplot(413)
plt.plot(err_log[67][2][0].real)
plt.subplot(414)
plt.plot(err_log[87][2][0].real)
plt.show()
# rx_flag = False

print('done')

txT.join()

if not debug:
    del tx_streamer, rx_streamer
    del myusrp
print('finished')

I expected to see that the data that every receive is different

Data that I received First two are IQ of Tx and the rest two are plot of rx checking whether the data I received are different

0

There are 0 answers