Whitney Knitter
Published © GPL3+

Getting Started with the SDR Zmod on Eclypse Z7 + GNU Radio

Walking through the setup of the SDR Zmod on Eclypse Z7 for SDR development using GNU Radio.

IntermediateFull instructions provided2 hours2,219
Getting Started with the SDR Zmod on Eclypse Z7 + GNU Radio

Things used in this project

Hardware components

Digilent Eclypse Z7: Zynq-7000 SoC Development Board with SYZYGY-compatible Expansion
×1
Digilent Zmod Digitizer 1430-125: 2-channel 14-bit Digitizer Module
×1
Digilent Zmod SDR: SYZYGY-compatible Analog-to-Digital Converter Module for Software-Defined Radio
×1

Software apps and online services

GNU Radio
Vivado Design Suite
AMD Vivado Design Suite
Pavel Demin's Alpine Image with Pre-Built Applications
RF / Coaxial Cable Assembly, SMA Straight Plug, RG316, 50 ohm, 3.3 ft

Story

Read more

Code

audio_trx.grc

Plain text
options:
  parameters:
    author: whitney
    catch_exceptions: 'True'
    category: '[GRC Hier Blocks]'
    cmake_opt: ''
    comment: ''
    copyright: ''
    description: ''
    gen_cmake: 'On'
    gen_linking: dynamic
    generate_options: qt_gui
    hier_block_src_path: '.:'
    id: audio_trx
    max_nouts: '0'
    output_language: python
    placement: (0,0)
    qt_qss_theme: ''
    realtime_scheduling: ''
    run: 'True'
    run_command: '{python} -u {filename}'
    run_options: prompt
    sizing_mode: fixed
    thread_safe_setters: ''
    title: SDR Zmod FM Transceiver
    window_size: (1000,1000)
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [8, 12.0]
    rotation: 0
    state: enabled

blocks:
- name: audio_rate
  id: variable
  parameters:
    comment: ''
    value: '48000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [624, 76.0]
    rotation: 0
    state: true
- name: audio_sym_rate
  id: variable
  parameters:
    comment: ''
    value: int(audio_rate*2)
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [360, 76.0]
    rotation: 0
    state: true
- name: awg_freq_corr_ppm
  id: variable
  parameters:
    comment: ''
    value: '0'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [488, 76.0]
    rotation: 0
    state: true
- name: cntr_freq
  id: variable
  parameters:
    comment: ''
    value: '100000000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [272, 76.0]
    rotation: 0
    state: true
- name: ip_address
  id: variable
  parameters:
    comment: ''
    value: '"192.168.1.171"'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [176, 12.0]
    rotation: 180
    state: enabled
- name: num_taps
  id: variable
  parameters:
    comment: ''
    value: '1000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [400, 12.0]
    rotation: 0
    state: true
- name: port
  id: variable
  parameters:
    comment: ''
    value: '1001'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [304, 12.0]
    rotation: 0
    state: true
- name: quad_rate
  id: variable
  parameters:
    comment: ''
    value: int(audio_sym_rate*2)
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [624, 12.0]
    rotation: 0
    state: true
- name: samp_rate
  id: variable
  parameters:
    comment: ''
    value: '384000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [176, 76.0]
    rotation: 0
    state: enabled
- name: sdr_freq_corr_ppm
  id: variable
  parameters:
    comment: ''
    value: '0'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [488, 12.0]
    rotation: 0
    state: true
- name: analog_wfm_rcv_0
  id: analog_wfm_rcv
  parameters:
    affinity: ''
    alias: ''
    audio_decimation: '1'
    comment: ''
    maxoutbuf: '0'
    minoutbuf: '0'
    quad_rate: quad_rate
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [696, 196.0]
    rotation: 0
    state: true
- name: analog_wfm_tx_0
  id: analog_wfm_tx
  parameters:
    affinity: ''
    alias: ''
    audio_rate: audio_sym_rate
    comment: ''
    fh: '-1.0'
    max_dev: 75e3
    maxoutbuf: '0'
    minoutbuf: '0'
    quad_rate: quad_rate
    tau: 75e-6
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [400, 476.0]
    rotation: 0
    state: true
- name: audio_sink_0
  id: audio_sink
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    device_name: ''
    num_inputs: '1'
    ok_to_block: 'True'
    samp_rate: '48000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1112, 204.0]
    rotation: 0
    state: true
- name: audio_source_0
  id: audio_source
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    device_name: ''
    maxoutbuf: '0'
    minoutbuf: '0'
    num_outputs: '1'
    ok_to_block: 'True'
    samp_rate: '48000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [16, 508.0]
    rotation: 0
    state: true
- name: eclypse_z7_sink_0
  id: eclypse_z7_sink
  parameters:
    addr: ip_address
    affinity: ''
    alias: ''
    comment: ''
    corr: awg_freq_corr_ppm
    freq: cntr_freq
    port: port
    ptt: '1'
    rate: samp_rate
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1152, 468.0]
    rotation: 0
    state: true
- name: eclypse_z7_source_0
  id: eclypse_z7_source
  parameters:
    addr: ip_address
    affinity: ''
    alias: ''
    comment: ''
    corr: sdr_freq_corr_ppm
    freq: cntr_freq
    maxoutbuf: '0'
    minoutbuf: '0'
    port: port
    rate: samp_rate
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [16, 172.0]
    rotation: 0
    state: true
- name: qtgui_freq_sink_x_0
  id: qtgui_freq_sink_x
  parameters:
    affinity: ''
    alias: ''
    alpha1: '1.0'
    alpha10: '1.0'
    alpha2: '1.0'
    alpha3: '1.0'
    alpha4: '1.0'
    alpha5: '1.0'
    alpha6: '1.0'
    alpha7: '1.0'
    alpha8: '1.0'
    alpha9: '1.0'
    autoscale: 'False'
    average: '1.0'
    axislabels: 'True'
    bw: samp_rate
    color1: '"blue"'
    color10: '"dark blue"'
    color2: '"red"'
    color3: '"green"'
    color4: '"black"'
    color5: '"cyan"'
    color6: '"magenta"'
    color7: '"yellow"'
    color8: '"dark red"'
    color9: '"dark green"'
    comment: ''
    ctrlpanel: 'False'
    fc: cntr_freq
    fftsize: '1024'
    freqhalf: 'True'
    grid: 'False'
    gui_hint: ''
    label: Relative Gain
    label1: ''
    label10: ''''''
    label2: ''''''
    label3: ''''''
    label4: ''''''
    label5: ''''''
    label6: ''''''
    label7: ''''''
    label8: ''''''
    label9: ''''''
    legend: 'True'
    maxoutbuf: '0'
    minoutbuf: '0'
    name: '"RX"'
    nconnections: '1'
    norm_window: 'False'
    showports: 'False'
    tr_chan: '0'
    tr_level: '0.0'
    tr_mode: qtgui.TRIG_MODE_FREE
    tr_tag: '""'
    type: complex
    units: dB
    update_time: '0.10'
    width1: '1'
    width10: '1'
    width2: '1'
    width3: '1'
    width4: '1'
    width5: '1'
    width6: '1'
    width7: '1'
    width8: '1'
    width9: '1'
    wintype: window.WIN_BLACKMAN_hARRIS
    ymax: '10'
    ymin: '-140'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [256, 276.0]
    rotation: 0
    state: true
- name: qtgui_freq_sink_x_0_0
  id: qtgui_freq_sink_x
  parameters:
    affinity: ''
    alias: ''
    alpha1: '1.0'
    alpha10: '1.0'
    alpha2: '1.0'
    alpha3: '1.0'
    alpha4: '1.0'
    alpha5: '1.0'
    alpha6: '1.0'
    alpha7: '1.0'
    alpha8: '1.0'
    alpha9: '1.0'
    autoscale: 'False'
    average: '1.0'
    axislabels: 'True'
    bw: samp_rate
    color1: '"blue"'
    color10: '"dark blue"'
    color2: '"red"'
    color3: '"green"'
    color4: '"black"'
    color5: '"cyan"'
    color6: '"magenta"'
    color7: '"yellow"'
    color8: '"dark red"'
    color9: '"dark green"'
    comment: ''
    ctrlpanel: 'False'
    fc: cntr_freq
    fftsize: '1024'
    freqhalf: 'True'
    grid: 'False'
    gui_hint: ''
    label: Relative Gain
    label1: ''
    label10: ''''''
    label2: ''''''
    label3: ''''''
    label4: ''''''
    label5: ''''''
    label6: ''''''
    label7: ''''''
    label8: ''''''
    label9: ''''''
    legend: 'True'
    maxoutbuf: '0'
    minoutbuf: '0'
    name: '"TX"'
    nconnections: '1'
    norm_window: 'False'
    showports: 'False'
    tr_chan: '0'
    tr_level: '0.0'
    tr_mode: qtgui.TRIG_MODE_FREE
    tr_tag: '""'
    type: complex
    units: dB
    update_time: '0.10'
    width1: '1'
    width10: '1'
    width2: '1'
    width3: '1'
    width4: '1'
    width5: '1'
    width6: '1'
    width7: '1'
    width8: '1'
    width9: '1'
    wintype: window.WIN_BLACKMAN_hARRIS
    ymax: '10'
    ymin: '-140'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1152, 364.0]
    rotation: 0
    state: true
- name: qtgui_waterfall_sink_x_0
  id: qtgui_waterfall_sink_x
  parameters:
    affinity: ''
    alias: ''
    alpha1: '1.0'
    alpha10: '1.0'
    alpha2: '1.0'
    alpha3: '1.0'
    alpha4: '1.0'
    alpha5: '1.0'
    alpha6: '1.0'
    alpha7: '1.0'
    alpha8: '1.0'
    alpha9: '1.0'
    axislabels: 'True'
    bw: samp_rate
    color1: '0'
    color10: '0'
    color2: '0'
    color3: '0'
    color4: '0'
    color5: '0'
    color6: '0'
    color7: '0'
    color8: '0'
    color9: '0'
    comment: ''
    fc: cntr_freq
    fftsize: '1024'
    freqhalf: 'True'
    grid: 'False'
    gui_hint: ''
    int_max: '10'
    int_min: '-140'
    label1: ''
    label10: ''
    label2: ''
    label3: ''
    label4: ''
    label5: ''
    label6: ''
    label7: ''
    label8: ''
    label9: ''
    legend: 'True'
    maxoutbuf: '0'
    minoutbuf: '0'
    name: '""'
    nconnections: '1'
    showports: 'False'
    type: complex
    update_time: '0.10'
    wintype: window.WIN_BLACKMAN_hARRIS
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1152, 284.0]
    rotation: 0
    state: true
- name: rational_resampler_xxx_0
  id: rational_resampler_xxx
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    decim: int(samp_rate/quad_rate)
    fbw: '0'
    interp: '1'
    maxoutbuf: '0'
    minoutbuf: '0'
    taps: '[]'
    type: ccc
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [256, 180.0]
    rotation: 0
    state: true
- name: rational_resampler_xxx_0_0
  id: rational_resampler_xxx
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    decim: '1'
    fbw: '0'
    interp: int(samp_rate/quad_rate)
    maxoutbuf: '0'
    minoutbuf: '0'
    taps: '[]'
    type: ccc
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [664, 484.0]
    rotation: 0
    state: true
- name: rational_resampler_xxx_1
  id: rational_resampler_xxx
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    decim: int(quad_rate/audio_rate)
    fbw: '0'
    interp: '1'
    maxoutbuf: '0'
    minoutbuf: '0'
    taps: '[]'
    type: fff
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [912, 180.0]
    rotation: 0
    state: true
- name: rational_resampler_xxx_1_0
  id: rational_resampler_xxx
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    decim: '1'
    fbw: '0'
    interp: int(audio_sym_rate/audio_rate)
    maxoutbuf: '0'
    minoutbuf: '0'
    taps: '[]'
    type: fff
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [208, 484.0]
    rotation: 0
    state: true
- name: root_raised_cosine_filter_0
  id: root_raised_cosine_filter
  parameters:
    affinity: ''
    alias: ''
    alpha: '0.35'
    comment: ''
    decim: '1'
    gain: '1'
    interp: '1'
    maxoutbuf: '0'
    minoutbuf: '0'
    ntaps: num_taps
    samp_rate: samp_rate
    sym_rate: audio_sym_rate
    type: fir_filter_ccf
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [456, 164.0]
    rotation: 0
    state: enabled
- name: root_raised_cosine_filter_0_0
  id: root_raised_cosine_filter
  parameters:
    affinity: ''
    alias: ''
    alpha: '0.35'
    comment: ''
    decim: '1'
    gain: '1'
    interp: '1'
    maxoutbuf: '0'
    minoutbuf: '0'
    ntaps: num_taps
    samp_rate: samp_rate
    sym_rate: audio_sym_rate
    type: fir_filter_ccf
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [856, 468.0]
    rotation: 0
    state: true

connections:
- [analog_wfm_rcv_0, '0', rational_resampler_xxx_1, '0']
- [analog_wfm_tx_0, '0', rational_resampler_xxx_0_0, '0']
- [audio_source_0, '0', rational_resampler_xxx_1_0, '0']
- [eclypse_z7_source_0, '0', qtgui_freq_sink_x_0, '0']
- [eclypse_z7_source_0, '0', rational_resampler_xxx_0, '0']
- [rational_resampler_xxx_0, '0', root_raised_cosine_filter_0, '0']
- [rational_resampler_xxx_0_0, '0', root_raised_cosine_filter_0_0, '0']
- [rational_resampler_xxx_1, '0', audio_sink_0, '0']
- [rational_resampler_xxx_1_0, '0', analog_wfm_tx_0, '0']
- [root_raised_cosine_filter_0, '0', analog_wfm_rcv_0, '0']
- [root_raised_cosine_filter_0_0, '0', eclypse_z7_sink_0, '0']
- [root_raised_cosine_filter_0_0, '0', qtgui_freq_sink_x_0_0, '0']
- [root_raised_cosine_filter_0_0, '0', qtgui_waterfall_sink_x_0, '0']

metadata:
  file_format: 1

audio_trx.py

Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: SDR Zmod FM Transceiver
# Author: whitney
# GNU Radio version: 3.10.1.1

from packaging.version import Version as StrictVersion

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 PyQt5 import Qt
from gnuradio import qtgui
from gnuradio.filter import firdes
import sip
from gnuradio import analog
from gnuradio import audio
from gnuradio import filter
from gnuradio import gr
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
import eclypse_z7



from gnuradio import qtgui

class audio_trx(gr.top_block, Qt.QWidget):

    def __init__(self):
        gr.top_block.__init__(self, "SDR Zmod FM Transceiver", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("SDR Zmod FM Transceiver")
        qtgui.util.check_set_qss()
        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", "audio_trx")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = 48000
        self.audio_sym_rate = audio_sym_rate = int(audio_rate*2)
        self.sdr_freq_corr_ppm = sdr_freq_corr_ppm = 0
        self.samp_rate = samp_rate = 384000
        self.quad_rate = quad_rate = int(audio_sym_rate*2)
        self.port = port = 1001
        self.num_taps = num_taps = 1000
        self.ip_address = ip_address = "192.168.1.171"
        self.cntr_freq = cntr_freq = 100000000
        self.awg_freq_corr_ppm = awg_freq_corr_ppm = 0

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.root_raised_cosine(
                1,
                samp_rate,
                audio_sym_rate,
                0.35,
                num_taps))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.root_raised_cosine(
                1,
                samp_rate,
                audio_sym_rate,
                0.35,
                num_taps))
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=int(audio_sym_rate/audio_rate),
                decimation=1,
                taps=[],
                fractional_bw=0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=int(quad_rate/audio_rate),
                taps=[],
                fractional_bw=0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate/quad_rate),
                decimation=1,
                taps=[],
                fractional_bw=0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=int(samp_rate/quad_rate),
                taps=[],
                fractional_bw=0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024, #size
            window.WIN_BLACKMAN_hARRIS, #wintype
            cntr_freq, #fc
            samp_rate, #bw
            "", #name
            1, #number of inputs
            None # parent
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)



        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.qwidget(), Qt.QWidget)

        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024, #size
            window.WIN_BLACKMAN_hARRIS, #wintype
            cntr_freq, #fc
            samp_rate, #bw
            "TX", #name
            1,
            None # parent
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)
        self.qtgui_freq_sink_x_0_0.set_fft_window_normalized(False)



        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 range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.qwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024, #size
            window.WIN_BLACKMAN_hARRIS, #wintype
            cntr_freq, #fc
            samp_rate, #bw
            "RX", #name
            1,
            None # parent
        )
        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)
        self.qtgui_freq_sink_x_0.set_fft_window_normalized(False)



        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 range(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.qwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.eclypse_z7_source_0 = eclypse_z7.source(ip_address, port, cntr_freq, samp_rate, sdr_freq_corr_ppm)
        self.eclypse_z7_sink_0 = eclypse_z7.sink(ip_address, port, cntr_freq, samp_rate, awg_freq_corr_ppm, 1)
        self.audio_source_0 = audio.source(48000, '', True)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_tx_0 = analog.wfm_tx(
        	audio_rate=audio_sym_rate,
        	quad_rate=quad_rate,
        	tau=75e-6,
        	max_dev=75e3,
        	fh=-1.0,
        )
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=quad_rate,
        	audio_decimation=1,
        )


        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.rational_resampler_xxx_1_0, 0))
        self.connect((self.eclypse_z7_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.eclypse_z7_source_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.root_raised_cosine_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.root_raised_cosine_filter_0_0, 0), (self.eclypse_z7_sink_0, 0))
        self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))


    def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "audio_trx")
        self.settings.setValue("geometry", self.saveGeometry())
        self.stop()
        self.wait()

        event.accept()

    def get_audio_rate(self):
        return self.audio_rate

    def set_audio_rate(self, audio_rate):
        self.audio_rate = audio_rate
        self.set_audio_sym_rate(int(self.audio_rate*2))

    def get_audio_sym_rate(self):
        return self.audio_sym_rate

    def set_audio_sym_rate(self, audio_sym_rate):
        self.audio_sym_rate = audio_sym_rate
        self.set_quad_rate(int(self.audio_sym_rate*2))
        self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))
        self.root_raised_cosine_filter_0_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))

    def get_sdr_freq_corr_ppm(self):
        return self.sdr_freq_corr_ppm

    def set_sdr_freq_corr_ppm(self, sdr_freq_corr_ppm):
        self.sdr_freq_corr_ppm = sdr_freq_corr_ppm
        self.eclypse_z7_source_0.set_freq(self.cntr_freq, self.sdr_freq_corr_ppm)

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.eclypse_z7_sink_0.set_rate(self.samp_rate)
        self.eclypse_z7_source_0.set_rate(self.samp_rate)
        self.qtgui_freq_sink_x_0.set_frequency_range(self.cntr_freq, self.samp_rate)
        self.qtgui_freq_sink_x_0_0.set_frequency_range(self.cntr_freq, self.samp_rate)
        self.qtgui_waterfall_sink_x_0.set_frequency_range(self.cntr_freq, self.samp_rate)
        self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))
        self.root_raised_cosine_filter_0_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))

    def get_quad_rate(self):
        return self.quad_rate

    def set_quad_rate(self, quad_rate):
        self.quad_rate = quad_rate

    def get_port(self):
        return self.port

    def set_port(self, port):
        self.port = port

    def get_num_taps(self):
        return self.num_taps

    def set_num_taps(self, num_taps):
        self.num_taps = num_taps
        self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))
        self.root_raised_cosine_filter_0_0.set_taps(firdes.root_raised_cosine(1, self.samp_rate, self.audio_sym_rate, 0.35, self.num_taps))

    def get_ip_address(self):
        return self.ip_address

    def set_ip_address(self, ip_address):
        self.ip_address = ip_address

    def get_cntr_freq(self):
        return self.cntr_freq

    def set_cntr_freq(self, cntr_freq):
        self.cntr_freq = cntr_freq
        self.eclypse_z7_sink_0.set_freq(self.cntr_freq, self.awg_freq_corr_ppm)
        self.eclypse_z7_source_0.set_freq(self.cntr_freq, self.sdr_freq_corr_ppm)
        self.qtgui_freq_sink_x_0.set_frequency_range(self.cntr_freq, self.samp_rate)
        self.qtgui_freq_sink_x_0_0.set_frequency_range(self.cntr_freq, self.samp_rate)
        self.qtgui_waterfall_sink_x_0.set_frequency_range(self.cntr_freq, self.samp_rate)

    def get_awg_freq_corr_ppm(self):
        return self.awg_freq_corr_ppm

    def set_awg_freq_corr_ppm(self, awg_freq_corr_ppm):
        self.awg_freq_corr_ppm = awg_freq_corr_ppm
        self.eclypse_z7_sink_0.set_freq(self.cntr_freq, self.awg_freq_corr_ppm)




def main(top_block_cls=audio_trx, options=None):

    if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.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 sig_handler(sig=None, frame=None):
        tb.stop()
        tb.wait()

        Qt.QApplication.quit()

    signal.signal(signal.SIGINT, sig_handler)
    signal.signal(signal.SIGTERM, sig_handler)

    timer = Qt.QTimer()
    timer.start(500)
    timer.timeout.connect(lambda: None)

    qapp.exec_()

if __name__ == '__main__':
    main()

awg_test.grc

Plain text
options:
  parameters:
    author: whitney
    catch_exceptions: 'True'
    category: '[GRC Hier Blocks]'
    cmake_opt: ''
    comment: ''
    copyright: ''
    description: ''
    gen_cmake: 'On'
    gen_linking: dynamic
    generate_options: qt_gui
    hier_block_src_path: '.:'
    id: awg_test
    max_nouts: '0'
    output_language: python
    placement: (0,0)
    qt_qss_theme: ''
    realtime_scheduling: ''
    run: 'True'
    run_command: '{python} -u {filename}'
    run_options: prompt
    sizing_mode: fixed
    thread_safe_setters: ''
    title: Not titled yet
    window_size: (1000,1000)
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [8, 8]
    rotation: 0
    state: enabled

blocks:
- name: awg_freq_corr_ppm
  id: variable
  parameters:
    comment: ''
    value: '0'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [392, 84.0]
    rotation: 0
    state: true
- name: cntr_freq
  id: variable
  parameters:
    comment: ''
    value: '20000000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [272, 76.0]
    rotation: 0
    state: true
- name: ip_address
  id: variable
  parameters:
    comment: ''
    value: '"192.168.1.171"'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [176, 12.0]
    rotation: 180
    state: enabled
- name: port
  id: variable
  parameters:
    comment: ''
    value: '1002'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [304, 12.0]
    rotation: 0
    state: true
- name: samp_rate
  id: variable
  parameters:
    comment: ''
    value: '1536000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [176, 76.0]
    rotation: 0
    state: enabled
- name: analog_const_source_x_0
  id: analog_const_source_x
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    const: '1'
    maxoutbuf: '0'
    minoutbuf: '0'
    type: complex
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [152, 308.0]
    rotation: 0
    state: true
- name: eclypse_z7_sink_0
  id: eclypse_z7_sink
  parameters:
    addr: ip_address
    affinity: ''
    alias: ''
    comment: ''
    corr: awg_freq_corr_ppm
    freq: cntr_freq
    port: port
    ptt: '1'
    rate: samp_rate
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [360, 272.0]
    rotation: 0
    state: true
- name: qtgui_freq_sink_x_0_0
  id: qtgui_freq_sink_x
  parameters:
    affinity: ''
    alias: ''
    alpha1: '1.0'
    alpha10: '1.0'
    alpha2: '1.0'
    alpha3: '1.0'
    alpha4: '1.0'
    alpha5: '1.0'
    alpha6: '1.0'
    alpha7: '1.0'
    alpha8: '1.0'
    alpha9: '1.0'
    autoscale: 'False'
    average: '1.0'
    axislabels: 'True'
    bw: samp_rate
    color1: '"blue"'
    color10: '"dark blue"'
    color2: '"red"'
    color3: '"green"'
    color4: '"black"'
    color5: '"cyan"'
    color6: '"magenta"'
    color7: '"yellow"'
    color8: '"dark red"'
    color9: '"dark green"'
    comment: ''
    ctrlpanel: 'False'
    fc: cntr_freq
    fftsize: '1024'
    freqhalf: 'True'
    grid: 'False'
    gui_hint: ''
    label: Relative Gain
    label1: ''
    label10: ''''''
    label2: ''''''
    label3: ''''''
    label4: ''''''
    label5: ''''''
    label6: ''''''
    label7: ''''''
    label8: ''''''
    label9: ''''''
    legend: 'True'
    maxoutbuf: '0'
    minoutbuf: '0'
    name: '"TX"'
    nconnections: '1'
    norm_window: 'False'
    showports: 'False'
    tr_chan: '0'
    tr_level: '0.0'
    tr_mode: qtgui.TRIG_MODE_FREE
    tr_tag: '""'
    type: complex
    units: dB
    update_time: '0.10'
    width1: '1'
    width10: '1'
    width2: '1'
    width3: '1'
    width4: '1'
    width5: '1'
    width6: '1'
    width7: '1'
    width8: '1'
    width9: '1'
    wintype: window.WIN_BLACKMAN_hARRIS
    ymax: '10'
    ymin: '-140'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [360, 176.0]
    rotation: 0
    state: true

connections:
- [analog_const_source_x_0, '0', eclypse_z7_sink_0, '0']
- [analog_const_source_x_0, '0', qtgui_freq_sink_x_0_0, '0']

metadata:
  file_format: 1

awg_test.py

Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Not titled yet
# Author: whitney
# GNU Radio version: 3.10.1.1

from packaging.version import Version as StrictVersion

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 PyQt5 import Qt
from gnuradio import qtgui
from gnuradio.filter import firdes
import sip
from gnuradio import analog
from gnuradio import gr
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
import eclypse_z7



from gnuradio import qtgui

class awg_test(gr.top_block, Qt.QWidget):

    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        qtgui.util.check_set_qss()
        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", "awg_test")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1536000
        self.port = port = 1002
        self.ip_address = ip_address = "192.168.1.171"
        self.cntr_freq = cntr_freq = 20000000
        self.awg_freq_corr_ppm = awg_freq_corr_ppm = 0

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024, #size
            window.WIN_BLACKMAN_hARRIS, #wintype
            cntr_freq, #fc
            samp_rate, #bw
            "TX", #name
            1,
            None # parent
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)
        self.qtgui_freq_sink_x_0_0.set_fft_window_normalized(False)



        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 range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.qwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.eclypse_z7_sink_0 = eclypse_z7.sink(ip_address, port, cntr_freq, samp_rate, awg_freq_corr_ppm, 1)
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 1)


        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.eclypse_z7_sink_0, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.qtgui_freq_sink_x_0_0, 0))


    def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "awg_test")
        self.settings.setValue("geometry", self.saveGeometry())
        self.stop()
        self.wait()

        event.accept()

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.eclypse_z7_sink_0.set_rate(self.samp_rate)
        self.qtgui_freq_sink_x_0_0.set_frequency_range(self.cntr_freq, self.samp_rate)

    def get_port(self):
        return self.port

    def set_port(self, port):
        self.port = port

    def get_ip_address(self):
        return self.ip_address

    def set_ip_address(self, ip_address):
        self.ip_address = ip_address

    def get_cntr_freq(self):
        return self.cntr_freq

    def set_cntr_freq(self, cntr_freq):
        self.cntr_freq = cntr_freq
        self.eclypse_z7_sink_0.set_freq(self.cntr_freq, self.awg_freq_corr_ppm)
        self.qtgui_freq_sink_x_0_0.set_frequency_range(self.cntr_freq, self.samp_rate)

    def get_awg_freq_corr_ppm(self):
        return self.awg_freq_corr_ppm

    def set_awg_freq_corr_ppm(self, awg_freq_corr_ppm):
        self.awg_freq_corr_ppm = awg_freq_corr_ppm
        self.eclypse_z7_sink_0.set_freq(self.cntr_freq, self.awg_freq_corr_ppm)




def main(top_block_cls=awg_test, options=None):

    if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.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 sig_handler(sig=None, frame=None):
        tb.stop()
        tb.wait()

        Qt.QApplication.quit()

    signal.signal(signal.SIGINT, sig_handler)
    signal.signal(signal.SIGTERM, sig_handler)

    timer = Qt.QTimer()
    timer.start(500)
    timer.timeout.connect(lambda: None)

    qapp.exec_()

if __name__ == '__main__':
    main()

Credits

Whitney Knitter

Whitney Knitter

165 projects • 1678 followers
All thoughts/opinions are my own and do not reflect those of any company/entity I currently/previously associate with.

Comments