Giter Club home page Giter Club logo

pysdr's Introduction

pysdr's People

Contributors

777arc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysdr's Issues

Not able to transmit and receive a sine wave using Python API (USRP B200)

I am trying to transmit and receive sine signal using USRP B200. I have referred the codes provided in the chapter 6 of pySDR. However I am not able to capture sine wave. The receive samples do not show any connection with the transmitted signal. I am copying the codes here.

########################

Code to transmit signal

########################

import uhd
import numpy as np
import time as tim

usrp = uhd.usrp.MultiUSRP()

duration = 30 # seconds
center_freq = 900e6
sample_rate = 1e6
gain = 20 # [dB] start low then work your way up

create sine wave

time = np.arange(0, duration, 1/sample_rate);# create sampling instances
samples = np.sin(time)

usrp.send_waveform(samples, duration, center_freq, sample_rate, [0], gain)

########################

Code to receive signal

########################
import uhd
import numpy as np
import matplotlib.pyplot as plt

usrp = uhd.usrp.MultiUSRP()
center_freq = 900e6 # Hz
sample_rate = 1e6 # Hz
gain = 10 # dB

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)
usrp.set_rx_agc(True, 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)

Start Stream

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

duration = 20 # seconds
t_n = np.arange(0, duration, 1/sample_rate);# time axis
num_samps=len(t_n)

Receive Samples

samples = np.zeros(num_samps, dtype=np.complex64)
for i in range(num_samps//1000):
streamer.recv(recv_buffer, metadata)
data=recv_buffer[0]
samples[i*1000:(i+1)*1000] = data

Stop Stream

stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont)
streamer.issue_stream_cmd(stream_cmd)

print(len(samples))
print(samples[0:10])
plt.plot(t_n, np.real(samples),'')
plt.show()

is this project effectively dead?

pyqt5 will only support a max python version of 3.6 which was EOL 23DEC2021 and is going to be removed. I don't see how this will continue to work without a lot of manual work.

image0

Pulse Shaping - Python Exercise - Make +1 and -1 lines more visually distinct

The current plot pulse-shaped plot generated in the python exercise uses 'grid' to provide reference lines:

But it would be visually helpful to emphasize the y=+1 and y=-1 lines to make it easier to note that the plotted curve has value +1 or -1 at integer values of t, and if the vertical lines went from 0 to +1 or -1, for example:

from email.base64mime import header_length
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal

num_symbols = 10
sps = 8

bits = np.random.randint(0, 2, num_symbols) # Our data to be transmitted, 1's and 0's

x = np.array([])
for bit in bits:
    pulse = np.zeros(sps)
    pulse[0] = bit*2-1 # set the first value to either a 1 or -1
    x = np.concatenate((x, pulse)) # add the 8 samples to the signal

# Create our raised-cosine filter
num_taps = 101
beta = 0.35
Ts = sps # Assume sample rate is 1 Hz, so sample period is 1, so *symbol* period is 8
t = np.arange(-51, 52) # remember it's not inclusive of final number
h = np.sinc(t/Ts) * np.cos(np.pi*beta*t/Ts) / (1 - (2*beta*t/Ts)**2)

# Filter our signal, in order to apply the pulse shaping
x_shaped = np.convolve(x, h)
fig, ax = plt.subplots()
plt.plot(x_shaped, '.-')
for i in range(num_symbols):
    xpos = i*sps+num_taps//2+1
    ypos = x_shaped[xpos]
    plt.arrow(
        x=xpos, y=0, dx=0, dy=ypos, 
        color="red", 
        ls=(0, (5, 5))
        )
plt.grid(True)
ax.set_yticks([-1, 0, +1], minor=False)
plt.savefig("pulse_shaping_python3_grw.png", format="png", dpi=150   )

yields
pulse_shaping_python3_grw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.