Monthly Archives: December 2011

Netduino Thoughts

I picked up Netduino a couple of months ago but didn’t find any time to play with it until the holidays. As somebody who has done a few projects with microcontrollers (most recently Atmel AVRs) and as a C# design team member, I found it to be an intriguing idea – to be able to write code for the microcontroller in C#, and to be able to debug it with Visual Studio.

The executive summary is that it works pretty well overall. Once you’ve installed what you need, it’s just a matter of plugging the netduino into the computer with USB, starting up VS, creating a project, and you’re off and running – or debugging.

There are some deployment issues from time to time; the deploy will hang and you’ll need to pull the USB out to power-cycle the netduino and try again. It’s also possible to temporarily kill the netduino if you do something unsupported – like use unsafe code – and you’ll have to use the micro framework tool to reset the netduino. So don’t do that.

Upsides:

  • It works pretty well. You write code, set breakpoints, and it all runs on the microcontroller.
  • VS works the way that you would expect it to.
  • The hardware support appears to work as expected, at least the SPI and button interrupt handler that I used worked fine. Once I remembered to hang onto a reference that I passed to the interrupt handler.
  • Purportedly, it’s all open source, so you can add new code if you want.
  • Floating-point

Downsides:

  • There is no JIT solution, which means the IL is interpreted. 48MHz, even with 32 bits, is not a lot of horsepower to be running a managed environment. Which means it is *slow*.
  • The C# language is not a good fit to the kind of things you want to do with a microprocessor. Properties, which are pretty much free due to inlining on the desktop, are not free at all on the netduino. The expression-evaluation rules – where all calculations are promoted to int – are not great when you actually need to deal with bytes. The advantage of C# on the desktop (and on the phone, to a lesser degree) is that the runtime takes care of a bunch of things that don’t matter. But on the Netduino, you often care about those things.
  • No timer interrupts. At first I thought that this was a deal-breaker, but it turns out it doesn’t matter – the execution speed and the non-determinism of the GC means that you aren’t going to be using the Netduino for real-time stuff *anyway*, so the timer interrupts wouldn’t be very useful.
  • At $35, it’s fairly pricey, though not really much pricier than an Arduino. With Arduino, however, you can pull the chip (at least if you have the DIP version) and replace it for a few dollars.
  • The community is a bunch smaller than the Arduino one.

Summary:

If you’re a C# developer and you’ve never played around with microcontrollers, the Netduino is a pretty good introduction, and is capable of handling a lot of simple projects. If you’re an experienced microcontroller developer, if you need speed, or if you’re trying to do anything real-time, I’d recommend looking elsewhere (Arduino or just a raw AVR).