Introduction: Cheap, Easy Robotics for the Non-Programmer

Hey Robotics-Programmer-Wanna-Bees! Tired of trying various 'environments' only to find that there's a steep learning curve between you and those cool robot tricks your geeky friends do? Are the commercial kits too expensive? Then this Instructable is for you! I'll show you an inexpensive (nearly free) environment that'll have you teaching your robot tricks without realizing you're actually programming. OK, maybe it's not quite that simple, but by presenting you with building blocks instead of a text editor, it makes programming much simpler and more intuitive.

"Hang on," you say, "How is this different from Arduino or Legos? They claim to make Robotics easy also."

What's wrong with Legos?

Perhaps you've seen Lego Mindstorms, but aren't ready to shell out $200 to $400 for the system. This Instructable is for you since the robot can be much cheaper and simpler, yet still do fun and interesting tricks.

One of the real strengths of the original Mindstorms was the programming environment. Since it was designed with kids in mind, it provided an intuitive, graphical method of programming. (But friends tell me that it has become bloated and is somewhat intimidating in the NXT version.) I'll show you a similar, simpler graphical environment you can have for free.

What's wrong with Arduino?

If you're like a lot of geek wanna-bes, you've purchased an Arduino or some flavor of Freeduino. Attracted by the low price and simplicity of the hardware, you ordered one. You downloaded and installed the software, got a led or two to blink, looked at all the great stuff in the many libraries - and then put it aside. It was all just too overwhelming! And trying to modify somebody else's library code was simply too complex.

The Solution

Suppose there was a way to combine the inexpensive Arduino hardware with an intuitive programming environment like Mindstorms? Guess what? There is! And the software is public domain, open source (as in "free") no less. For teachers and educators, there's even free courseware. Doesn't get much better.

I'll provide a little background so you'll understand the pieces, then I'll explain how to create your own robot development and programming environment. The Graphical Programming Environment is known as "Blocos" and the robot hardware is known as "Babuino". I'll tell you all about them, how to get them, and how to have fun with them. So hang on, here we go! Babuino / Blocos is in use in Spain , Argentina, and the US .

When you complete this Instructable, you'll know how to turn an Arduino into a programmable robot controller and how to set up a graphical programming environment for it. I'll provide some pointers which will help you interface robotic hardware to your controller. In a planned follow-up, I'll give detailed instructions on hardware interfacing.

Important Note: When I use the name "Arduino" I mean not just the (not quite copyrighted) Arduino itself, but also the many public domain versions collectively known as "Freeduino". In some cases I use the term "Ard/Free-duino", but the terms should be considered interchangeable for the purposes of this Instructable.

Step 1: A Little Background

Here's an abbreviated and imperfect history of fun-to-program robotics. Back in the late 60s, Seymour Papert at MIT decided that robots should be fun. His excuse was that he wanted to help children learn, but I really think he just wanted to play himself. :)} One of his concepts was known as Turtle Graphics in which an imaginary turtle could be programmed to draw lines on the display. Shortly afterward, the idea of making a motorized turtle that could drag a pen on a piece of paper evolved. MIT got Legos involved and the first Programmable Brick (robot controller) was created. Mindstorms (name taken from a Papert book) followed quickly. A spin off, based on the work of Fred Martin, was a programmable brick known as Cricket . Most recently, an inexpensive brick, known as Babuino and based on Arduino, has been developed. The Babuino is the reason I'm writing this Instructable.

To go along with his easy to use hardware, Papert invented a language called Logo to make programming equally easy. Logo was supposed to be easy for anyone (adults included) to learn. It was easy compared to languages of the day, but still involved a text editor and memorizing syntax. Papert's collaborators created a graphical environment called Logo Blocks in which blocks representing Logo statements could be metaphorically snapped together to build the logical constructs of the robotics programs. Fortunately, Logo Blocks is much easier to understand than that last sentence describing it! Logo is now available as Cricket Logo and is the basis for Logo Blocks. Cricket Logo and Logo Blocks are both only for Windows and Mac environments. Blocos is a modern replacement running on Linux, Mac and Windows that I'll tell you all about in the sections to follow.

One additional concept is integral to the Programmable Brick and the Logo Blocks environment. To keep the Programmable Brick simple and cheap, the software that runs on it must be very simple. So the brick software knows nothing about the elegant programming environment provided by Logo Blocks. Instead it accepts single byte codes, also known as "opcodes". Each opcode translates to exactly one simple action that the brick software will perform. For example, opcode 46 might refer to Motor A while opcode 49 might turn on a motor. So the opcode sequence 46 49 would cause Motor A to turn on. The result is that Logo Blocks (and Cricket Logo also) knows nothing about the Programmable Brick; it simply generates opcodes. The brick knows nothing about Logo Blocks; it simply responds to the opcodes sent to it.

A direct consequence of this clever scheme is that new languages and environments (such as Blocos) may be developed as long as they produce opcodes as their output. An equally important consequence is that new programmable bricks (such as Babuino) may be created as long as they provide appropriate actions in response to a stream of opcodes.

Step 2: Easy Robotics Today


On the hardware side, besides Lego Mindstorms, simpler and cheaper versions of the Programmable Brick, known as Crickets , are available.  But even these are not exactly cheap. So a still cheaper brick, intended for aspiring roboticists in the developing world, was created by a team in Brazil working with the folks at MIT. There creation is known as the GoGo Board and they also created Blocos, the graphical programming environment I'll tell you all about. The only drawback to GoGo is that you have to make the circuit board and round up all the parts yourself.

The newest alternative is Babuino (wait for the link, read a bit first). The Babuino uses the very inexpensive and popular hardware platform known as Arduino (or a Freeduino clone) which can be purchased cheaply with no assembly required. You can save more if you can solder and build your own Arduino from a kit, but it's not required. And when you get tired of Babuino (as if that will ever happen!) and want to do other things, you have an Arduino! As you might quickly surmise, Babuino is just software for an Arduino. When you download it to your Arduino, it turns the Arduino into a Programmable Brick capable of interpreting opcodes. Certain pins are defined as inputs and outputs for the brick; add some simple hardware to interface motors and sensors, and now you have a very inexpensive robotics experiment system!

Babuino is the Programmable Brick half of your robotics experiment system. The other half is the software environment. We'll use Blocos (we'll get to this link soon also), the Brazilian-developed, block-oriented programming environment that makes robotics simple to program. Blocos is really easy to use. The gallery here shows 4th grade students programming Babuino with Blocos.

Step 3: Creating Your Own Babuino

To create your own Babuino you only need two things: An Ard/Free-duino and the Babuino software. Obviously, if you already have an Arduino, you can load Babuino onto it and away you go. If you don't have an Arduino, now's the time to order one. Have a look at this Wiki article to learn more about Ard/Freeduino and locate some suppliers. The simplest version is suitable to become a Babuino. You can even build your Freeduino on a breadboard . Here and here are two alternative methods of building an Arduino. But I'll provide more details in my next Instructable.

Download Babuino from the Support Forum . You need to sign up (free, easy; and if you have a Yahoo login, you're half way there), then you can access the Files Page. The figure of the Files Page shows the files you need to download. Get the Command Reference which is a complete manual for using Blocos (which we'll download in the next section) on Babuino. Click on Firmware to go to the page with the code - the Firmware Page is also shown here. Right click on the latest .hex file and save it in an appropriate location. This is what you'll upload to your Arduino.

To actually upload Babuino to your Arduino, follow these directions . Just be sure to specify the hex file you uploaded with the latest firmware, not version v01.hex. Babuino is not actually Arduino code, but can be loaded using the Arduino bootloader and does not harm the Arduino bootloader. (So when you're done with Babuino, you still have an Arduino.) To do the upload, you'll need a USB to serial adapter. Sparkfun offers a nice, reasonably priced one if you don't already have one. You'll be able to use it to download your Blocos programs to Babuino as well. If you already have your Arduino working with a serial port, it'll work just fine for Blocos/Babuino.

You should know that Babuino is still being developed, so while there'll be more features in the future, everything works that you need to make a robot go. There is active bug fixing and expansion. You can join the discussion and provide your inputs on the support forum that you just signed up for.

Babuino defines certain pins of the Arduino to do certain functions. These include controls for two DC motors, four switch or sensor inputs, a beeper, a serial port (the Arduino serial port) to talk to a pc (Linux, Mac, or Windows), a RUN button (guess what it does), a User Led and a Status Led. Just the resources needed for a small robot! The connection diagram is shown. You need to add the RUN button, the Status Led, and the beeper to your Arduino to make it into a Babuino. In the follow-on Instructable, I'll explain more about this (it's pretty simple). I'll also show you how to build an interface to DC motors (more complex). If you have a minimal Arduino with no connectors, connect Babuino resources to the processor pins as shown. Otherwise, you can use the standard Arduino connectors.

You can build an inexpensive robot platform following the instructions on this great web site which shows how to build an Arduino clone using a Radio Shack kludge board. This version includes all the hardware interface to have a Babuino. The picture shows the robot platform you can build following the directions provided. You can also keep an eye out for my Simple Robotics Breadboard Instructable (coming real soon now - really!).

Step 4: The Babuino Programming Environment: Blocos

Blocos is written in Python, so installing it is a two step process. First, download and install Python, then download the Blocos Python Program itself. It's an easy process and you can do it in either order. There's a nice discussion forum for Blocos just like for Babuino. Sometimes the same issues are discussed, but the two are separate and distinct. You'll probably want to sign up for both of them. Since these two projects are based in Brazil, some of the discussion is in Portuguese or Spanish - but there's lots in English as well. If you post in English, you'll be answered in English.

You'll find the download page here . The figure shows the page and the files you need. For all systems, download the Blocos Python program indicated. It's a tar file so you can use either 7-zip (Windows) or gzip and tar (Mac or Linux) to unpack the files. (There's also a zip file for Windows - either one works.) Create a directory for it (I called mine Blocos, but use whatever name you like.) Move the zip file into that directory and either unzip it or untar it.

For Windows only, download the Python Package that is indicated. You install it in the usual manner; you have to be Administrator to do the install. As the install proceeds, you'll have to respond to several prompts. Take the defaults, agree to licenses and mostly just say yes. You may get an error or two about files not found, but you should just ignore these. (If things don't work when you're done, then post questions to the Blocos Forum.) I have used Blocos on W2K and W7. Problems have been reported with Vista; I don't know about XP. Try it and post problems to the Forum.

To install Python on Linux, you will use apt-get in a terminal window. You will need to be super user or use sudo. Enter the following command at the prompt:
apt-get update
Then enter this one at the next prompt:
apt-get install python2.5 python-cairo python-gtk2 python-kiwi python-serial
Relax for a minute while the systems grinds away and you're done installing Python.

Installing the Python package on Mac is best done using MacPorts . Install MacPorts if you haven't already done so. MacPorts allows you to safely install software on your Mac without worry about interfering with any system software. Directions for using MacPorts are here . Following the directions, install the following in the order given: python-cairo, python-gtk2, python-kiwi, and python-serial. (I haven't done this myself. Others who have tell me this works fine.) You'll also need a soft link to your USB serial port. That'll look something like: sudo ln -s /dev/tty.complicatedName /dev/ttyUSB0 ... where "complicatedName" means the (unfortunately unique) name assigned to your FTDI cable.
(Thanks to Ian Dees for these tips on Python for Mac. Blame me for any errors in this procedure. Perhaps some Mac guru can provide more complete details?)

Once the Python Package is installed and Blocos is unzipped (or untarred), simply double click (on Windows) the Blocos.py file. In Linux (hopefully Mac also) from a terminal window, cd to the directory containing Blocos.py. Start the program by entering "python Blocos.py" (without the quotes). The programming window which you'll see is shown in the figure. The figure is annotated to show the key components of the interface. I'll give you a simple introduction in the next section. See the Command Reference (you did download it, right?) for lots more detail.

Step 5: Creating a Babuino Program Using Blocos


The figure shows a simple program in Blocos. I'm going to explain what it does, but you'll probably be too busy laughing at my explanation of the obvious to really listen. Here goes anyway. After the program is downloaded to your Babuino and the RUN button is pressed, Motor A is turned on for 2 seconds (20 tenths), then it stops and Motor B is turned on for 1 second. Being in a loop, this behavior continues until the RUN button is pressed again or the batteries run dead.

Create the program just described. Look at the other figure for more details on the Blocos environment. Simply click on a component in the Blocks Pane, move your cursor into the Program Pane, and the component will appear under your cursor. Click again to drop it, and use the Define Pane to set the parameters. Click the tabs to select different sets of program blocks. The blocks fit together to create the program. If you have any problems, read the Command Reference you already downloaded.

Once you have created the program, the next step is to download it to your Babuino. You can use the same USB to serial interface cable you used to upload Babuino itself. From the Blocos program, simply click the large Download button. Blocos will search for serial ports and will test to see if a Babuino is connected. When Blocos finds a suitable port, it downloads your program. Babuino will beep when the download is complete and Blocos will show a suitable message.

As the program is downloaded, it is stored in the EEPROM memory of the Babuino. So once the download is complete, you can disconnect the USB cable (not required, but your robot won't go far with the cable connected). You have to have a power supply (probably batteries) connected. Press the RUN button on the Babuino and your program should run. Press the RUN button again to stop the program. You can even turn the power off and back on, hit the RESET, then hit RUN again. Your program should run. You'll note that the Status Led on Babuino will blink at different rates when it is running (fast blink) and when it is stopped (slow blink).

To load another program, simply reconnect the USB cable and use Blocos to download the new code. Be sure you stop any running program (Status Led should be doing a slow blink).

Step 6: Conclusion

The purpose of this Instructable was to explain how to set up a really cheap robotics development system that's fun and easy to program. If you've followed the steps, you've turned your Arduino into a Babuino and are now using Blocos to program it. I've provided some links to give you ideas on how to build your own Arduino-based robots that can be programmed with Blocos. Besides the photo galleries I've already mentioned, you can see a Babuino/Blocos robot in action here . Your robotics experiments are now limited only by your imagination, not by your hardware and software skills.

Have fun!

Full Disclosure:

Due to my interest and willingness to help, I am now a member of the Babuino Development Team. We're an open and friendly bunch and welcome anyone interested. You should be comfortable with Atmel AVR processors and the gcc development environment.

Acknowledgments:

Thanks to my friend Brett for bringing Babuino and Blocos to my attention. Brett is teaching and developing a robotics class for elementary and middle schoolers using these. His website has already been mentioned and is well worth visiting.