Getting Started with Microcontrollers
Total Page:16
File Type:pdf, Size:1020Kb
Getting Choose the right controller for your Started with project and your Microcontrollers skill level. BY TOM IGOE I/O board: PicoBoard Programmable module: Arduino Bare processor: PICAXE Single-board computer: Chumby icking your first microcontroller can be bewildering, because there are so P many on the market. Here’s what you need to know to get started. TYPES OF CONTROLLER SYSTEMS don’t have to be attached to your computer. More I/O boards (examples: PicoBoard, Phidgets) expensive than bare processors, they make up for You don’t program these devices directly, but you it in convenience. For most people, this is the best can control their input and output (I/O) from a level at which to start. desktop programming environment like Scratch, Processing, or Flash. They don’t work when Bare processors (examples: Propeller, PICAXE) detached from the computer. If you’re familiar with These are the guts of the other microcontroller desktop programming, this is a good place to start. categories. You have to build all the supporting circuitry and connectors yourself, but they offer the Programmable modules (examples: Arduino, lowest price. These generally require an additional BASIC Stamp) These devices can operate inde- piece of hardware to program them as well. They’re pendently of your computer once programmed. better for more experienced hobbyists. Like I/O boards, they have a lot of the electronics onboard: communications, power management, Single-board computers Experienced program- and connectors. They require more learning than mers get excited about boards like the Beagle I/O boards, but let you build smart things that Board or the Chumby. I don’t recommend starting Troxell Ed by Photography 42 Make: Volume 25 M_042-45_SS-MicroconSel_F1.indd 42 12/15/10 3:10:58 PPMM here. They’re usually more difficult to interface hard- ware to than simpler controllers. For experienced GET A STARTER KIT programmers, it’s too tempting to stay in software Here are some components you’ll need regardless rather than experimenting with circuits attached to of the platform you choose: their board. For software beginners, the challenge » Breadboard » Speaker of getting an operating system started from the » LEDs » Servomotor bootloader can be an insurmountable hurdle. » Switches » Pliers » 10kΩ resistors » Wire strippers 220 » 220 Ω resistors » Diagonal cutters PICKING YOUR FIRST CONTROLLER » Photocells » Jumper wire Focus on ease of use. You’re learning to program » Potentiometers and learning to build a computer. Starting simple will keep your enthusiasm high. discussion threads. Do a few web searches for the Don’t be seduced by features. Apollo spacecraft microcontroller you’re considering. Is there a lot made it to the moon and back with less processing of collected knowledge available in a form you power than most microcontrollers have. Don’t be understand? If nobody besides you is using your tempted by the fastest, or the one with the most controller, you’ll find it much harder to learn, no memory or I/O, at the expense of simplicity. matter how great its features are. What’s the “Getting Started” guide like? How easy is it to add extra components? The time you’re most likely to give up on micro- If there’s a particular component you want to work controllers is in the first hour. The Getting Started with, check to see if someone’s written an example guide should take you from zero to blinking an LED for how to use it with the controller you’re consider- or reading a switch in a short time. Read it before ing. Most controllers offer 16 or so I/O connections, you buy. If you don’t understand any of it, or it which is plenty enough to get started. Tools for doesn’t exist, be wary. expanding your I/O, such as shift registers and multiplexers, are compatible with most controllers. How complicated is the programming environ- ment? The program in which you write your code, Is your operating system supported? Most called the integrated development environment microcontroller manufacturers focus on the (IDE), should be easy to understand. Download the Windows operating system. Some have third-party IDE and check it out before you buy hardware. If support for Mac OS X and Linux. Learning from you don’t feel you can understand it quickly, keep friends is common, and being able to have the looking around. same user experience on different operating systems is helpful for that. How expandable is the programming environ- ment? I/O boards and very simple languages make WHAT SHOULD YOU CHOOSE? getting started easy, but you’ll reach their limits For beginners, I recommend starting at the middle quickly. If you’re experienced in programming or level, with programmable modules. You can get your electronics, you want to feel liberated by a plat- first few projects going for under $100 including form’s simplicity, not limited by it. the controller and components. You’ll save yourself time not having to learn some of the messy details Is the programming environment free? If not, of the support circuitry, hardware programmers, or don’t bother. There are too many good free envi- setting up a development environment. ronments for a beginner to bother paying for the The first microcontroller you learn will most likely software alone. not be the last. It’s addictive. So start simple, and grow into the advanced tools as you go. What’s the community knowledge base like? There are lots of microcontroller environments You’re not just getting hardware, you’re getting a out there! I looked at 25 for this article, and only community. Every controller has websites and email scratched the surface. The following table covers 8 lists dedicated to its use; check them out, look at that I think are most interesting, ranging from I/O the code samples and application notes, read a few boards to bare microcontrollers. Make: 43 M_042-45_SS-MicroconSel_F1.indd 43 12/10/10 3:07:30 PPMM SIMPLE I/O boards Programmable modules PicoBoard Phidgets Lego Mindstorms BASIC Stamp 2 $50 picocricket.com/ $78 phidgets.com $280 mindstorms.lego.com $49 parallax.com picoboard.html Phidgets are specialized Lego Mindstorms kits are The granddaddy of the hob- The PicoBoard is a USB- hardware blocks that give Lego’s entry into the pro- byist microcontroller market based hardware accessory your personal computer gramming market, done as sets the bar for a simple to the Scratch programming added physical functionality. only they (and MIT) could do. programming language, language. If your kids know Besides general sensor I/O, The language is slick and fun, good starter kits, and excel- Scratch already, it’s a great there are RFID modules, the parts are way cool, and lent documentation. Several way to introduce them motor control modules, just putting things together models offer more speed, to taking input from the and display modules. If you gets the geek in you excited. memory, or both. Parallax physical world; you just read already know how to code, You’re somewhat locked into also sells sensor modules, the inputs via the Scratch there’s an API that’ll let you the (expensive) Lego world if actuator modules, project board watcher. It’s more talk to a Phidget as easily you choose this as your main kits, robot boards, and good limited than its cousin, the as talking to a mouse or platform, but it’s a fun world development boards for PicoCricket kit ($250), but keyboard. in which to be locked. beginners, along with lesson a whole lot cheaper. plans and teaching guides. Runs on: Windows, Runs on: Windows, Mac OS X Runs on: Windows, Mac OS X, Linux* Requires: Lego Mindstorms Runs on: Windows (third- Mac OS X, Linux* Requires: Sensor modules, NXT 2.0 kit 8547 party applications are avail- Requires: USB A-to-B cable $7–$100 each Inputs/outputs: 3 motor able for Mac OS X and Linux) Inputs/outputs: Built-in Inputs/outputs: 8 analog ports, 4 sensor ports, USB Requires: USB-to-serial button, slider, light sensor, in, 1 digital in, 8 digital out port, speaker, buttons, converter, $15 sound sensor, 4 stereo jacks (model 1018 interface board) display Inputs/outputs: 16 general with alligator clips Languages: Director, C++, Languages: Mindstorms I/O plus 2 for dedicated Languages: Scratch* C#, Cocoa, Flash, Flex, Java, visual language, based on serial. No analog input, but Getting Started guides: Max/MSP, Visual Basic, etc.* LabVIEW you can fake it with RCTime. Short, clear, and simple Getting Started guides: Getting Started guides: Languages: BASIC with good examples. Guides and code samples for Guides are clear and step- Getting Started guides: Knowledge base: each language are clear. Not by-step. Build instructions Manual is clear and thor- • Good examples on site many sample projects, but are excellent. ough, but dated: still uses • Small knowledge base, but plenty of user-contributed Knowledge base: 9-pin serial cable; doesn’t large collection of Scratch examples on the web. • Good tutorials on site and take advantage of what a examples on the web that Knowledge base: bundled with kit micro can do. could be expanded through • Lots of code samples in • Plentiful examples on the Knowledge base: the use of the PicoBoard many languages on site web from users • Many excellent examples Pros: • Plentiful examples on the Pros: on Parallax site • Very simple, fun way to web at large • Graphical programming • Countless examples on introduce kids to physical • Lots of sensor and special language is great for people the web interfaces function modules who’ve never programmed • Parallax has a ton of appli- • Alligator clips