Posted by Elecia White.

 

On last week’s show, Chris and I talked some about some new processors we are using so it was interesting to get listener email asking why we use different processors. The listener (who requested anonymity) said:

 

I'm trying to grok what would make me want to switch off Arduino (besides perhaps the parents fighting... ignoring that, just looking technically).

 

In case you wondered about the “parents fighting” comment, the two teams that created Arduino are fighting about trademarks. It is frustrating to me that this open source, educational company, which makes amazing things for people, is fighting over money. I know it is naïve but I am this close (holding fingers quite close together) to never recommending an Arduino board again, even to beginners.

 

However, the Arduino UNO has been my go-to board for beginners. The easy start-up makes for a good initial experience and the large number of libraries gets home/garage projects off the ground quickly. But to stay on it? The Atmel ATmega chip is a good one but there are so many others. And so many reasons to choose something else: power (current consumption), different peripherals, built in functionality, more processing, more RAM, more flash, size, cost, ease of programming in manufacturing, etc.

 

These depend on what your goals are. Our listener did give a hint about herself:

 

I've made an Arduino Shield (..and...surprise and WHOA...it works :-) ). I mention this to give an approximate idea of my current skill level.

 

A later email also mentioned going through Chris Gammell’s wonderful Contextual Electronics, learning to layout and build a board (I’ve been meaning to do that myself). She continues,

 

I'm hearing conversations about different microcontrollers and platforms. Are there clear (technical) differentiators that would make a different microcontroller (than used by the Arduino) a much better choice within (certain) scenarios? If yes, what scenarios?

 

I’ve been working on some wearable consumer products lately. For one, I needed a fast prototype that could be worn. I chose the RedBear BLENano as a platform. I could have used an Arduino with one of the many BLE shields but it would have been much larger (and less power efficient, so I’d need a bigger battery as well as larger boards). Also, why have two processors if I don’t have to? The BLENano uses the Nordic nrf51822, a processor I’ve used before so I was familiar with its Cortex-M0 with built in Bluetooth Low-Energy (or ANT, a protocol that lots of health and sports gear uses). The BLENano is an mbed™ device which means it has a free online-compiler. It is similar to Arduino, actually: easy to set up, lots of available libraries, debugging via serial port.

 

When I previously used the Nordic nrf51822, it was in a product with a client’s custom board. I used the Keil compiler to build the embedded code along with a debugger. Here is where things might change for our listener. Debugging over serial is fine. I mean, it is ok. However, a real debugger, even one with only a few hardware breakpoints, means getting to walk through code and look at variables. It is so nice. It feels like a luxury vacation after trying to debug interrupts via printf.

 

Such luxury comes at a price: about $100 to get a dev kit with the necessary parts for my nrf51 part. Given how much my time costs to a client, that is a fair deal: I save a lot of development time by being able to look at the variables and registers as I walk through the code (aka “on-chip debugging”). Is it worth it to you when you are doing a home project? It very much depends on just how stuck you are with a problem.

 

You can do on-chip debugging with an Arduino UNO: get an AVR debugger, set up GCC or other compiler to cross-compile (to target the Atmel processor instead of your computer), and start using the board without the Arduino interface. (I know how to do Linux and Windows, I think Mac would be similar to Linux.)

 

The Arduino UNO has the Atmel ATmega328 on it. It is an 8-bit processor with 14 digital inputs/outputs (6 can be used for PWM, 6 can be analog inputs) and a 16MHz clock. This processor is relatively small, all things considered. Sure, it is fine for blinking some LEDs, maybe running a motor or two but if you want to connect via Bluetooth or WiFi you’ll need another whole processor to handle the communication layers. It is inefficient from a parts-cost, size, and power perspective. Like the nrf51288, many BLE and WiFi SOCs (system-on-chips) allow users to run their applications onboard the communications processor.

 

Other processors may also have DSP blocks that speed up signal processing or better PWM blocks that allow for complex and fine-tuned motor control (oh, TI DSPs, I do miss you sometimes). You may want more IO pins. Or you may want far fewer and to have a much smaller board. (Though if you enjoy Arduino, do check out the Trinket and Arduino Micro.) If you are making light up clothing (shoes, jacket, bike helmet, etc.), you probably don’t want or need to carry the full Arduino board in a pocket: size matters.

 

Or you might also want to consider cost. If you are conducting a class or making a kit for other people, paying ~$20 for a board can get expensive. If you are willing to use a non-Arduino interface, the STM8 Discovery boards are only $7.  This board’s processor is a slightly less capable than the Arduino UNO ATMega processor but it is close.

 

More likely, though, after you add lights, motors, speakers, and all sorts of sensors, you’ll find the Arduino just isn’t big enough for what you want. You won’t be able to compile as linkers say the code won’t fit, you’ll get crashes because there isn’t enough RAM, or things will just not happen when they are supposed to due to too few clock cycles. You could spend a lot of time optimizing your code: re-writing libraries to remove floating point, getting rid of debug printfs because they take too long to execute, or tweaking your code to stretch the RAM or cycles.

 

Alternatively, you can take an easier path and move up to something larger. The mbed boards are all ARM core boards (mbed is owned by ARM, vendors who use the ARM core to make their processors can make mbed compatible boards, utilizing the online compiler). This has many advantages as our listener had already determined one of the downsides of moving away from Arduino and mbed platforms:

 

I added the ADS1015 ADC. Adafruit had a breakout board, library, wiring diagrams...my goodness...I totally support Adafruit for this level of guidance!...would I get that level with another microcontroller and its platform? Would I have to start at writing a library that talks to the ADS1015 directly (i.e.: parse through the datasheet to build up read/write/control commands)?

 

The mbed might have libraries for you (many are written by community members such as yourself). In general, processor and peripheral vendors are starting to provide more driver libraries, apparently learning that embedded software engineers are as lazy as cats. But, yeah, I read datasheets (ooh! Embedded.fm t-shirt idea!). Sometimes I write drivers from scratch. It is tough the first two or three times, then you get good at it and it is just another skill.

 

Writing drivers and application code, I spend a lot of time working on ARM Cortex-M0 and Cortex-M3, though not necessarily with the mbed interface, usually using IAR or Keil compiler and IDEs (debuggers, yay!). Projects that are more complex might require going to the beefy Cortex-M4F (with floating point built into the hardware!). The Cortex series is popular with people making power efficient (i.e. battery powered), inexpensive devices in large quantity (i.e. consumer). Their ubiquity drives the cost for compilers and debuggers down.

 

If your processing needs move up far enough (or you dislike drivers enough), you may find yourself in Raspberry Pi land (in which case, element14 is a wonderful place to get started). Those are essentially small general-purpose computers. They are extraordinarily capable, often have Linux drivers already written for you, and remarkably easy to build code for (python! Scratch!)… but you’ll need a larger battery.

 

Thus, the processor continuum starts with tiny chips (ATTiny or STM8 or MSP430) and goes all the way to miniature desktop computers. There are many technical differences between various MCU products. As someone learning about hardware and microcontrollers, you probably look at the Arduino and say, “what can I do with this?” That’s only going to last for a little while. Someday soon you are going to see a problem and say “what do I need to solve this?”. When that happens, the Arduino UNO may no longer be the right answer.