Microcontrollers can drive anything from watches and tiny MP3 players to industrial control systems and sophisticated robotics, so the opportunity to write C# .NET code on a small and cheap microcontroller is very exciting. In April 2008 I wrote an article comparing the .NET Micro Framework to Robotics Development Studio (RDS), since they are both used for driving robotics applications. RDS requires at least the Compact Framework, which in turn requires Windows CE hardware, which is a good deal more power-hungry and more expensive than tiny microcontrollers that can cost as little as a few dollars each (in bulk, developer kits go for $35 and up).
You may have heard of the popular Linux-based Arduino microcontroller prototyping boards. These boards have standard ports for plugging in other boards (called shields) for adding functionality such as motor and servo controllers, sensor input expansions, radio communications, and much more. These are really cool boards, but being a spoiled .NET developer myself, I haven’t been strongly motivated to program without my beloved Visual Studio tools, and hitting the steep learning curve of Linux development just never happens during the little free time that I have.
Fortunately, there are now some .NET Micro Framework boards that are Arduino board compatible, providing you the comfort of .NET development with the ability to use any of the Arduino-compatible boards that are out there. Netduino is a popular, low-cost ($34.95), open source option that makes it easy for any .NET developer to get started. Another great Arduino-compatible option is the FEZ Domino board from TinyCLR.com. It’s more expensive than the Netduino ($74.95), but also more powerful.
I’m also a big fan of Phidgets boards, which are USB and therefore very easily extensible for those unfamiliar with the various microcontroller communication standards. I wrote an article on Phidgets Robotics Programming where I built a pan-tilt camera system controlled by a Wii remote.
Since I enjoy working with robotics applications so much, I decided to try out the FEZ Mini Robot Kit for $149.95. This is a great kit for beginners as it includes all the tools necessary and can be assembled within 15-20 minutes. It uses the FEZ Mini board (included with the kit) which is an astonishing 1.1” x 1.9” tiny. When not being used in the robot, it would be ideal for my own custom MP3 player as well.
The robot kit instructions are a bit rough: lots of pretty bad spelling and grammar errors, but the assembly instructions are easy enough to follow. The worst part is the code. Getting the various sensors, motors, and other things to work properly requires that you download individual C# files from all over their website: the reflective sensor code is found on their reflective sensor product page, and so on. Stitching this all together and correcting mistakes took me a while. It’s also evident that the folks writing this code are not fluent C# developers. By the look and feel of things, they’re probably used to low-level assembly and unmanaged C development.
To save you some pain and discomfort, I’ve gone ahead and rewritten all of the drivers for all the components involved, and have reorganized it from the perspective of someone who’s been writing business applications in C# since .NET 1.0. I’ve reshaped the API to look and feel a lot more natural to those unfamiliar with the gory details of pulse width modulation (PWM) and similar protocols. And instead of delivering individual code files scattered across a website, I’ve packaged them all in one place as a Visual Studio 2010 solution, which you can download here:
Have fun developing!
Here’s the robot in action: