Radio's Next Generation: Radii
September 30th, 2005 by Dan Rasmussen, Paul Norton and Jon Morgan in
A phrase we heard many times when we sought venture capital to develop the Internet appliance we call Radii was “If this were 1999, you would already have your money.” Unfortunately, it was 2004 and there was no money for a risky consumer product such as Radii, despite our compelling prototype and a well-defined market. Rather than let our efforts go to waste, we decided to share the details of the prototype here with the Linux community that made its development possible. In this article, we explain how we quickly built our Radii prototype using low-cost hardware and Linux along with some of its companion software, including Perl and GCC.
Radii is a radio: a box with buttons and dials used to select bands and tune stations in a familiar way. Because this radio receives Internet radio, it provides hundreds of noise-free stations with a wide variety of listening options. The band selection dial, instead of AM and FM, is used to select genres such as News, Sports and Rock. The station selection dial scrolls through station names that can be tuned by clicking the select button.
At the beginning of this project, the three of us threw in $100 each and some spare time while continuing to work our day jobs. We never thought of this as an exercise in rapid prototyping; it was all about implementing our vision as quickly and inexpensively as possible. At every step of our development, we looked for the fastest way to get the task accomplished and balanced that against its cost.
The prototype is housed in a converted SW-54 radio made by the National Radio Company in the 1950s. The radio was in poor condition before the conversion. As admirers and collectors of old technology, we like to think we gave it a new lease on life.
The Radii core hardware platform is an old laptop running Linux. The operator interface consists of two rotary encoders, three momentary contact buttons, a 40x2 backlit LCD, a power supply and a retro radio cabinet. The encoders and buttons are connected to a PIC microcontroller development board that is, in turn, connected to the laptop's serial port. The LCD is connected to the laptop's parallel port.
On our budget of $300, cost was important. As such, eBay was our vendor of choice. Here is our hardware shopping list:
PIC microcontroller dev board (OOPIC) ($70).
One TTL to RS-232 chip (TI MAX232) and associated bits to interface the PIC to RS-232 ($5).
Three momentary buttons for selection/special functions ($3).
Two rotary encoders one for band selection, one for stations selection ($3).
One 40x2 LED backlit LCD ($12 eBay).
Gateway Solo 5150, 300MHz Pentium laptop, broken screen ($100 eBay).
One National NC-54 vintage radio ($35 eBay).
Power supply for PIC and LCD (3/$10 eBay).
Cables, connectors, bubble gum, baling wire and so on. ($25).
Shipping, fees and taxes took up most of the remaining funds.
A PIC microcontroller is a single-chip computer produced by Microchip Technology, Inc. Although these tiny computers are capable of many useful things, we used it here simply to handle operator inputs. For prototyping with a PIC, a development board normally is used. PIC development boards provide an easy way to prototype a PIC application by allowing a range of input power options and easy access to the input and output pins for the chip. It is not necessary to use this, but it makes creating a prototype easier.
We used the OOPIC development board/system by Savage Innovations. It is inexpensive and provides a simple object interface for many input and output devices, including buttons, encoders and RS-232 serial communication. Unfortunately, there is no Linux development environment for OOPIC, although a SourceForge project is underway.
The hardware is rounded out with a Gateway Solo 5150 laptop that has a broken LCD. Similar laptops go for between $50 and $100 on eBay.
We chose Linux from the start for many reasons. The primary reason is that most distributions are configured with many of the tools we thought we might use, such as mpg123, XMMS, Perl and compilers. It also helped us stay on budget because it's free. Linux makes prototyping easy, because many applications and utilities have retained their command-line interface, allowing their use from scripts, such as the one written for Radii and described below.
Installation and configuration of the OS was straightforward, except for audio support. Because our laptop was so old, most installers were not able to detect the audio hardware. In an unscientific way, we tried many different Linux distributions until we found one that installed easily on our machine. We wound up installing Fedora Core 2 with ALSA (Advanced Linux Sound Architecture) support.
To get sound working for your particular machine, it is most important to identify your sound hardware. In our case, we were able to determine the sound hardware by Googling on the model number for this laptop. Once we determined which sound hardware we had, we were able to locate and install the appropriate ALSA driver for our machine, the ES1879 ESS Audio Driver, from the ALSA Project site. You may need to tweak some of the default ALSA parameters by using the alsamixer utility.
With the hardware in place and the OS working, it all came down to finding or creating the required software components. We had simple requirements:
An audio stream player.
An LCD controller.
An application to process operator-induced signals from the serial port and interact with the stream player and LCD.
We needed a way to play streaming audio that we could control from our application. We initially dismissed XMMS because it is a GUI application, but we later re-examined it and discovered that XMMS can be manipulated from the command line.
The XMMS application provides many handy options that can be used to control an already-running instance of itself. It can be stopped by issuing the -s argument. The playlist can be updated by using -p <playlist> and the playlist argument can be the URL of a stream. Use xmms -h for complete details.
For example, you ask XMMS to switch from its current selection to the AM 1710 Antioch Internet station (old-time radio), by issuing the command:
xmms -p http://66.54.65.226:9022
To stop, use xmms -s and so on.
XMMS completely covered our needs for a player, but it introduced a problem as well. XMMS is a GUI application, so it requires a running X11 server. Rather than tax the available resources on our low-powered laptop, we used the X Virtual Frame Buffer, Xvfb. Xvfb provides a lightweight X11 server that can be used to provide X11 resources to applications that require them, but it does nothing else— it is invisible.
We required a CLI application that would display a string on our parallel port LCD. After Googling for this, we found a FOSS application called lcd-info. lcd-info displays system performance information on an HD44780-compatible LCD connected to the system parallel port. It was not quite what we needed, but after studying its source for a few minutes, we found that it could be adapted easily for our purpose.
lcd-info is written in C and compiles into a CLI application. We compile our simpler application with a trivial invocation of GCC:
% gcc -o setlcd setlcd.c iolcd.c
The low-level routines that control the LCD are in iolcd.c, which was borrowed without modification from the lcd-info Project. setlcd.c is the Radii-specific piece that uses functions found in iolcd.c. We called our binary setlcd, and it is run like so:
% setlcd <string to display>
Building the cable to interface the LCD to the parallel port was more time consuming than was adapting lcd-info. It seems that there should be an appropriate off-the-shelf cable, but the pinout on the LCD-side of the cable varies with the manufacturer/model. Rather than finding exactly the right cable/LCD pair, we elected to make our own cable for the LCD we had acquired based on price.
We built the Radii application using Perl. We chose Perl because it's a language we know well, it has many supporting packages and the update/compile/debug cycle is fast.
The first thing to do is read the input from the PIC development board connected to the serial port. We used the Device::SerialPort package. Here is the beginning of our application, which shows how to initialize the serial port using the Device::SerialPort module:
#!/usr/bin/perl
use Device::SerialPort;
use strict;
# Set up the port.
# All port settings must match the PIC settings.
my $port = new Device::SerialPort("/dev/ttyS0");
$port->baudrate(9600);
$port->parity("none");
$port->databits(8);
$port->stopbits(1);
$port->handshake('none');
$port->write_settings;
Then we needed to handle the following messages sent from the PIC development board based on user input:
Msg Meaning
--- -------
U The station encoder rotated one unit up
D The station encoder rotated one unit down
s The select button was pressed
u The band encoder rotated one unit up
d The band encoder rotated one unit down
while ( 1 )
{
while (! ($code = $port->input))
{
select undef, undef, undef, 0.075;
}
}
The outer while loop keeps the application running until it is killed or dies. The inner while loop attempts to read from the serial port. If there is nothing to read, it sleeps for a short time, 0.075 seconds, and then tries again. This sleep is important to keep the application from spinning too hard and consuming a lot of CPU time. Any messages that arrive while the loop is sleeping accumulate on the port and are available the next time we read.
When an input message is received, the application always should respond by updating the LCD. It sometimes should respond by changing the current station, that is, when the selection button is pressed.
When we get a Station Up (U) or Station Down (D) message, we need to display the next station on the LCD, but we don't want the station to change until the user sends a select signal. This brings us to the LCD message display. As previously noted, we use the setlcd command, but now we call it from the Perl script using the Perl system command:
system("setlcd",
"Sel:$radiiStn{$curBand}{$choice}{name}");
where $radiiStn{$curBand}{$choice}{name} is a hash that is indexed by way of the band index and the choice index. It contains the necessary selection information: display name (used here), station URL and its band.
Once the operator clicks the select button, the PIC sends an s message. In response, the system updates the LCD to the new station name and signals XMMS to play the new stream, again using Perl's system command:
system("setlcd",
$radiiStn{$curBand}{$choice}{name});
system("/usr/bin/xmms",
"-p",
$radiiStn{$curBand}{$choice}{station});
The Radii application is configured using a simple XML input file:
<?xml version="1.0"?>
<Radii>
<station url="http://66.54.65.226:9022">
<band>OLD TIME RADIO</band>
<name>AM 1710 Antioch</name>
</station>
<station url="http://205.188.234.38:8040">
<band>Celtic</band>
<name>CelticGrove.com 24/7 Celtic/Irish</name>
</station>
.
.
.
</Radii>
The XML configuration file can be read using the XML::Simple Perl module.
my @station;
my %radiiStn = ();
my %bands = ();
my $file = 'stations.xml';
my $xs1 = XML::Simple->new();
my $doc = $xs1->XMLin($file);
foreach my $key (keys (%{$doc->{station}}))
{
$band = $doc->{station}{$key}{band};
$url = $doc->{station}{$key}{url};
$name = $key;
$bands{$band} += 1;
$radiiStn{$band}{$bands{$band}}{name} =
$bands{$band}.":$band: ".$key;
$radiiStn{$band}{$bands{$band}}{station} = $url;
}
This code utilizes Perl hashes for the required band and station information. Band information, including name and number of stations, is kept in the bands hash. Station information, such as name, URL and band, is kept in radiiStn hash.
See the on-line Resources for the URL of a site with the complete script and other associated software, along with details on how to build the hardware.
Radii demonstrates how Linux can be used to prototype a complex consumer device quickly and cheaply. As the iPod revolution takes hold and satellite radio becomes more popular, Radii-like devices inevitably will change the way radio is broadcast and received all over the world.
Rapid prototyping does not require particular hardware, sets of tools or languages. It's not about finding the best solution; it's about getting it done quickly using the available resources. That pool of resources is vast when it is FOSS on Linux. Keep your eye on the goal while you sort through the potential building blocks. Tweak as necessary, and then glue it all together with your language of choice.
We configured our laptop to boot to run-level 3, full multiuser mode. After the laptop boots, we start Xvfb, set our DISPLAY variable, start XMMS and start the Radii application. The startup sequence is:
% Xvfb :1 & % export DISPLAY=:1.0 % xmms & % radii.pl
Then we hide the laptop and enjoy the radio that we call Radii.
Resources for this article: /article/8537.
Subscribe now!
Recently Popular
| Do we really have options? | Jul-18-08 |
| Review: HP 2133 Mini-Note | Jul-16-08 |
| Building a Call Center with LTSP and Soft Phones | Aug-25-05 |
| Boot with GRUB | May-01-01 |
| Why Python? | May-01-00 |
| Audio/Visual Synthesis: The New Arts, Part 2 | Jul-17-08 |
Featured Videos
Shawn Powers reviews the HP Mini-Note portable computer.
Thanks to our sponsor: Silicon Mechanics
Silicon Mechanics is a leading manufacturer of rackmount servers, storage, and high performance computing hardware. The best warranty offerings available are backed by experts dedicated to customer satisfaction.
In today's time of rampant information crimes, including identity theft, security is more important to the average computer user than ever. This tutorial shows how you can use GnuPG to secure and verify data on your Linux box.
From the Magazine
August 2008, #172
There's nuttin like a Cool Project to give you some relief from the summer heat, so get out your parka cuz we got a bunch of em. First up is the BUG, not a bug, The BUG. It's got a GPS, camera and more, in a hand-sized package that's user programmable. The BUG does everything. It's both a floor wax and a dessert topping. Get one now. Need a software version of a Swiss Army knife? Take a look at Billix, and don't leave home without it. Then, chew on this one, an X server on a Gumstix device driving an E-Ink display. Need more storage? How about 16 Terabytes? Can do.
And, of course, we have the usual cast of characters: Marcel, Reuven, Dave, Kyle, Doc, plus the new kid on the block Shawn Powers. But it doesn't stop there: build a MythTV box on a budget, build your own GIS system, set up the tools to monitor your enterprise and more. Finally, remember The War of the Worlds? Now you can play too.


Delicious
Digg
Reddit
Newsvine
Technorati







Woah, love the idea of this.
On December 10th, 2005 Luc (not verified) says:
Woah, love the idea of this. There are quite a few stations I like to listen to that are forgien so obviously don't boradcast within a few 1000 miles of where I live. This would be a great way to listen to them around the house. So when does production start?
Great Prototype
On October 5th, 2005 Dave (not verified) says:
A very interesting article. Your prototype now allows you to show people the concept,something they can get their hands on.
Never OO embedded devices
On October 5th, 2005 James (not verified) says:
Gentlemen,
On the surface, your homespun project looks impressive. However,
as an embedded expert, your 'project' demonstrates everthing
wrong with many if not most product development efforts.
1. OO programming for embedded devices, is doom to failure
for a variety of reasons: security, maintainance, portabilty
but mostly costs.
2. You project could be implemented on a $5 x86 embedded CPU, avoiding
the pc mobo and the PIC all together. You have to have hardware and
firmware engineers minimize the hardware design before you start
coding.
3. Features that are missing are killers. Traditional AM/FM radio
support must be added, using a chip that costs a few dollars so as
to attract the tradition radio market. Upon using the AM/FM radio
features, as a comfortable commodity, you can then attact them
to Internet radio. NTP and the ability to filter out commercials
over traditional AM/FM broadcast would make your product much more
financially viable.
I could go on and on, but I hope you start to see clearly. The
problem with product development, is it starts with expertise
in hardware and firmware. Embedded linux is fantastic, but, you
never, never, never use a distro espcially pocket PR or Fedora,
as all of that excess baggage wastes critical resoures and leads
to unstable products that are expensive to maintain.
Last, if you are going to build embedded products, LEARN ASSEMBLER
mixed in with ansi C. Leave OO on the destops, where it belongs..
sincerely,
James Horton, BSEE, MSCS PE.
Some do and some talk
On October 27th, 2005 K2TQN (not verified) says:
I think this is a great project just as it is. It's a great new idea and it has been implemented. I put them in the same league with Bell, Edison, the Wright Brothers, Marconi, DeForest, Mauchly and Eckert, Woz and Jobs, and all the others who forged ahead and were first!
Of course everything can be improved, but they did it, and did it first.
Congratulations.
John Dilks, K2TQN
Personal Computing Pioneer (1976)
I agree completely if this were a final product
On October 5th, 2005 Dan Rasmussen (not verified) says:
Hi James,
You are universally correct in your assesment of the device as a final product and I am glad your brought it up. One of the points of the article that may not have been made well is, as a prototype, our primary goal was to minimize effort/cost get it done as quickly as possible.
Had we done all of the things you mentioned, it would have taken much much longer than the month or two that it did take (and much of that time was spent soldering). Prototyping is extremely important in the development of any software or system and we needed to have a prototype to have any hope of getting funded and this was it.
Had we received funding for the idea, the device was to include some of your suggestions and many other features not mentioned. Our fist technical task after receiving funding would have been to get it on an embedded system (we were considering Gumstix - http://www.gumstix.com - as the next step but not necessarly the final platform - we still had lots of work to do).
Prototyping is about getting something together that looks complete but doing it as quickly/cheaply/easily as possible. Optimization comes when you have the time/money/resources to do that. Some of that message may have been lost as the article went through its many revisions (We had to get rid of lots of words).
Thanks for the comments.
Dan Rasmussen
still pursuing the Internet Radio project?
On January 31st, 2007 Tracy R (not verified) says:
Hello .. I came across your article regarding your Internet Radio device while I was doing a search for exactly that type of product. If you (..or any one else out there) ever needs cheap(free!), quality labor designing this product, feel free to contact me any time (trcal_2000@yahoo.com). I have 20+ years in New Product Development for many different products. Let's do it!
Thanks,
Tracy R.
Assembler not always needed
On October 5th, 2005 Barton (not verified) says:
While I agree with most of your comments I don't think that assembly language is needed very often. I have done many embedded applications and very seldom need to fall back on assembly language. Even when doing DSP projects the C compilers are very capable of creating very optimized code. If one does need a little bit of assembly it can usually be added in line with a C extension like asm {} or the like. With DSP's one does usually need a little bit of start up assembly but it is only a page of code. Assembly language is hard to code, hard to maintain, and hardest still to port to other processors. When ever possible I try to make do with ANSI C. I agree that OO and C++ are usually overkill for an embedded application unless it has an OS to fall back on. An embedded system using one of the embedded Linux products could support OO if the project was real big. Most of the time however the embedded projects I work on don't need any OS and must fit into small spaces. PIC's and DSP projects for hardware control usually don't need the extra overhead of an OS.
Of course that's my opinion, I could be wrong.
next step ?
On October 4th, 2005 ben ciceron (not verified) says:
wow ! great.
let's find a linux friendly palmtop or mp3 player and we might have winner...
When and where, I'd buy!
On October 4th, 2005 Ed O'Neil (not verified) says:
You've got a GREAT idea. Broadcast radio reception where I live isn't that great so a device like yours is very atractive. In the mean time, I will continue to use an inexpensive ($15-20) FM transmitter to re-broadcast from my PC to all of the radios in my home. You could intigrate something similar in yours so that the listener could roam the house and hear the same station. If you need a beta tester...
Retro Radio
On October 4th, 2005 Frank Daley (not verified) says:
There IS a market for something like this. Just look at the huge success that Chrysler had with their retro PT Cruiser:
http://www.chrysler.com/pt_cruiser/
There are even some interesting similarities between the two. Surely there is at least one VC company with some vision!!
Good luck, it would be a winner if it went to production.
Uhhhh. The PT Cruiser is a h
On October 5th, 2005 Anonymous (not verified) says:
Uhhhh. The PT Cruiser is a hacked Neon. Not in the least bit retro.
Internet radio and Music servers
On October 3rd, 2005 Anonymous (not verified) says:
very interesting project, I was actually looking at some music servers that offer Internet radio, such as the musica from www.olive.us and the sonos from www.sonos.com , if end not purchasing a music server, and this product becomes a reality, I may end up getting one
One thing I didn't understand
On October 3rd, 2005 Dave (not verified) says:
One thing I didn't understand was how the consumer uses it. It looks like they select a genre from the dial, then how does the radio know what stations to list? Does the user have to enter them somehow? Will it work wireless (using a hot spot)? Over-all it seems very cool!
Dave,
Radii
On October 3rd, 2005 Dan Rasmussen (not verified) says:
Hi Dave,
Thanks for the positive comments. Possibly not explained well was that there is a genre dial and a turner dial. Twiddle the genre dial and the LCD will update to the new genre. Once you get the the desired genre, twiddle the station dial and the LCD updates with new selections from the genre.
Dan
XML station identification
On October 3rd, 2005 Glider (not verified) says:
The XML configure script allows for the storing of radio stations.
I don't see where the authors allow for this lsit to be updated except for someone with command line access editting the configuration file. However I could see where it could be set up to populate radio stations from the web using an RSS feed or something similar.
Great article!
-G-
XML station builder script
On October 3rd, 2005 Dan Rasmussen (not verified) says:
Hello -G-,
Yes, you are correct, there is no mention of how this file gets generated. If you take a look at the resources page it will lead you to a page that gives a little bit of an explanation but it goes like this: yes there is a script that will generate the xml config file (well, sort of, it still needs a bit of hand editing). It does this by querying a well known station list keeper (that actually limits your daily queries - based on IP). At the same site (http://www.retro-tronics.com/radii) You will also find a stale xml station file along with all of the associated source. The station gen scrip is not yet posted but everything else is. I need to clean it up a bit first.
Thanks for the positive comments.
Dan
script?
On December 27th, 2005 ken Scharf (not verified) says:
Well it's now December 27 and you STILL havn't put the station list generater scrpit up on your web site.
Also I have an optical encoder switch that has a push button switch built in. I can see rewriting the interface so the single dial could switch between 'bands' and 'stations' with the push button selecting which menu and making the selection. (quick push changes menus, long push makes selection.)
Well written and inspiring. A
On October 3rd, 2005 jh (not verified) says:
Well written and inspiring. Almost makes me regret having become a software-only geek :-)
Great Job!!
On September 30th, 2005 Richard Kut (not verified) says:
Wow! Great job! Any plans on selling some of these to guys like me?