Microcontrolling on the Cheap With Arduino and Linux
Open, Affordable Microcontrollers
So where does Linux fit with this scheme?
Being a diehard Linux guy with a track record of keeping the faith, it makes no sense to use anything other than a Linux machine, to program these miniature process automation factories.
A Revolution In Microcontrollers
Within the last few years, there has been an explosion of microcontroller modules in the $45 to $60 range. The granddaddy of them all is the Basic Stamp by Parallax. Others include the NetMedia BX-24 and Zbasic ZX-24n, which are virtual clones of the Basic Stamp. All have generous numbers of input/output pins, analog-to-digital conversion, and serial interfaces. They are easy to program with their Basic development environments and are robust and reliable. Sadly, their programming environments have always had to run under Windows.
A significant difference between the Stamp type platforms and more traditional microcontrollers, that have been around for years, is that the Stamps can be programmed "in circuit". They are also suitable for newbies, hobbyists, and even non-techno types due to their modular design. You hook up a serial line (USB or RS-232) and download the compiled binary code directly to the electrically erasable programmable read-only memory (EEPROM), resident on the board. No need to pull a chip out of the socket and stick it into a hardware programmer to "burn" in the embedded code. This is a tremendous development advantage, saving valuable prototyping time and unnecessary equipment expense. Additional pluses are that the memory is self-contained and you can program (or re-program) your finished projects, even remotely. After, the download, simply restart the microcontroller and your program will just run.
Since I wanted to automate my sprinkler system and perhaps add some life to a future Halloween monster, I did a few prototype projects with some of those chips, but was always grumpy about having to use a Windows box to compile and download any code. Alas, I longed for a cheaper microcontroller platform with a nice development environment that ran on Linux.
Next Level..Open Hardware
Taking easy-to-use, mass-market microcontroller technology to the next level is the Arduino.
This little package measures 2.75 x 2.50 inches, has a USB interface, 14 digital I/O pins, 6 analog pins, a socketed ATMega168 chip, and a recommended supply voltage of 7 to 12 volts. Did I mention that the board can run standalone from a 9 volt battery or right off of the USB connection. The thing retails for $34.95 from Sparkfun. There's also an Arduino Stamp, which is actually about the size of two US stamps, that sells for $37.95. Either way, they're considerably cheaper than the Basic Stamps.
Ready for the best part? You can program them from your favorite version of Linux!
Going cheaper is easy too. Since the Arduino is an open hardware platform, several clone boards have popped up and cost about $25. Google around for unassembled Arduino kits that goes for about $20. The USB bare Boarduino clone printed circuit board can be found for $5, if you really want to start from scratch.
I recommend that you start out downloading the Arduino software package to a 32-bit Linux machine. I originally tried to get it working on 64-bit SuSE. It needed a lot of tweaking and seemed to be pretty flaky. Regular old 32-bit Kubuntu works great on my HP Pavilion zv5000 laptop and configuring the Arduino environment was straightforward. You'll need to apt-get sun-java6-jre, avr-libc, gcc-avr, the latest version of the Arduino software, and a couple of other packages. Go to LadyADA's Tea Party or The POP! Project, POP-168 board Site for in-depth details. I don't mean to discourage all of you 64-bit gurus. It's just that most people might get frustrated trying to optimize the Arduino software on a 64-bit machine. The situation is getting better and at some point I'm certain that all the issues will be worked out. Go for it if you have the time and curiosity.
You can install the XP version on your Windows box. It's not really optimal to develop on XP because then you lose all those interesting tools like minicom, multiple desktops, and a built-in Apache Web server, that you'd otherwise have under Linux. The pre-compiled Arduino source code is the same regardless of operating system, which makes it easy to use the microcontrollers in a mixed (Linux and XP) production environment.
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader