2013-07-29

Domo Arigato, XBotMicro

From the last Boxtec Freaky Friday, I brought home a purchase I was particularly eager to unwrap: The XBotMicro, a small, Swiss-made robotics platform.

First Impressions

The XBotMicro comes fully assembled, with a set of jumper wires, a handful of plastic standoffs and screws, and a manual in passable, though not always entirely idiomatic, English.


The hardware appears to make a really excellent beginner’s platform:
  • Motors and motor drivers built in, just require two microcontroller pins each side to drive.
  • Front equipped with solid mechanical bumper sensors.
  • LEDs for motors (green/red for forward/backward indicator) and bumpers.
  • Built-in LiPo battery, reportedly good for 2 hours’ driving. Very simple charging circuit—if the + pin sees a 5V voltage, the battery gets charged, otherwise, the battery voltage gets applied to the + pin to drive the installed microcontroller.
  • Easily accessible power switch—one would think this is a complete no-brainer, but some robotics platforms, e.g. the SparkFun ProtoSnap Minibot Kit, require removing the battery to stop the motors. 
  • Separate motor switch: This is a really clever feature allowing a dry run of the programming by observing the LEDs, without powering the motors.
The battery comes pre-charged, and the manual contains a sketch to make the XBotMicro drive forward without needing a controller (although the included jumper wires are too short to implement this sketch).

Adding a Microcontroller

Naturally, for any nontrivial task, one would want to install a microcontroller. At first glance, I thought that pretty much any Arduino board would do—the XBotMicro certainly looks mechanically compatible with them. However, the devil is in the details: When operating in battery mode, the microcontroller has the LiPo battery, typically about 3.7V, available.

The manufacturer of the XBotMicro makes the Diduino, a rather neat Arduino clone with a built in breadboard. While the Diduino works with 5V, it does not have a built-in voltage regulator, which makes it unsuited to input voltages greater than 6V, but gives it much more flexibility toward LOW input voltages, so the Diduino would work well with the XBotMicro. There are also a variety of 3.3V based Arduino boards, most of which should also work.

Update: It’s been pointed out to me that 5V Arduino boards should also work, as long as the input voltage is applied to the 5V pin, not the VIN pin, thus bypassing the voltage regulator.

However, none of the Arduino boards I currently own are 3.3V based, so I had to think of another alternative. I ended up putting a self mini breadboard on the XBotMicro and installing an ATtiny84 on it. Since I already hard the Arduino-Tiny core installed, it was quite simple to adapt the demo code to the ATtiny84 and program it using ScratchMonkey. The breadboard has enough room to even implement a dual-ATtiny84 controller solution if I were to need more processing power.

A Minimalist Controller

Once I had this running, I could not leave well enough alone: Why waste the 12 I/O pins of an ATtiny84 on running the XBotMicro if I could save several cents and use an ATtiny85 instead? The ATtiny85 has just the 6 I/O pins needed to drive the XBotMicro (4 outputs for the motors, 2 inputs for the bumpers), provided the RESET pin gets disabled. This requires programming the ATtiny85 using the High Voltage Serial Protocol, but ScratchMonkey handles this just fine, and indeed, the ATtiny85 is perfectly capable of driving the XBotMicro:


Room for Improvement

It would be quite unreasonable to expect a brand new product like the XBotMicro to already be perfect in every way, so here’s a few minor suggestions for improvement:
  • The language of the manual is not always 100% clear, and there are some typos.
  • I was a bit confused about the A0/A1/A2 pins, initially thinking they were alternate pins for the bumper sensors. The schematics in the documentation are not very clear on that point either.
  • The included jumper wires are very short; perfectly sized if an Arduino board is installed on top, but not very flexible for other pinouts.
  • The demo code is written in French and is structured a bit awkwardly. I’ve taken the liberty of merging it into a single file and translating it into English.

Demo Code

Here’s my version of the demo code, with pinouts for ATtiny84 and ATtiny85 added (in fact, the code is less than 2K, so you could save a few more cents and run this on an ATtiny25, but I didn’t have any at hand).



2013-07-05

Using the Arduino IDE with CrossPack

As I’ve started exploring some of the more exotic members of the ATtiny family, I have increasingly been clashing with the fairly old AVR toolchain included in the Arduino IDE. I understand that there is little upside for the Arduino project in upgrading their tools: The current versions support the ATmegas on which official Arduinos are based just fine.

There are, of course, a lot of people simply using avr-gcc and avrdude with makefiles and generic text editors, but personally, the Arduino IDE suits me just fine for most of my projects.

After a few months of replacing bits and pieces of the toolchain, I’ve arrived at a more principled approach, based on CrossPack, a well maintained distribution of up to date versions of the AVR tools for OS X, including patches for the latest processors. After installing CrossPack from the web site, the following script will replace the toolchain in the Arduino IDE with a link to the CrossPack toolchain: