HOW I DID IT: I’ve had an iPhone for about a year now, and find it quite indispensable. It’s handy in so many situations, and fits into a lot of nerdy stuff I do. However, it hasn’t fit in perfectly to the main nerdy thing that I like to do: Fly radio control airplanes and helicopters. For that, I use a really high quality piece of hardware from a company called JR, a JR 9303 radio. It works great. However, one day it occurred to me, how cool would it be to use my iPhone to fly my RC stuff? The answer was “So cool” obviously. I tossed around the idea for a couple of months and ultimately gave up on it because the iPhone doesn’t have a receiver I can put in the airplane to fly it with.
So the idea sat untouched while I learned how to program stuff on the iPhone for other nerdy purposes. My roommate requested I make a chadwick balancer for him using the accelerometers. (For those who don’t know, this is a device they use in real and model helicopters to find out if something is not balanced. Main blades, tail blades, shafts, gears etc…) While I was learning about the accelerometer functions in the iPhone, the idea pinged me again, and I thought, How cool would it be to fly an R/C model using the accelerometers inside the iPhone?! Alas, still no receiver.
IMAC Season came and went, and so did indoor season. I was busy practicing for contests I knew I’d be beat at, and building planes I knew were way to good for me. =) Then, one fateful day, I deleted some PHP program I was working on by accident. This was a LOT of work, and I was exceptionally pissed off about it. I was distracted by some girl in my bed (Don’t EVAR program PHP with a girl(s) in your bed!) and maybe a beer or six in my blood. I was writing a series of test programs for a SOAP interface, and had named one of them 8.php. (The more seasoned nerds among you can probably see where this is going). The program had turned into a complete disaster and was causing “internal server errors”, and I wanted to delete it. While girl was yammering in my ear I typed rm *.php instead of rm 8.php, and hit enter. Deleting every php file in the folder. Hours of hard work gone into the void.
The next day I went and bought a time capsule from Apple so this would never happen again. The side effect of this was that I had a Linksys 54 to play around with. I always had this grandiose idea of building a WIFI sniffer/jammer. I figured there may have been some people playing around with these routers. And gosh, was I right.
The DD-WRT project is a group of people who have reverse engineered many popular brands of routers and have managed to load a small linux distribution. As soon as I saw that they had independent programs running, it hit me like a bolt of lightning: My planes and helis don’t need a receiver if they are carrying around the server. If I could carry around the router on board, I could fly my stuff.
So I started scheming. There were a lot of problems to be solved, and I am only just so nerdy. I made a list:
So I had my basic idea down. iPhone joins the Linksys router network. It gets an IP address. Then, I open up my pilot program. The pilot program interfaces with the router via SSH (I couldn’t think of a better way that has redundancy, and speed, and was already buily by someone else). The pilot program interprets what the iphone is doing, and outputs data to one of the ethernet ports of which there are conveniently 4. Rudder, Ailerons, Throttle, Elevator.
Once I had that idea all drawn up, I said “great, I’ll file this in the ‘projects I’ll claim to have come up with once someone else does all the work’” file. However, my friends and roommates kept egging me on, especially as more and more of them got and loved their phones. They wanted to be able to fly stuff too! Just to say they can.
So the first order of business was to come up with a user interface for the iPhone to fly things with. I know how my JR Transmitter works, but it’s a whole different beast: it has sticks and buttons. So, I came up with a simple “flight interface” for the iPhone. It’s sinfully ugly, but brutally functional. It has a couple of things that I felt were important:
The program itself wasn’t too hard to make using Xdev, the iPhone/OS X development suite. The interface was pretty easy, but there was a lot of code behind tapping all the accelerometers at once. To further complicate things, how I tilt the phone may be different from how someone else tilts it.
There were some major hurdles. While range testing one night, I received a call from a girl. She was pretty insistent on me going to a party or something. So now I had two huge problems, incoming calls would kill the link to the craft, and I had to figure out if I had any clean clothes without R/C Logos on them to wear out.
The other problem I ran into was that the Linksys router can actually work on a lot of different voltages. Ironically, it’s very happy at nine volts, the max output voltage for the Castle Creations Castle link.
Finally, you may ask how the servos are being driven. Well, routers are used to send bits of information down a series of twisted pair wires usually. Guess what it takes to send packeted information? An IC that would work really well as a PWM! I did some haxoring around on this, and read what other nerds had done on the internet, and the next think you know I have a servo with a Cat5E plug on the end of it. Below is a small video I made of some of the earlier tests, the first real successful flight test, and an interesting near miss at the very end.