
I constantly ask myself this question, during my hobby lessons - developing a home automatic control system (smart home) based on a 16-bit microcontroller - is this really the right approach? A month and a half ago, I already wrote in my blog on the topic
“Microcontrollers against systems-on-chip” . So, I'm going to write about it again.
Partly to this, I was prompted by the appearance on sale of
Stellaris Launchpad and
Arduino Due . They are both based on 32-bit microcontrollers, and in many ways, very similar. I studied the specifications (datasheet) for both, and although they differ in price well, they are designed for one target audience. I thought that maybe I should switch from MSP430 to Stellaris, and maybe even transfer to a fundamentally different system, use something like Raspberry Pi, instead of microcontrollers.
Both, Stellaris Launchpad and Arduino Due, are very powerful, but not designed to run Linux. They work either on executable code written directly for them, or under the control of the real-time operating system (RTOS), a minimalistic OS, with a very short reaction time to external events. They are also much more complicated than MSP430 or 8-bit AVRs.
On the other hand, in real life (beyond the borders of the Internet), most who I know use Raspberry Pi or other embedded systems on Linux. The use of microcontrollers is quite a rare case among those I have met. Even Arduino, is much less popular in my environment than embedded Linux. As I understand it, why would anyone buy an Arduino when you can buy a Raspberry Pi, which can do much more and cost as much or less? Under Linux, there is a huge amount of ready-made software, and it can be programmed using simple scripting languages.
')
For me personally, the reason why I don’t want to use Linux is because I use it every day at work, and when I go back home I don’t enjoy having to work on Linux-like systems again. I have no problem using Linux, but it’s too much everywhere, it pushes me. It is much more interesting for me to work with simple electronic devices on 8/16-bit microchips.
However, I do not turn away from reality. If I want to stay on the same wavelength with the real world, I have to use those tools that are used in the real world. Otherwise, it looks like the desire to drive a car with a steam engine, just because the internal combustion engine is too ordinary, I use it all the time. If the world around goes to a more advanced technology, you need to master it, whether I like it or not. In particular, if I want my blog to be interesting to people and remain relevant.
In my project of smart home, I really ran into this problem. I have already made a local area network driver for the monitoring system on the MSP430, and everything looks very decent. In fact, I can do everything that is needed for an automation system on the MSP430. However, I wonder if it’s right how I do it? Am I trying to eat soup with a fork when I have a spoon? Maybe Linux is a more suitable system? Let me explain.
If you stop and look at the current situation, on the technological achievements for November 2012. I ask myself, are microcontrollers good enough and relevant compared to on-chip systems using Linux?
If I list the projects on embedded systems that come to my mind, these are: drones, robots, home automation, motor controllers, sensors, wrist watches, 3D printers, etc. In which of these cases, embedded Linux fits better than microcontrollers? And why?
I think that there are three situations when the microcontroller is the best choice: where instantaneous (realtime) response to events is important; where extremely low energy consumption is needed; and where you need to use chips as low as possible.
For a start, the use of cheap microchips is not a very important moment for me. I do my hobby for myself and am not going to ever produce competitive products. I do not have to think about transferring production to a factory using slave labor in order to have a competitive price for those small projects that I develop. I would be happy if I could, unsolder more than one board per day, thanks to my abilities!
For example, for a smart home project, I can develop a remote-controlled switch. It can turn on / off the light or something else. At the same time, I can go to a local electrical store and buy the same for $ 20, produced in China. Will I ever beat this price by trying to sell my own switch? I do not think that this is possible.
If you think about it, this also applies to many other things that are necessary for home automation. Sensors of temperature, smoke, movement, etc., I am quite able to do the same on my own, but it is unlikely that financial gain can be derived from this. Who is interested in buying such things from me for $ 75, when they can find them for $ 20 in household goods?
If you think about extracting some benefit from your hobby, then it is better to pay attention to more expensive and complex products. For example, a home automation controller or thermostat, usually costing more than $ 100, and leaving more freedom for individual creativity, you can build one, sell it to your neighbors, and even make money from it.
But the desire to achieve a better price for the final device does not mean that you need to use the cheapest microcontroller on earth. In fact, this is a bad idea, because development time has the same value as the parts used. The microcontroller may be cheap, but it takes more time to write the control code. Time is money, and if you work faster, you will have time to achieve more.
All these thoughts lead me to the conclusion that it is more profitable to develop a smart home system on Linux than on microcontrollers, despite my personal preferences, not to use Linux (I like low-level programming more than scripts, Linux bored me).
If you go back to the topic of topic, the price of microcontrollers, this may be an important factor for large corporations about to launch a new product, but on an individual level, if you try to run a Kickstarter-style business, this factor is not so important, in fact, fast development time, more important than the cost of components.
On the other hand, microcontrollers can be a better choice than system-on-a-chip when low power consumption is needed. In such systems there are two points: low consumption of the circuit itself, during operation, and a short start time. A typical way to save battery for small devices is self-shutdown (shut off). When you turn off the computer on Linux, it needs a decent time to get back to work, sometimes up to several minutes. This time is not acceptable for embedded systems.
If you take such a microcontroller as MSP430, then it can work for years on a single battery. Stellaris Launchpad and Arduino Due, in principle, the same is capable of this, they consume more energy than MSP430, but still very little, compared to Raspberry Pi. Still, MSP430, can instantly start, after shutdown.
Thus, I am absolutely sure that in all situations where low-voltage operations are necessary, it makes sense to use microcontrollers. There is a large variety of battery-powered devices where the need arises.
In the third case, as I said, the use of the microcontroller is more meaningful than Linux in operations that require an instant response (realtime response). I mean devices such as 3D printers and CNC machines, I know what I'm talking about, because I spent a lot of time studying them. By their nature, they require high accuracy in work, which is slightly less than completely dependent on the reaction time to commands.
For example, if you have a circular saw that cuts a piece of wood or metal at the moment, you cannot stop the process, due to the fact that the computer that controls it, needed a pause to throw the data from memory to disk or something other in the same vein. Anyone who has used a PC is familiar with random hangs that occur periodically during the most regular work. Now imagine that you have a large drilling machine, running a PC, which suddenly begins to check for updates for Windows, and a drill, drills through the table on which it stands, because the computer has lost control of it.
PCs and system-on-chip are not designed to work in real time, even with Windows, even with Linux, but by themselves they are trying to get closer to this. As an example, there is a real-time patch for the Linux kernel, and a special CNC software designed for this kind of work. I’m not familiar enough with this Linux patch, and I don’t know how flexible it is to fully control real-time events. But I think that this is only a possible alternative, since Linux, no matter what patches are not installed on it, will never beat microcontrollers in this area, due to their interrupt system.
In conclusion, I want to say that I spent a lot of time trying to find areas where the use of microcontrollers in my projects has an advantage. And it looks like the era of world domination of Raspberry Pi and Beaglebones has arrived. This is the current situation in the DIY community. In most cases, it is faster and easier to develop on these systems, so it is often the best choice for most projects.
For microcontrollers, only areas of low-voltage devices, real-time operations and low-cost devices remain.
It does not depend on the fact that microcontrollers may seem "more fun" than PCs. This is what you have to accept.
Translation from English of the original post
“Are Microcontrollers Obsolete?” In the
blog of Matthew Cashdollar , dedicated to his DIY development in the field of home automation.