Saturday, September 8, 2012


(addendum - FR3DDY got written about on Hack a Day! Awesome!)

So I've been up to some interesting stuff lately. Let me introduce you to FR3DDY.

Freddy (easier to type) is a Heathkit HERO 1 robot, model ETW-18. The HERO robot series are some of the quintessential examples of early personal robotics, and which many roboticists have drawn inspiration from, such as the White Box Robotics  group of robots (which now uses the Heathkit name), and, of course, my very own HouseBot. The ETW-18 model was the factory assembled model, whereas the ET-18 was the do-it-yourself kit.

When I was a kid, it was every nerd's dream to own one of these. But they were very expensive! Now that I'm older, and thanks to eBay, I can. They're occasionally available, but, they are all antiques. Some are in better shape than others. Freddy's in pretty good shape, but does need some work here and there.

So why the name Freddy? When you turn this old boy on, one of the first things it does is say "Ready!" in an old 1980's style, shall-we-play-a-game, War Games type voice. My girlfriend thinks it sounds like "FREDDY", so, Freddy it is, and "FR3DDY", just to emphasize the computer generated nature of it all.


Freddy saying "Freddy"!

Another thing that Freddy says from time to time is "LOW VOLTAGE", which comes out sounding like "NO CARNAGE". Coming from a robot, it's awfully nice to know that it doesn't intend to cause murder and mayhem. Freddy's a good robot that way.

"LOW VOLTAGE" or "NO CARNAGE"? You decide...

As one of the defining examples of early personal robotics, Freddy is, of course, a restoration project. First and foremost, he needs to be brought back to top running condition. And, in fact, when he came to me, he was not doing that bad. I've had to work a little on the sonar, and he's got some minor problems with the main drive wheel, and there were some missing outer side panels (since replaced), but in general, not too bad -- not too bad at all for being approximately 30 years old.

Work continues on the restoration project, but what fun is just doing that? The ET-18 and ETW-18 robots were primarily programmable in machine code, by directly entering bytecodes through the hex numeric keyboard on the robot's head. It's exactly as awful as it sounds, maybe more so! So what I did is contact this guy, who sold me an upgrade kit for the HERO BASIC ROM, plus the memory upgrade needed to support it. You also need some sort of serial or USB connection to hook to some sort of terminal. I generally use my laptop and puTTY for this. Installation was pretty simple -- it mostly just snapped in to existing ports inside the robot.

So that's cool, but, of course, not great. I'd love to be able to work with this machine using some more modern programming paradigms than a 30 year old dialect of BASIC.

I want to program it in Python.

And I don't want to have some huge wire running to it across the floor. So I'll need wifi or xbee of some sort. The problem here is, Freddy *is* a restoration project, so anything that I do has to be easily reversible, and as non-invasive to the original hardware as possible.

So enter OpenWrt. This is where the fun stuff begins! As you may know, a lot of routers these days are hackable. You can load OpenWrt, dd-WRT, Tomato, and so forth on your router, and turn a kind of clunky interface and router into a sleek, linux-driven router capable of doing a lot more than what it could just out of the box. My personal favorite for just being a router is Tomato. Unfortunately, Tomato has a read only file system, and, while it can be made writeable, it means compiling your own kernel, which means installing the toolchain, which means.. yeah... nah, let's find another route for now.

So what I did is use OpenWrt.  OpenWrt is perhaps a bit more basic than some others, as far as the interface, but it's very capable, and will certainly allow you to hack and tweak your router to how you want it, including having a writeable file system, allowing you to SSH and Telnet into the router, and allow you to install packages (through the opkg package manager).

Now, I need a router that has a serial port. Many have serial ports built in. I lucked out here -- I walked into my local thrift store, and found a WRT54GS, just sitting there waiting to be hacked! Five bucks! I grabbed it as quickly and as calmly as I could, and made for the door. I have an awesome thrift store near me, where I find all sorts of stuff like this --  and wild horses won't drag out of me where it is!

Freddy's new auxiliary brain, partially hacked

The WRT54xx models are the ones that started all of this hackable router business, and it has two built in serial ports, although you have to solder headers on them and do level conversion in order to use them. They also have several GPIO lines, although they're pretty much tied up monitoring the switches and running the lights on the router. If it's an open router thing you want to do, you can probably do it on one of these devices or one of their descendants -- although the early ones aren't so great in the memory department. (They didn't need to be -- they're just routers!)

So, after an install of OpenWrt, some configuring of the router to put it in client mode and have it automatically log into my house's wifi, allow for ssh and telnet login, and install of some packages, I now have a router that has a pared down version of Python on it, the PySerial library (to talk to Freddy through the serial port), and minicom (a hyperterm type program), nano (because the vi editor irks me), and is running BusyBox Linux.

Freddy's router up and running, logged in remotely via SSH, and doing some communication tests

Using the arduino software's built in serial port monitor, I can respond across the router's serial port

Plenty of this was needed - that really is the size of a soup bowl!

This is the same - or better - than some less capable and more expensive boards I've played around with in the past, such as the TS-7800 -- and with wifi, two serial ports, five ethernet ports, and a bunch of GPIO lines built in. Ready to be hooked up to Freddy!

The router, with wires soldered onto the serial port headers, 
and a USB FTDI Pro from CKDevices on port 0, and a BrainStem MAX232 level converter on port 1.

Some soldering on the router, and I have wires coming from the serial ports. Information on how to solder serial headers to your WRT54G, as well as a lot of other information about the WRT54G router, can be found here. Max232 serial converters can be found a lot of different places, but the one I used for this was the BrainStem level converter from Acroname Robotics. Serial port 0 (/dev/tts/0) is the debug port, where you can see the router boot sequence, telnet to a shell, and so forth. /dev/tts/1 is free to use, so, I can talk to Freddy on that, using either minicom, or writing programs in Python which send commands to the serial port. I could also hook up another device on /dev/tts/0, such as an arduino to run some sensors, but the arduino would have to be tolerant of the stream of data coming from the router during bootup -- probably by waiting for a specific code before it started interacting with the router.

So good enough, we have a little computer that runs linux, has wifi, and has Python installed on it -- although not all the batteries are included, as the Python philosophy would have us do. As you might surmise, the router doesn't have a whole lot of space on it, and after installing the bare minimum I need, I only have about 1.5 MB free. Fortunately, you can expand the storage it has by using an SDIO card, but that's a project for another day.

The next thing to do is to install this in Freddy, with minimal to no impact to the original machinery. The router normally runs off of 5 volts at 2.5 amps, but a little experimentation proved that it could do just fine on less than half that amperage. I assume the antenna output is less, but so far haven't seen any problems with it. What remains is to find a steady source of 5 volts on Freddy, plug up the serial port, and find a place for the router to live.

Always good to have handy...
A little bit of experimentation, and I found that the main processor board had a nice supply of 5 volts at a reasonable amount of amperage, and running the router off this line did not interfere with the main board in the robot.

If you blow a fuse while experimenting, wrapping it with tinfoil to make it work again is not the correct solution. This is a bad example and you should never do this. (it sure works in a pinch, though!)

Next was finding a place to mount the router. I had hoped to find a place on the lower chassis to mount it, perhaps with a little velcro, but the router was too thick. I ended up mounting it in the head, underneath the keyboard.

This almost worked out, not quite...

The router, mounted under the keyboard

The cover on, and the wire to the serial port hooked up

All put back together, my cat gives Freddy an inspection

And there you have it! A ~30 year old robot, accessible through wifi, capable of running Python (not to mention a built in, extendable web site run by the Lua programming language), and with minimal impact to the original hardware!

Just to watch it work, here's a demo of Freddy running a short Python script.


And here's the code:

import serial
from serial import *

import time

port = Serial(port='/dev/tts/1', baudrate=9600, bytesize=SEVENBITS, parity=PARITY_EVEN, stopbits=STOPBITS_ONE, timeout=1,  interCharTimeout=0.25)

def read():
 result = port.read(port.inWaiting())
 return result
def wait():
 i = 0
 while port.inWaiting() == 0 and i < 100:
def write(line):
 for c in list(line):

def writeln(line):
 write(line + '\r')

def execute(command):
 return read()

def get(command):
 result = execute(command)
 return str(result.split('\r\n')[1])
execute('dprint "$hello"')
execute('speak 64709')
execute('dprint "$freddy"')

print "run complete."