Software-defined Radio on a Shoestring
Posted by Andrew Back on Tue, Jul 10 2012 09:15:18
Software-defined radio (SDR) holds incredible promise for the future of communications: from reducing the bill of materials and enabling software upgrade of equipment, to cognitive radio systems that bring unprecedented efficiency in managing access to scarce spectrum resource. However, most hardware platforms that enable SDR experimentation are expensive or else limited to some specific use. But this is no longer the case and due to a neat hack it’s possible to re-purpose hardware that can be had for less than £20, to provide an RF front-end that can be tuned from 64-1700 MHz and to provide sample rates of up to 2.8 MS/s.
Firstly, it’s important to note that if you require a system with high resolution ADCs or one that supports transmit as well as receive, this may not be what you’re looking for. But if you have basic Linux skills and would like to gain hands on experience with SDR for minimal outlay, this provides incredible value for money. Which is not to say that the hardware covered here cannot be put to use in some pretty impressive applications, as it’s been used to receive everything from FM broadcast and AM aircraft traffic, to GSM, TETRA and various satellite modes.
Over the years there has been much talk among the open source community of re-purposing DVB receiver hardware for use with SDR, but with very limited actual success. That changed earlier this year when a Linux developer reported that a particular DVB-T demodulator IC could be configured to provide raw samples instead of a demodulated signal. Two days later and another member of the community had managed to demodulate an FM broadcast from a file captured with a DVB receiver that uses the IC. This was back in February, and since then open source tools have been created to support using RTL2832U-based receivers with SDR, rtl-sdr. With other projects building on this to provide integration with existing open source SDR software.
A Generic RTL2832U-based USB DVB-T Receiver
Drivers for RTL2832U-based DVB-T hardware are already present in the Linux kernel, and what rtl-sdr provides is two simple command line tools that support use with SDR. The rtl_sdr command can be used to tune a receiver to a particular frequency and to set the gain and sample rate, whilst specifying a file to capture samples to. And rtl_tcp performs a similar function but provides a TCP server that makes samples available over the network instead of capturing them to a file.
Getting up and running with rtl-sdr takes no time at all and requires following a few simple build steps provided by the project. And if you wanted to write your own SDR application from scratch you could proceed from there by studying the rtl-sdr source code. But for a far friendlier approach we’ll look at using the GNU Radio SDR framework.
GNU Radio is an open source toolkit for creating SDR applications, that provides signal processing blocks written in C++ which are assembled together via Python scripts to create flow graphs. This can either be done by hand or via a graphical editor, GNU Radio Companion (GRC).
The software has quite a few open source dependencies, and by far the easiest way to get up and running with GNU Radio is to use the build script provided by Marcus D. Leech. When using this it should be noted that you may have to unpick problems with installing dependencies if the script fails, and the build can take some time if your machine has limited resources. Should you already have a recent version of GNU Radio installed, all you need to do is install rtl-sdr and some additional software, gr-osmosdr, which will provide RTL2832U support from within GNU Radio.
A Multimode Receiver
With GNU Radio, rtl-sdr and gr-osmosdr installed we are now ready to run SDR applications, and a good starting place is the Multimode receiver that is available from the Comprehensive GNU Radio Archive Network (CGRAN). The files for this can be checked out from CGRAN Subversion with the command:
$svn co https://www.cgran.org/svn/projects/multimode
Following which the receiver can be started either by executing multimode.py from the command line, or by running gnuradio-companion and from within this selecting to open the file called multimode.grc.
As can be seen GRC provides a powerful editing environment where GNU Radio blocks can quickly be browsed and assembled to create signal processing graphs.
With the application loaded in GRC we now select to Execute the flow graph.
The Multimode application tuned to FM broadcast station BBC Radio 4.
Creating GNU Radio Applications
Although the rtl-sdr breakthrough is quite recent GNU Radio has been around for many years, and there exists a good selection of open source applications which can be used to learn from and as the basis for new projects. For example, GNU Radio is supplied with applications for a variety of modes and these get installed to/usr/local/share/gnuradio/examples, the aforementioned CGRAN provides hosting for 3rd party GNU Radio applications, and others can be found around the Web.
GRC provides the perfect learning tool for those that are just starting out, and since the underlying flow graphs are Python scripts these can be easily viewed to understand the finer details. The GNU Radio documentation is fairly comprehensive, the project provides tutorials and further support is available via the mailing lists.
Other SDR Software
The availability of SDR hardware at such a price point has created immense excitement among the open source, ham radio and electronics hobbyist communities. And there now exists a number of projects doing work with rtl-sdr hardware. One notable example being a fork of the GHPSDR project, which providesAndroid software that can connect over the Internet to control a remote system that is configured with an RTL2832U-based receiver.
In this post we look at how USB DVB-T hardware can be used with software-defined radio (SDR) to create a low cost aviation Mode S receiver.
Modern aircraft are fitted with “Mode S” transponders that can be interrogated by air traffic control radar in order to ascertain their position and heading. Hobbyist equipment for receiving these transmissions has been available for some time and typically costs hundreds of pounds. But it’s now possible to re-purpose DVB-T hardware costing around £20 to create an SDR-based receiver.
The SDR is constructed using the GNU Radio framework and details of how to configure this and the DVB-T hardware used can be found in a previous post. With GNU Radio and rtl-sdr etc. configured all that’s required is to set up the gr-air-modes application. This takes only a few minutes and involves cloning the source from GitHub, building and installing. With gr-air-modes set up the rtl_modes.pyPython script can be run to provide a simple text output of decoded transmissions.
Google Earth integration
The gr-air-modes application also provides Google Earth support and this can be configured with the following steps:
- Run “uhd_modes.py -d -K modes.kml”
- In Google Earth select Add → Network Link, browse to the modes.kml file and set refresh to 5 seconds
- Optional: edit /usr/local/bin/uhd_modes.py to set my_position
Flight simulation and network applications
Integration with the FlightGear flight simulator is also possible, with live traffic being inserted into the simulator via its multiplayer interface. And gr-air-modes can also store reports in an SQLite database, and serve data over the network in either the SBS-1 format or as raw UDP packets.
The gr-air-modes software serves as a compelling demonstration of the power of software-defined radio, and shows how it has become possible for custom hardware to be easily replaced by generic hardware costing a fraction of the price and by shifting complexity into the software domain.
Top image: detail from Google Earth showing two aircraft and their flight paths.
— Andrew Back