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.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Google's SwiftShader Released
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Interview with Patrick Volkerding
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Non-Linux FOSS: Caffeine!
- SuperTuxKart 0.9.2 Released
- Tech Tip: Really Simple HTTP Server with Python
- Parsing an RSS News Feed with a Bash Script
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide