Monday, 30 July 2012

Domo Arigato, Mr Roboto

I apologise if my first post was incomprehensible to non-technical people. I did try, but it's not easy to accommodate an audience ranging from university Electronic Engineering lecturers to drama graduates - I'm torn between getting lost in jargon and getting bogged down explaining what things like SSH are. I suppose I could provide some hyperlinks?

When I ordered a Raspberry Pi I was told I'd have a six week wait, but against expectations I got it 10 days later. The trouble is that I ordered parts with long lead times, thinking they'd still turn up before the RPi, and a lot still hasn't turned up. Two key components are missing - a power supply and an HDMI-DVI adaptor. I think I can use my iPad charger temporarily, and get by with composite video to our aging telly, but I've not had time to try yet due to spending the last couple of days being ill and a dad.

Ooh I see evil...
I've been thinking some more about a robot project, though at this stage it's still about checking feasibility and costs without too much detail. The RPi will be the heart of it, connected by the GPIOs to an off-the-shelf motor controller, possibly via something to protect the RPi, that much is straightforward. As I see it there are two main problems to solve: connectivity and power.

The robot needs to provide some kind of remote access to the RPi for a telnet or ssh session, and preferably a fast enough link to send back real-time lo-res video. Wi-fi seems like an obvious choice for this but the RPi isn't designed to support most USB Wi-Fi dongles without a powered hub. It's designed for "low-power" devices, taking no more than 100mA - the "unit load" in USB 2.0. The polyfuses used on the USB ports are rated at 140mA, and they have quite a bit of resistance so at high currents the voltage supplied can drop significantly below 5V. You can perform what's called a PiPass, short-out the fuse with a small resistor, but I'd rather not solder stuff directly to my RPi if I can help it and reckon fuses are generally added for a good reason. So my options are:
  1. Find a Wi-Fi dongle which draws less than 140mA, can tolerate a supply drop of about a volt, and has a linux driver compatible with the RPi's ARM processor.
  2. Use a Y-cable to connect to both USB ports.
  3. Feed external power into the Wi-Fi dongle.
  4. Use a different type of connection.
Would a low-power dongle compromise on range and signal strength, so drop-out more easily? I'm yet to find one which I'm certain will work. I recall reading somewhere that Y-cables violate the USB spec and I'd kinda like having the other port available, so I'm leaning towards option 3. What's needed is effectively a mobile 1-port powered USB 2.0 hub. Could I put together something which supplies the power without knackering the signal integrity of the data lines? As the data lines are a twisted pair I guess they're completely independent of the power rails, but is the shielding connected to ground? Though it should be a short trip from the RPi's USB port, over a cable which is maybe 10cm long to a new port, at 480 MBit/s does it still have to be treated as a transmission line with matched impedance? Perhaps I'm just being paranoid and it'll be a cinch, but I'd better dig out the spec to answer some of these questions.

Ideally everything would be powered off a single battery pack. The RPi can be powered over GPIO, it needs a steady 5V supply and can draw up to 1.2A. The motors I'm looking at each take 6V and have a 360mA stall current, and that's just for the low power versions - HP ones stall at a whopping 1.8A, though if I could provide that the extra speed/torque would be tempting (200cm/s? Practically light speed). Power also needs to be provided for the motor controller and connectivity in whatever form it might take. Will four AA batteries be up to the task? Rechargeables can do about 2500mAh, I doubt I'd get much more than an hour out of them even if the power were consumed really efficiently, but it'd depend on how much work the RPi was doing and how much the motors were moving. As a battery drains its voltage can vary quite significantly, so I'll have to use regulators and if I do that I might as well go with something mightier and step it down to the right voltage(s).

So I'm looking at putting together a custom board to do those things. Though I might be able to get away with one voltage regulator, I expect I'll need two - one giving me 5V for the RPi and the extra USB power, the other giving me 6V for the motors and controller. The RPi will need a switched supply to keep a nice, steady voltage, I might get away with a linear regulator for the motors but if there's a controller on the same circuit I'd have to check that could take a voltage drop, and a switched supply would be more efficient, helping prolong the battery life. I'd also like to detect when the battery voltage is getting low so I can cut off the motor power, with luck keeping the RPi up long enough to shut down cleanly.

Making a board like that should be well within my abilities. At college our end of year one project was to make a switch-mode power supply, and though IIRC I only got a C that was pretty good for the marker I had. That was running off the mains, so it had a step-down transformer and rectification which I wouldn't need for this project where it'd be DC-DC. My worry is that as I've gravitated towards digital electronics I've learnt a lot of theory but not really had much experience with boards or more practical considerations like impedance matching, decoupling capacitors, etc. Still, half of the point of this project would be to re-acquaint myself with all that stuff.

Once I've recalled enough of my college education to pick the right resistor and capacitor values, I'll just need a stack of soldering kit, bit of Veroboard™ and a bunch of components, just like the good ol' days. Then I need some time to spend on it. If Micro Men is to be believed Steve Furber single-handedly soldered the Acorn Proton prototype overnight, but the guy's a god among men. Still, once I've finalised the design I should be able to put it together in a couple of hours I reckon.

I'm also wondering how to make it more than just an over-complicated RC car. It'd be good to add a camera, even if that proved to be no more useful than helping me find things I'd stored under the bed. It'd be really good if the robot could process the images and do its own path-finding, but creating a model of the world off a single camera is pretty hard. I could add a pump and a bag for the world's smartest Roomba™? That reminds me - anti-stair sensors might be an idea as that's how my BigTrak met its demise...


Finally, I was thinking about naming the robot. For some reason "Harvey" sprang to mind immediately, I've no idea why. It'll be a wall-banger of sorts I guess. I also like "Joey", after the robot from Beneath a Steel Sky who starts the game as a small card and gets inserted into different chassis as the plot progresses. There's also "Nigel", the robot from Gozilla: The Series who gets destroyed every episode. Any other suggestions welcome.