8 November 2008

The Arduino Diecimila

Gadgets are guaranteed to give geeks a special tingly feeling, and robot controllers are a very special type of gadget. Was it William Morris who said that nothing useless can ever be truly beautiful? Whoever it was, he was spot on. By that definition, Robot controllers are immensely beautiful. What's more, they're not difficult to get into, and thanks to the open source hardware movement, they're an amazingly cheap method of making intelligent objects. Robot controllers typically contain tiny amounts of RAM, but because you're not fannying about trying to hoist a pointlessly resource hungry translucent user interface onto a graphics card that can outperform an 80's supercomputer, you don't need that much memory to do complex and genuinely cool things. Robot controllers also have plenty of input/output lines built in, waiting for you to poke the wires from sensors, buzzers, motors etc. into them to give your creation (whatever it is - and it doesn't have to be a robot) a sense of where it is, what's going on and how to control itself in the world. The rest is down to your creativity as a programmer.


I've just bought the Arduino Diecimila robot controller for just £17.60 from Cool Components. To the untrained eye, it looks like a very small and boring interface card for a PC. It's not. It's a full computer with some very special qualities. The chip at its heart is an Atmel Mega168, for instance. This is an industry standard microcontroller, which is basically a complete computer on a chip. It runs at 20MHz and, because it has a simple yet very comprehensive instruction set, it delivers a full 20 MIPS. The chip has 16K of non-volatile RAM on board to store its programs, 1K of volatile RAM to store variables while it's running, and 0.5K to store data when it's switched off. So, it can maintain a persistent state between battery changes - ideal for a robotic pet, wouldn't you say? but isn't the lack of RAM a problem?


No. Seriously. By programming like a real programmer, you can fit one hell of a lot of functionality into this beast. Think about it: you need to store a true/false (boolean) value, for example. Why would you need a 4-byte word to do that? Why not designate one byte to store 8 such booleans? See? Real programming; "tapping on tin" as they used to say is how it used to be done, before Windows came along and PCs became bloated playthings. Who actually needs an Intel Quad Core processor to read their email, for crying out loud?


Sorry, I got a bit ranty there. Anyway, by thinking like a proper programmer, the amount of "mind" you can squeeze into a microcontroller is phenomenal and the RAM seems huge. Want proof? Hundreds of millions of microcontrollers are used in car manufacture every year. They control everything from the dashboard to the injector system. They decide whether to deploy the air bags and tell the mechanic whether the wheels need balancing at service time. Your car may contain several dozen of them.


Everything about the Arduino Diecimila is open source, including the hardware. You can, if you wish, download the plans from the Arduino homepage, buy a Mega168 (they're around £3 retail!), a few resistors, capacitors and wires, solder the lot into a bit of veroboard, and hook it up to the serial port on your PC. You can program it directly from there using the free AVR Studio suite, which gives you the industry standard GCC C compiler, and a superb macro assembler if you want to get really code efficient. It also has a full simulator for a range of Atmel chips so you can test your code properly before squirting it onto the chip and watching it control your creation.


The Arduino Diecimila has 20 I/O lines. 6 can take analog inputs and convert them into 10-bit binary. 6 of the ports will do pulse width modulation, making them ideal for directly controlling servos. The others will accept things like infra-red diodes and photo-resistors directly, and have such high impedence, touching the end of a wire connected to them will cause the input to go high (ideal for touch sensors).


What's more, the Arduino Diecimila has a USB interface. This is used to program it, but there's also a library enabling you to write from the unit to a USB pen storage device. Is that enough non-volatile RAM for you?


So, what can you do with a robot controller? Well, the obvious thing is to make a robot, but there are plenty of other possibilities. I'm interested in making what I call an intelligent object; one that reacts intelligently to it's surroundings and to your interaction with it - a digital pet that goes WAY beyond the idea of a Tamagotchi, for want of a better phrase. One that learns from physical interaction. So far, the design can see light and infra red, it has a basic sense of touch, it can sense its orientation (and any movement), and hear basic sounds. It has light, sound and vibration as outputs at the moment and there are plans to give it a small LCD screen. It doesn't even move yet under its own steam, but the plan is to mount the sensors on a kind of "head" that sits atop a servo motor so that it can turn.


I'll be posting the results of my experiments over the coming months, and hopefully I'll have something basic running to show you soon. It's a big project and something I've never contemplated before, but I'm not doing it because it's easy. J.B Priestly once said that the secret to happiness is to be busy with unimportant things. I'm beginning to see what he meant.


P.S: I have no idea why the formatting of this post is different. I've tried everything. Sod it. Life's too short.


Stumble Upon Toolbar