Skip to content

Add FM Radio Example with Moku and GNU Radio - #18

Open
upul-li wants to merge 9 commits into
mainfrom
fm-radio
Open

Add FM Radio Example with Moku and GNU Radio#18
upul-li wants to merge 9 commits into
mainfrom
fm-radio

Conversation

@upul-li

@upul-li upul-li commented Dec 20, 2024

Copy link
Copy Markdown
  1. Wrote Python script for configuring and streaming IQ samples from Lock-in Amplifier.
  2. Created GNU Radio files for a simple FM receiver.
  3. Basic usage instructions added.

Comment on lines +13 to +31
from PyQt5 import Qt
from gnuradio import qtgui
from PyQt5 import QtCore
from gnuradio import analog
from gnuradio import audio
from gnuradio import blocks
from gnuradio import blocks, gr
from gnuradio import filter
from gnuradio.filter import firdes
from gnuradio import gr
from gnuradio.fft import window
import sys
import signal
from PyQt5 import Qt
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
import difi
import sip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up these imports. You import Qt twice, you import gnuradio.blocks and gnuradio.gr twice etc. Prefer list imports so long as the list doesn't get too long, e.g. from gnuradio import analog, audio, blocks, .... Once you've consolidated, they should also be sorted

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually one good thing to do here is probably to run black over this code. It's a Python linter with some fairly sensible defaults.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the top block code auto generated from GNU Radio. Changes made manually are overwritten by the scheduler when running the flow graph from gnu radio companion. I believe changes are viable if the application is intended for a field deployment.

self._volume_range = qtgui.Range(0, 4, 0.1, 1, 200)
self._volume_win = qtgui.RangeWidget(self._volume_range, self.set_volume, "Volume", "counter_slider", float, QtCore.Qt.Horizontal)
self.top_layout.addWidget(self._volume_win)
self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these magic numbers come from? Given that this is an example it'd be worth a few concise comments

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto generated code from GNU Radio. Changes made manually are overwritten when running the flow graph from gnu radio companion.


self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False)

labels = ['', '', '', '', '',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labels = [''] * 10, and similar below. But why 10?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto generated code from GNU Radio. Changes made manually are overwritten when running the flow graph from gnu radio companion.

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. and why 1 here? What are we looking at, is this something like channel count and for now we only support a single channel?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto generated code from GNU Radio. Changes made manually are overwritten when running the flow graph from gnu radio companion.

self.qtgui_time_sink_x_0.enable_stem_plot(False)


labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above why 10, and consider using some shorthands like widths = [1] * 10 and labels = [f"Signal {i+1}" for i in range(10)]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto generated code from GNU Radio. Changes made manually are overwritten when running the flow graph from gnu radio companion.

Comment thread python-api/lock_in_amplifier_fm_radio/lock_in_amplifier_fm_radio.py Outdated
Comment thread python-api/lock_in_amplifier_fm_radio/lock_in_amplifier_fm_radio.py Outdated
Comment thread python-api/lock_in_amplifier_fm_radio/lock_in_amplifier_fm_radio.py Outdated
Comment thread python-api/lock_in_amplifier_fm_radio/lock_in_amplifier_fm_radio.py Outdated
Comment thread python-api/lock_in_amplifier_fm_radio/lock_in_amplifier_fm_radio.py Outdated
@upul-li
upul-li requested a review from bnizette-li January 6, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants