【问题标题】:X310 USRP with pythonX310 USRP with python
【发布时间】:2022-12-27 22:08:19
【问题描述】:

I'm new to USRP so I don't quite understand the transmission and reception. I have a IQ data needs to be transmitted, I'm using the tx_waveform.py to perform the transmission or any other I should use? What would be the output of this? What are the configuration need to be done to transmit the data and receive the IQ data on receiver (OTA or Over the wire)?? What should be the procedure of this? I have attached the example code I found, this would come in receiver part, but how to use the tx_waveform.py? I just need to have a simple end to end transmission setup.

Thank you

I am using the same X310 USRP for the close loop transmission by simply connect a RF cable between them. Besides, I have one octoclock is connected to this USRP.

num_symbols = 10000
r = 0.1*np.random.randn(num_symbols) + 0.1j*np.random.randn(num_symbols)
print(r.size)
r = r.astype(np.complex64) # Convert to 64
r.tofile('test.dat')

import uhd
import numpy as np

usrp = uhd.usrp.MultiUSRP()
num_samps = 10000
center_freq = 1e9
sample_rate = 50e6
gain = 20

usrp.set_rx_rate(sample_rate, 0)
usrp.set_rx_freq(uhd.libpyuhd.types.tune_request(center_freq), 0)
usrp.set_rx_gain(gain, 0)

# Set up the stream and receive buffer
st_args = uhd.usrp.StreamArgs("fc32", "sc16")
st_args.channels = [0]
metadata = uhd.types.RXMetadata()
streamer = usrp.get_rx_stream(st_args)
recv_buffer = np.zeros((1, 1000), dtype=np.complex64) #maximum allowed value is 1996 through streamer.get_max_num_samps()

# Start Stream
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)
stream_cmd.stream_now = True
streamer.issue_stream_cmd(stream_cmd)

# Receive Samples
samples = np.fromfile('test.dat', np.complex64)
for i in range(num_samps//1000):
    streamer.recv(recv_buffer, metadata)
    samples[i*1000:(i+1)*1000] = recv_buffer[0]
    
# Stop Stream
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont)
streamer.issue_stream_cmd(stream_cmd)

print(samples)

【问题讨论】:

    标签: python receiver usrp uhd transmitfile


    【解决方案1】:

    Your code looks like it was taken from this source with a few minor modifications: PySDR: A Guide to SDR and DSP using Python

    If you look a bit further down on that page, there is an example describing how to transmit data, using the usrp.send_waveform()

    Furthermore, the modification you made to that example is a bit strange:

    # Receive Samples
    samples = np.fromfile('test.dat', np.complex64)  #<-- here you populate samples with data from your file
    for i in range(num_samps//1000):
        streamer.recv(recv_buffer, metadata)
        samples[i*1000:(i+1)*1000] = recv_buffer[0] #<-- now you overwrite with received data
    

    【讨论】:

      猜你喜欢
      • 2020-09-29
      • 2016-10-07
      • 2021-04-19
      • 2018-08-24
      • 2017-11-19
      • 2023-04-11
      • 2021-07-29
      • 1970-01-01
      • 2021-12-22
      相关资源
      最近更新 更多