GNU Radio: Tools for Exploring the Radio Frequency Spectrum
GNU Radio provides a library of signal processing primitives and the glue to tie it all together. The programmer builds a radio by creating a graph (as in graph theory) where the nodes are signal processing primitives and the edges represent the data flow between them. The signal processing primitives are implemented in C++. Conceptually, primitives process infinite streams of data flowing from their input ports to their output ports. Primitives' attributes include the number of input and output ports they have as well as the type of data that flows through each. The most frequently used types are short, float and complex.
Some primitives have only output ports or input ports. These serve as data sources and sinks in the graph. There are sources that read from a file or ADC, and sinks that write to a file, digital-to-analog converter (DAC) or graphical display. About 100 primitives come with GNU Radio. Writing new primitives is not difficult.
Graphs can be constructed and run in C++, but the easy way to glue everything together is with Python. Listing 1 is the “Hello World” of GNU Radio. It generates two sine waves and outputs them to the sound card, one on the left channel, one on the right.
Listing 1. Hello World (Dial Tone Output)
#!/usr/bin/env python
from GnuRadio import *
def build_graph ():
sampling_freq = 32000
ampl = 8192
fg = gr_FlowGraph ()
src0 = GrSigSourceS (
sampling_freq, GR_SIN_WAVE, 350, ampl)
src1 = GrSigSourceS (
sampling_freq, GR_SIN_WAVE, 440, ampl)
sink = GrAudioSinkS ()
fg.connect (src0, sink)
fg.connect (src1, sink)
return fg
if __name__ == '__main__':
fg = build_graph ()
fg.start () # fork thread(s) and return
raw_input ('Press Enter to quit: ')
fg.stop ()
We start by creating a flow graph to hold the primitives and connections between them. The two sine waves are generated by the GrSigSourceS calls. The S suffix indicates that the source produces shorts. One sine wave is at 350Hz, and the other is at 440Hz. Together, they sound like the US dial tone.
GrAudioSinkS is a sink that writes its input to the sound card. It takes one or two streams of shorts as its input. We connect the three primitives together using the connect method of the flow graph. Once the graph is built, we start it. Calling start forks one or more threads to run the computation described by the graph and returns control immediately to the caller. In this case, we simply wait for any keystroke.
Listing 2 shows a somewhat simplified but complete broadcast FM receiver. It includes control of the RF front end and all required signal processing. This example uses an RF front end built from a cable modem tuner and a 20M sample/sec analog-to-digital converter.
Listing 2. Simple Broadcast FM Receiver
#!/usr/bin/env python
# simple broadcast FM receiver
from GnuRadio import *
#
# return a gr_FlowGraph
#
def build_graph (IF_freq):
input_rate = 20e6
CFIR_decimate = 125
RFIR_decimate = 5
fm_demod_gain = 2200
quad_rate = input_rate / CFIR_decimate
audio_rate = quad_rate / RFIR_decimate
volume = 1.0
src = GrHighSpeedADCSourceS (input_rate)
# compute FIR filter taps for channel selection
channel_coeffs = \
gr_firdes.low_pass (
1.0, # gain
input_rate, # sampling rate
250e3, # low pass cutoff freq
8*100e3, # width of trans. band
gr_firdes.WIN_HAMMING)
# input: short; output: complex
chan_filter = \
GrFreqXlatingFIRfilterSCF (CFIR_decimate,
channel_coeffs,
IF_freq)
# input: complex; output: float
fm_demod = \
GrQuadratureDemodCF (volume * fm_demod_gain)
# compute FIR filter taps for audio filter
width_of_transition_band = audio_rate / 32
audio_coeffs = \
gr_firdes.low_pass (
1.0, # gain
quad_rate, # sampling rate
audio_rate/2 - width_of_transition_band,
width_of_transition_band,
gr_firdes.WIN_HAMMING)
# input: float; output: short
audio_filter = \
GrFIRfilterFSF (RFIR_decimate, audio_coeffs)
final_sink = GrAudioSinkS ()
fg = gr_FlowGraph ()
fg.connect (src, chan_filter)
fg.connect (chan_filter, fm_demod)
fg.connect (fm_demod, audio_filter)
fg.connect (audio_filter, final_sink)
return fg
if __name__ == '__main__':
# connect to RF front end
rf_front_end = microtune_eval_board ()
if not rf_front_end.board_present_p ():
raise IOError, 'RF front end not found'
# set gain and radio station frequency
rf_front_end.set_AGC (300)
rf_front_end.set_RF_freq (100.1e6)
IF_freq = rf_front_end.get_output_freq ()
fg = build_graph (IF_freq)
fg.start () # fork thread(s) and return
raw_input ('Press Enter to quit: ')
fg.stop ()
Like the Hello World example, we build a graph, connect the primitives together and start it. In this case, our source is the high-speed ADC, GrHighSpeedADC. We follow it with GrFreqXlatingFIRfilterSCF, a finite impulse response (FIR) filter that selects the FM station we're looking for and translates it to baseband (0Hz, DC). With the 20M sample/sec converter and cable modem tuner, we're really grabbing something in the neighborhood of a 6MHz chunk of the spectrum. This single chunk may contain ten or more FM stations, and GrFreqXlatingFIRfilterSCF allows us to select the one we want. In this case, we select the one at the exact center of the IF of the RF front end (5.75MHz). The output of GrFreqXlatingFIRfilterSCF is a stream of complex samples at 160,000 samples/second. We feed the complex baseband signal into GrQuadratureDemodCF, the block that does the actual FM demodulation. GrQuadratureDemodCF works by subtracting the angle of each adjacent complex sample, effectively differentiating the frequency. The output of GrQuadratureDemodCF contains the left-plus-right FM mono audio signal, the stereo pilot tone at 19kHz, the left-minus-right stereo information centered at 38kHz and any other sub-carriers above that. For this simplified receiver, we finish off by low pass filtering and decimating the stream, keeping only the left-plus-right audio information, and send that to the sound card at 32,000 samples/sec. See the GNU Radio Wiki for discussions and tutorials on signal processing.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- The Pari Package On Linux
- Home, My Backup Data Center
- New Products
- Dart: a New Web Programming Experience
- This is the easiest tutorial
5 hours 1 min ago - Ahh, the Koolaid.
10 hours 39 min ago - git-annex assistant
16 hours 39 min ago - direct cable connection
17 hours 2 min ago - Agreed on AirDroid. With my
17 hours 12 min ago - I just learned this
17 hours 16 min ago - enterprise
17 hours 46 min ago - not living upto the mobile revolution
20 hours 37 min ago - Deceptive Advertising and
21 hours 13 min ago - Let\'s declare that you have
21 hours 14 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
create radio FM on linux using bluetooth as receiver
any ideas?