Skip to content
Snippets Groups Projects
Commit a156ad3a authored by Gonzalo Belcredi's avatar Gonzalo Belcredi
Browse files

First commit

parent 92e428f4
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 26909 deletions
File deleted
File deleted
File deleted
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Top Block
# Generated: Tue Oct 29 19:30:54 2019
##################################################
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 PyQt4 import Qt
from gnuradio import blocks
from gnuradio import digital
from gnuradio import eng_notation
from gnuradio import filter
from gnuradio import gr
from gnuradio import qtgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from gnuradio.filter import pfb
from gnuradio.qtgui import Range, RangeWidget
from optparse import OptionParser
import math
import osmosdr
import sip
import sys
import time
class top_block(gr.top_block, Qt.QWidget):
def __init__(self):
gr.top_block.__init__(self, "Top Block")
Qt.QWidget.__init__(self)
self.setWindowTitle("Top Block")
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except:
pass
self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)
self.settings = Qt.QSettings("GNU Radio", "top_block")
self.restoreGeometry(self.settings.value("geometry").toByteArray())
##################################################
# Variables
##################################################
self.sym_rate = sym_rate = 48e03*4
self.samp_per_sym = samp_per_sym = 3
self.len_sym_srrc = len_sym_srrc = 11
self.alfa = alfa = 0.350
self.samp_rate_hackrf = samp_rate_hackrf = 2e6
self.samp_rate = samp_rate = sym_rate*samp_per_sym
self.pulso = pulso = firdes.root_raised_cosine(1, sym_rate*samp_per_sym, sym_rate, alfa, samp_per_sym*len_sym_srrc)
self.gain = gain = 0
self.freq = freq = 450e6
self.bits_per_sym = bits_per_sym = 2
self.amp = amp = .4
##################################################
# Blocks
##################################################
self._amp_range = Range(.1, 2, .1, .4, 200)
self._amp_win = RangeWidget(self._amp_range, self.set_amp, "amp", "counter_slider", float)
self.top_layout.addWidget(self._amp_win)
self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
interpolation=2000000,
decimation=int(samp_rate),
taps=None,
fractional_bw=None,
)
self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
1024, #size
samp_rate, #samp_rate
"", #name
1 #number of inputs
)
self.qtgui_time_sink_x_0.set_update_time(0.10)
self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")
self.qtgui_time_sink_x_0.enable_tags(-1, True)
self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
self.qtgui_time_sink_x_0.enable_autoscale(False)
self.qtgui_time_sink_x_0.enable_grid(False)
self.qtgui_time_sink_x_0.enable_axis_labels(True)
self.qtgui_time_sink_x_0.enable_control_panel(False)
if not True:
self.qtgui_time_sink_x_0.disable_legend()
labels = ['', '', '', '', '',
'', '', '', '', '']
widths = [1, 1, 1, 1, 1,
1, 1, 1, 1, 1]
colors = ["blue", "red", "green", "black", "cyan",
"magenta", "yellow", "dark red", "dark green", "blue"]
styles = [1, 1, 1, 1, 1,
1, 1, 1, 1, 1]
markers = [-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1]
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0]
for i in xrange(2*1):
if len(labels[i]) == 0:
if(i % 2 == 0):
self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
else:
self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
else:
self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
1024, #size
firdes.WIN_BLACKMAN_hARRIS, #wintype
0, #fc
samp_rate, #bw
"", #name
1 #number of inputs
)
self.qtgui_freq_sink_x_0.set_update_time(0.10)
self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
self.qtgui_freq_sink_x_0.enable_autoscale(False)
self.qtgui_freq_sink_x_0.enable_grid(False)
self.qtgui_freq_sink_x_0.set_fft_average(1.0)
self.qtgui_freq_sink_x_0.enable_axis_labels(True)
self.qtgui_freq_sink_x_0.enable_control_panel(False)
if not True:
self.qtgui_freq_sink_x_0.disable_legend()
if "complex" == "float" or "complex" == "msg_float":
self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
labels = ['', '', '', '', '',
'', '', '', '', '']
widths = [1, 1, 1, 1, 1,
1, 1, 1, 1, 1]
colors = ["blue", "red", "green", "black", "cyan",
"magenta", "yellow", "dark red", "dark green", "dark blue"]
alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0]
for i in xrange(1):
if len(labels[i]) == 0:
self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
else:
self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(
samp_per_sym,
(pulso),
100)
self.pfb_interpolator_ccf_0.declare_sample_delay(0)
self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf=1' )
self.osmosdr_sink_0.set_sample_rate(samp_rate_hackrf)
self.osmosdr_sink_0.set_center_freq(freq, 0)
self.osmosdr_sink_0.set_freq_corr(0, 0)
self.osmosdr_sink_0.set_gain(0, 0)
self.osmosdr_sink_0.set_if_gain(0, 0)
self.osmosdr_sink_0.set_bb_gain(0, 0)
self.osmosdr_sink_0.set_antenna('', 0)
self.osmosdr_sink_0.set_bandwidth(0, 0)
self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym)
self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([-1-1j, 1-1j, 1+1j, -1+1j]), 1)
self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST)
self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((amp, ))
self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/gonzalo/workspace/lab-integrador/dat/imagen_bin.dat', True)
##################################################
# Connections
##################################################
self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_freq_sink_x_0, 0))
self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_0, 0))
self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_0, 0))
self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0))
self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_interpolator_ccf_0, 0))
self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0))
self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "top_block")
self.settings.setValue("geometry", self.saveGeometry())
event.accept()
def get_sym_rate(self):
return self.sym_rate
def set_sym_rate(self, sym_rate):
self.sym_rate = sym_rate
self.set_samp_rate(self.sym_rate*self.samp_per_sym)
self.set_pulso(firdes.root_raised_cosine(1, self.sym_rate*self.samp_per_sym, self.sym_rate, self.alfa, self.samp_per_sym*self.len_sym_srrc))
def get_samp_per_sym(self):
return self.samp_per_sym
def set_samp_per_sym(self, samp_per_sym):
self.samp_per_sym = samp_per_sym
self.set_samp_rate(self.sym_rate*self.samp_per_sym)
self.set_pulso(firdes.root_raised_cosine(1, self.sym_rate*self.samp_per_sym, self.sym_rate, self.alfa, self.samp_per_sym*self.len_sym_srrc))
def get_len_sym_srrc(self):
return self.len_sym_srrc
def set_len_sym_srrc(self, len_sym_srrc):
self.len_sym_srrc = len_sym_srrc
self.set_pulso(firdes.root_raised_cosine(1, self.sym_rate*self.samp_per_sym, self.sym_rate, self.alfa, self.samp_per_sym*self.len_sym_srrc))
def get_alfa(self):
return self.alfa
def set_alfa(self, alfa):
self.alfa = alfa
self.set_pulso(firdes.root_raised_cosine(1, self.sym_rate*self.samp_per_sym, self.sym_rate, self.alfa, self.samp_per_sym*self.len_sym_srrc))
def get_samp_rate_hackrf(self):
return self.samp_rate_hackrf
def set_samp_rate_hackrf(self, samp_rate_hackrf):
self.samp_rate_hackrf = samp_rate_hackrf
self.osmosdr_sink_0.set_sample_rate(self.samp_rate_hackrf)
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate)
self.qtgui_freq_sink_x_0.set_frequency_range(0, self.samp_rate)
def get_pulso(self):
return self.pulso
def set_pulso(self, pulso):
self.pulso = pulso
self.pfb_interpolator_ccf_0.set_taps((self.pulso))
def get_gain(self):
return self.gain
def set_gain(self, gain):
self.gain = gain
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.osmosdr_sink_0.set_center_freq(self.freq, 0)
def get_bits_per_sym(self):
return self.bits_per_sym
def set_bits_per_sym(self, bits_per_sym):
self.bits_per_sym = bits_per_sym
def get_amp(self):
return self.amp
def set_amp(self, amp):
self.amp = amp
self.blocks_multiply_const_vxx_1.set_k((self.amp, ))
def main(top_block_cls=top_block, options=None):
from distutils.version import StrictVersion
if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
qapp.exec_()
if __name__ == '__main__':
main()
File deleted
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File moved
images/imagen_frame_recibida.png

276 KiB

images/imagen_recibida.png

1.24 MiB

images/imagen_recibida_1.png

305 KiB

images/imagen_recibida_2.png

298 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment