-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmpsk_stage1.py
executable file
·159 lines (132 loc) · 4.98 KB
/
mpsk_stage1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Mpsk Stage1
# Generated: Sun Nov 18 21:01:09 2018
##################################################
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print "Warning: failed to XInitThreads()"
from gnuradio import blocks
from gnuradio import digital
from gnuradio import eng_notation
from gnuradio import filter
from gnuradio import gr
from gnuradio import wxgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from gnuradio.wxgui import constsink_gl
from gnuradio.wxgui import scopesink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import numpy
import wx
class mpsk_stage1(grc_wxgui.top_block_gui):
def __init__(self):
grc_wxgui.top_block_gui.__init__(self, title="Mpsk Stage1")
##################################################
# Variables
##################################################
self.sps = sps = 32
self.excess_bw = excess_bw = 0.35
self.samp_rate = samp_rate = 32000
self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1, sps, 1, excess_bw, 45)
self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
self.arity = arity = 4
##################################################
# Blocks
##################################################
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=0,
ac_couple=False,
xy_mode=False,
num_inputs=1,
trig_mode=wxgui.TRIG_MODE_AUTO,
y_axis_label='Counts',
)
self.Add(self.wxgui_scopesink2_0.win)
self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
self.GetWin(),
title='Constellation Plot',
sample_rate=samp_rate,
frame_rate=5,
const_size=2048,
M=4,
theta=0,
loop_bw=6.28/100.0,
fmax=0.06,
mu=0.5,
gain_mu=0.005,
symbol_rate=samp_rate/4.,
omega_limit=0.005,
)
self.Add(self.wxgui_constellationsink2_0.win)
self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (rrc_taps))
self.fir_filter_xxx_0.declare_sample_delay(0)
self.digital_constellation_modulator_0 = digital.generic_mod(
constellation=qpsk,
differential=True,
samples_per_symbol=sps,
pre_diff_code=True,
excess_bw=excess_bw,
verbose=False,
log=False,
)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True)
##################################################
# Connections
##################################################
self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0))
self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_constellationsink2_0, 0))
self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
def get_sps(self):
return self.sps
def set_sps(self, sps):
self.sps = sps
self.set_rrc_taps(firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 45))
def get_excess_bw(self):
return self.excess_bw
def set_excess_bw(self, excess_bw):
self.excess_bw = excess_bw
self.set_rrc_taps(firdes.root_raised_cosine(1, self.sps, 1, self.excess_bw, 45))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
self.wxgui_constellationsink2_0.set_sample_rate(self.samp_rate)
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
def get_rrc_taps(self):
return self.rrc_taps
def set_rrc_taps(self, rrc_taps):
self.rrc_taps = rrc_taps
self.fir_filter_xxx_0.set_taps((self.rrc_taps))
def get_qpsk(self):
return self.qpsk
def set_qpsk(self, qpsk):
self.qpsk = qpsk
def get_arity(self):
return self.arity
def set_arity(self, arity):
self.arity = arity
def main(top_block_cls=mpsk_stage1, options=None):
tb = top_block_cls()
tb.Start(True)
tb.Wait()
if __name__ == '__main__':
main()