#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: MSRSAS DPSK Modulation
# Author: MSRSAS,RTES,PT08,Nyjil George
# Description: Transmit a DPSK signal
# Generated: Sat Mar 17 02:42:29 2012
##################################################
from gnuradio import digital
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from gnuradio.wxgui import forms
from gnuradio.wxgui import scopesink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import numpy
import wx
class dpskmod(grc_wxgui.top_block_gui):
def __init__(self, rx_gain=0, freq_offset=0, address0="addr=192.168.10.2", tx_gain=0, freq=145e6, samp_rate=1e6):
grc_wxgui.top_block_gui.__init__(self, title="MSRSAS DPSK Modulation")
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
##################################################
# Parameters
##################################################
self.rx_gain = rx_gain
self.freq_offset = freq_offset
self.address0 = address0
self.tx_gain = tx_gain
self.freq = freq
self.samp_rate = samp_rate
##################################################
# Variables
##################################################
self.tun_tx_gain = tun_tx_gain = tx_gain
self.tun_rx_gain = tun_rx_gain = rx_gain
self.tun_freq = tun_freq = freq
self.samps_per_sym = samps_per_sym = 8
self.rx_freq_off = rx_freq_off = freq_offset
self.ampl = ampl = .1
##################################################
# Blocks
##################################################
_tun_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
self._tun_rx_gain_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_tun_rx_gain_sizer,
value=self.tun_rx_gain,
callback=self.set_tun_rx_gain,
label="UHD RX Gain",
converter=forms.float_converter(),
proportion=0,
)
self._tun_rx_gain_slider = forms.slider(
parent=self.GetWin(),
sizer=_tun_rx_gain_sizer,
value=self.tun_rx_gain,
callback=self.set_tun_rx_gain,
minimum=0,
maximum=20,
num_steps=100,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.Add(_tun_rx_gain_sizer)
_tun_freq_sizer = wx.BoxSizer(wx.VERTICAL)
self._tun_freq_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_tun_freq_sizer,
value=self.tun_freq,
callback=self.set_tun_freq,
label="Freq (Hz)",
converter=forms.float_converter(),
proportion=0,
)
self._tun_freq_slider = forms.slider(
parent=self.GetWin(),
sizer=_tun_freq_sizer,
value=self.tun_freq,
callback=self.set_tun_freq,
minimum=144e6,
maximum=146e6,
num_steps=100,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.Add(_tun_freq_sizer)
_rx_freq_off_sizer = wx.BoxSizer(wx.VERTICAL)
self._rx_freq_off_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_rx_freq_off_sizer,
value=self.rx_freq_off,
callback=self.set_rx_freq_off,
label="RX Freq Offset (Hz)",
converter=forms.float_converter(),
proportion=0,
)
self._rx_freq_off_slider = forms.slider(
parent=self.GetWin(),
sizer=_rx_freq_off_sizer,
value=self.rx_freq_off,
callback=self.set_rx_freq_off,
minimum=-50e3,
maximum=+50e3,
num_steps=100,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.Add(_rx_freq_off_sizer)
_ampl_sizer = wx.BoxSizer(wx.VERTICAL)
self._ampl_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_ampl_sizer,
value=self.ampl,
callback=self.set_ampl,
label="Amplitude",
converter=forms.float_converter(),
proportion=0,
)
self._ampl_slider = forms.slider(
parent=self.GetWin(),
sizer=_ampl_sizer,
value=self.ampl,
callback=self.set_ampl,
minimum=0,
maximum=1,
num_steps=100,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.Add(_ampl_sizer)
self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
self.GetWin(),
title="Scope Plot",
sample_rate=samp_rate,
v_scale=0,
v_offset=0,
t_scale=1e-6,
ac_couple=False,
xy_mode=True,
num_inputs=1,
trig_mode=gr.gr_TRIG_MODE_AUTO,
y_axis_label="Counts",
)
self.Add(self.wxgui_scopesink2_0.win)
self.uhd_usrp_source_0 = uhd.usrp_source(
device_addr="",
stream_args=uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_source_0.set_samp_rate(samp_rate)
self.uhd_usrp_source_0.set_center_freq(tun_freq+rx_freq_off, 0)
self.uhd_usrp_source_0.set_gain(tun_rx_gain, 0)
self.uhd_usrp_sink_0 = uhd.usrp_sink(
device_addr="",
stream_args=uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
self.uhd_usrp_sink_0.set_center_freq(tun_freq, 0)
self.uhd_usrp_sink_0.set_gain(tun_rx_gain, 0)
self.uhd_usrp_sink_0.set_antenna("A:A", 0)
_tun_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
self._tun_tx_gain_text_box = forms.text_box(
parent=self.GetWin(),
sizer=_tun_tx_gain_sizer,
value=self.tun_tx_gain,
callback=self.set_tun_tx_gain,
label="UHD TX Gain",
converter=forms.float_converter(),
proportion=0,
)
self._tun_tx_gain_slider = forms.slider(
parent=self.GetWin(),
sizer=_tun_tx_gain_sizer,
value=self.tun_tx_gain,
callback=self.set_tun_tx_gain,
minimum=0,
maximum=20,
num_steps=100,
style=wx.SL_HORIZONTAL,
cast=float,
proportion=1,
)
self.Add(_tun_tx_gain_sizer)
self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)
self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((ampl, ))
self.digital_dxpsk_mod_0 = digital.dqpsk_mod(
samples_per_symbol=samps_per_sym,
excess_bw=0.35,
gray_coded=True,
verbose=False,
log=False)
##################################################
# Connections
##################################################
self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_0, 0))
self.connect((self.gr_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
self.connect((self.random_source_x_0, 0), (self.digital_dxpsk_mod_0, 0))
self.connect((self.digital_dxpsk_mod_0, 0), (self.gr_multiply_const_vxx_0, 0))
def get_rx_gain(self):
return self.rx_gain
def set_rx_gain(self, rx_gain):
self.rx_gain = rx_gain
self.set_tun_rx_gain(self.rx_gain)
def get_freq_offset(self):
return self.freq_offset
def set_freq_offset(self, freq_offset):
self.freq_offset = freq_offset
self.set_rx_freq_off(self.freq_offset)
def get_address0(self):
return self.address0
def set_address0(self, address0):
self.address0 = address0
def get_tx_gain(self):
return self.tx_gain
def set_tx_gain(self, tx_gain):
self.tx_gain = tx_gain
self.set_tun_tx_gain(self.tx_gain)
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.set_tun_freq(self.freq)
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate)
self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
def get_tun_tx_gain(self):
return self.tun_tx_gain
def set_tun_tx_gain(self, tun_tx_gain):
self.tun_tx_gain = tun_tx_gain
self._tun_tx_gain_slider.set_value(self.tun_tx_gain)
self._tun_tx_gain_text_box.set_value(self.tun_tx_gain)
def get_tun_rx_gain(self):
return self.tun_rx_gain
def set_tun_rx_gain(self, tun_rx_gain):
self.tun_rx_gain = tun_rx_gain
self._tun_rx_gain_slider.set_value(self.tun_rx_gain)
self._tun_rx_gain_text_box.set_value(self.tun_rx_gain)
self.uhd_usrp_sink_0.set_gain(self.tun_rx_gain, 0)
self.uhd_usrp_source_0.set_gain(self.tun_rx_gain, 0)
def get_tun_freq(self):
return self.tun_freq
def set
我虽横行却不霸道
- 粉丝: 97
- 资源: 1万+
最新资源
- 精益算法交易引擎由QuantConnect Python C.zip
- 可扩展的可移植和分布式梯度增强GBDT GBRT或GBM库,适用于Python R Java Scala C和更多在单.zip
- 具有静态类型的Python库存根的集合.zip
- 可移植Python数据框架库.zip
- 快速异步和优雅的Python web框架.zip
- 跨平台 Python 异步聊天机器人框架 Asynchronous multiplatform chatbot fr.zip
- 跨平台库,用于Python中的进程和系统监控.zip
- 来自一位 Pythonista 的编程经验分享内容涵盖编码技巧最佳实践与思维模式等方面.zip
- 快速正确的Python JSON库支持datetimes和numpy数据类.zip
- (C语言版)扩展卡尔曼滤波器EKF的锂电池SoC计算仿真模型 容积卡尔曼滤波CKF进行锂电池SOC估计的C语言版本实现,包含定参和FFRLS两种情况,已在VS2019和Ubuntu 20.04.4版本
- 来自Python的浏览器交互式数据可视化.zip
- 离线语音识别API Android iOS树莓派和服务器与Python Java C和Node.zip
- 利用Python进行数据分析 第二版 2017 中文翻译笔记.zip
- 领先的本地Python SSHv2协议库.zip
- 灵活而强大的Python数据分析操作库,提供类似于R数据框架对象的标记数据结构,统计函数等等.zip
- 流行的机器学习算法的Python示例与交互式Jupyter演示和数学解释.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论3