Microcontrollers in a Raspberry (Pi) Flavored World?

Microcontrollers in a Raspberry (Pi) Flavored World?

A couple of dc501 members have been playing with the hugely successful, incredibly popular Raspberry Pi machines. One member, Kwadroke of the Wired, is planning on using RaspPi for the heart of one of his many custom arcade systems. (Picture of Raspberry Pi courtesy Kwadroke).

All the local interest and global buzz regarding this nifty little single board computer (yeah, there was a time when that was a big deal) has sparked a number of questions directed my way. With the exception of “what do you mean, ponies?” they can be summed up basically thusly:

“Why in the world would you use a microcontroller in a world where the Raspberry Pi is only $35?!?”

Wow. A gazillion reasons. (BTW, really? my spell check flags “microcontroller” but not “gazillion”? TF?)

The thing that makes computers most awesome is that they are the only machines without a purpose. Read that again, and read it correctly: without _A_ purpose. They are multipurpose devices. A processor runs code, and that code can be anything. The history of engineering and technology is a history of specialty; however the most useful tool we’ve ever developed is one that’s a generalist.


Kwadroke’s Pi up and running

Even with that in mind, computers are like other tools. There are differences, of course, and it comes down to the right tool for the job.

Let’s see where the Pi loses to discrete microcontrollers:

Size

The parts keep getting smaller. And I keep getting older. And the laser etched chip markings are so hard to read. Arg. Enough cranky old hacker. Chips are small. I’ve done projects that use SOT23-6 microcontrollers to do stuff in the field. Yeah, battery powered stuff in the field that does stuff for people who work in the field. And that’s all I can say about that. Now admittedly you’re not going to cram an OS into that part, but if you just need something to run some simple code, there you go. Tiny and computing.


uC powered ‘SmartBar’ LM3914 replacement

Even going with some horsepower, discrete microcontrollers are very small. Need some processing power in a cosplay prop? Discrete uC. I can even teach you how to solder TQFP packages by hand. Seriously, I can. Give me a shout sometime. Just stay away from ball grid or QFN packages. Yes, I can do QFN by hand. No, I don’t have the patience to teach you how, unless you bring beer, are really cool, or have other endearing qualities.

Cost

The Pi is only $35. Oh, but you need a display, and a Gert board, and some SD cards, and a keyboard, and, and, and.

Many microcontrollers have onboard clocks, so you don’t even need an external rock anymore (that’s crystal for you non EE types). One chip, ok, throw in a bypass cap, but you can do a _lot_ with nothing more than a PIC18F2410.

Ok, I’m not going to do a complete “total cost of ownership” here, but if some Guinness guzzling Student would care to, that would be an interesting exercise. Yes, if you’re doing something with a discrete microcontroller you need a method of programming it, a circuit board to mount it on, a power supply…but, let’s say you want to do some snazzy light organ thing. (That’s what we used to call stuff that blinked lights to music). A $3 PIC and some FETs and you’re ADCing music in and blinking lights out. The reason I mention this is because I’ve heard folks talk about using the Pi for projects like this. Ok, interesting academic exercise, but maybe not the right tool for the job.

Software reliability

“OMG you can’t be serious! Linux is da bomb!” Ok, yeah, sure, youbetcha. But the reality is that an OS is a cumbersome risk in an embedded system. Yes, some require it. And yes, I’ve done plenty of work with RTOSes (Real Time Operating Systems). Keep in mind in some RTOSes the extent of the “OS” is a real time executive that keeps an eye on time slices and multi-tasking. It’s not the same thing as a “designed by committee” OS. An RTOS is a sniper rifle.

If you’ve got something that has to happen, no matter what, simple software is better. I’d much rather have my rockets controlled by a simple uC with a watchdog timer and interrupts than an OS that I don’t know where the code came from. In hard control systems, and that includes things like hobby bots and CNC tools, simple is better. Unless you are a big fan of unintended acceleration. Oh yeah, NASA said it wasn’t the code. (No they didn’t, they said they couldn’t recreate the problem…) If you, your bot, or somepony else could get hurt if the code flakes, consider keeping it simple.

Power consumption

The Pi draws around 500mA at 5V; 2.5W. Add in a display, and some uber cool over-clocking, and to quote one of my favorite robotics engineers, “you’re tethered”. Small microcontollers can draw nanoamps in sleep; we’re talking microwatts. Need some computer power but need it to run on batteries for a long time, or solar? Microcontrollers.

And remember, power consumption in processing devices is directly linked to instructions processed per unit time. With a simple uC and foreground/background code, I can go to sleep consuming uW until something important needs to be done. With the Pi there’s that operating system in the way again.

Boot time

From stable power rail to code execution on some of the uC’s I use can easily be in the 100s of uS. Microseconds. How long does it take your Pi to come up? Ten seconds? A few?

Again, it’s all about code complexity. And if your project requires something that quickly responds, waiting for an OS to boot might not be the answer. Well, you could keep the Pi running, but you pay for that again in power consumption. The one thing I miss about the T/S1000, TRS-80, C-64 days: flipping a switch and having the computer say “READY”. Again, if you want something that turns on and is doing stuff immediately, in human time, you want a platform without an OS in the way.


Various small, quick, low power uC boards, from 8 to 32 bits

Hardware reliability

Let’s face it, for your home project you’re probably not going to have a reliability engineer calculate your Mean Time To Failure. But when I get asked this question of Pi vs uC, it’s often from home makers asking about professional gear. “The Pi is so cool! Why don’t they use something like this in _fill_in_the_blank_with_something_critical_?” The thing to keep in mind, from a simplified perspective, is that generally the more parts a system has, the less reliable it is. That’s a gross simplification; but think if all semiconductors are equal, the device with more of them has a higher likelihood of failing before a device with just one. Add in electromechnical nonsense (that SD card slot) and it just gets worse.

I’m not saying that the Pi is unreliable. Read that paragraph again. What I’m saying is that if I’m designing a critical system and I get to choose between a single chip solution and a multichip solution, all things being equal I’m going with the single chip.

Peripherals

Most microcontrollers today have an alphabet soup of built in stuff: ADC, PWM, CAN, I2C, SPI, comparators, timers…all sorts of nifty peripherals, ready to read sensors, talk to things, and control the world. Your “just $35″ Pi needs a Gert board to get in to some of that…

…also note that some of what I’m saying here applies to discrete uC vs. Arduino. Yes, Arduino is great and creddy, but not even all hammers are the same. If I catch you using my ball peen to drive nails Imma smack you. Why use an Arduino for something that can be done on a 16 pin part with less than 100 lines of assembly code?

But, I’m not Pi bashing here. Let’s look at some of the great things about this platform.

Cost

Did you say cost before? FirmWarez, you are so pseudo-random!

Yes. Let’s face it, that’s a lot of computing platform for the money! The Pi Foundation accomplished what they set out to do. Which remember, wasn’t “make a nifty gizmo so home makers can get street cred when turning lights on and off”. Their goal was to make a computer, that could do computer stuff, cheap enough for every school kid to have one. Bam. Home run.

Code base

Linux. Huge code base. Enough said.

Reliability

Didn’t you say that the Pi is an unreliable piece of junk? No, I said that reliability engineers look at things like component count. A single-chip solution is considered more reliable than a multi-chip solution. But compare the Pi to a PC. No harddrives. No fans. Electromechanical parts are a royal pain. And orders of magnitude less reliable than semiconductors. Stuff that moves wears out. This means that the Pi trumps the PC in this category. Again, right tool for the job, correct? If you need an OS and all, but want something reliable, go with a Pi over that old desktop you’ve got in the corner.

Possibility

This is probably the most exciting thing about the Raspberry Pi. It’s a new idea, and new ideas are what excite hackers and makers. It’s ripe for experimentation. Who knows where it will lead? That’s what we live for! Even I have ordered a Pi, and I’m looking forward to learning and hacking this nifty system. I’ve got a great idea of where it will fit in to one of my home projects…but rest assured, when the task calls for it, I will be designing in a discrete microcontrollers. They are the right tool for so many jobs.

What I hope I’ve presented here is the fact that single chip microcontrollers and systems like the Raspberry Pi are indeed different tools that solve different kinds of problems. Are there problems that both could solve equally well? Sure, and that probably applies to many home maker projects. And the maker movement has a long history of using overly complicated systems just to do cool stuff. It’s a great way to learn, or sometimes to make your project happen quickly because that’s the platform you are most familiar with. But every now and then pull back from the project, and ask the question, “is this really the best tool for this job?” The answer may lead you to exploring new hardware, and learning new skills. Isn’t that why you got in to this making and hacking in the first place?




« | »

Leave a Reply

Get Adobe Flash player