Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am interested in learning how to program microcontrollers. It seems to be quite interesting, but I don't know, where to start. I am particularly interested in:

  • What platform is worth learning?
  • Are there any cheap systems that make it easy to write own programs for them?
  • Pointers to good books / tutorials
share|improve this question

5 Answers 5

I would recommend arduino because the electronics are very easy to setup which allows you to spend time on programming. It is programmed using a c++ like language and is very simple but powerful. Just my two cents.

Edit: Also, they are inexpensive and come with an editor that makes uploading programmes easy.

share|improve this answer
    
One of the nice things about arduino is that you don't need to buy them online if you don't want. Radioshack has started to carry it and so does MicroCenter (if you live near one of those). –  Jetti Oct 1 '11 at 20:45
    
+1 for Arduino. Avoid Netduino though - they are damn slow. –  Deleted Oct 1 '11 at 22:02
1  
A big +1.... I have been wanting to use something like this, Auduino looks excellent!! I've spent the last 30 minutes look at all the add-ons for it, LCD Readouts, motor control.... heck you can even get it to open www.google.co.uk :) –  Dal Oct 1 '11 at 22:41
    
@ChrisSmith - Just read your comment, damn! Netduino looks ace because I work with the .NET framework, is it really that bad? –  Dal Oct 1 '11 at 22:43
    
There's a very good pdf tutorial for the Arduino at the bottom of this page: earthshineelectronics.com/10-arduino-starter-kit.html –  Joe Internet Oct 1 '11 at 23:56

What platform is worth learning?

While the already mentioned (AVR-based) Arduino is really nice for starters and for rapid prototyping, if you want to go more in depth about it, then get a collection of AVR controllers, solder your own programmer and a few nice boards (you might want to start with something like this) and learn this platform in depth, as the Arduino will hide away features and details which might be useful and which really ease the transition to other platforms (such as TI's MSPs or Microchip's PICs). It'll benefit your general understanding of microcontrollers. There's also a whole IDE for AVR development, the AVR studio. Also note that Microsoft introduced the gadgeteer series for rapid prototyping. It is built upon the .NET microframework and can be programmed in C#.

Are there any cheap systems that make it easy to write own programs for them?

Cheap systems? There's the MSP $4.30 launchpad, which is basically something like an Arduino on the hardwareside. There's a header file on the web which makes its programming a bit like programming the Arduino. Those boards a damn cheap an useful for small controlling applications.

Pointers to good books / tutorials

I guess google is your friend...

share|improve this answer

The available answers miss one very big point which I'll try to somewhat address. The point is why do you want to learn how to program microcontrollers.

The problem with "just learning" how to program microcontrollers is that microcontrollers themselves are a very wide field and that some of the acquired knowledge may not translate well to another platform.

So basically you have several "grades" of microcontrollers and each grade has its own specifics and available platforms.

The simplest would be the beginner hobby grade in which the Arduino is the most popular system. In addition to what others have said there are few more things which need to be taken into account in this grade. First is that the boards themselves are expensive (some would say inexpensive, but read on) and they themselves don't provide too much. Their main promise is that with a simple board, USB cable, wall wart and few wires you'll be able to make an interesting project. This is somewhat true, but the points which are often missed are the need for so called "shields" and consumption of Arduinos themselves. There's no easy way to use Arduino in a complete permanent project without "using up" the board or moving to the next grade. Other similar systems such as PICAXE suffer from same limitations. So basically their good side is that you'll be able to "touch the water with your toes" and be able to do so cheaply, but the bad side is that they hide the actual microcontroller programming from you and that they're easy to outgrow. Also it is taken for granted that the price of the system isn't a problem and can be afforded. For these reasons, they're very rarely used for any professional work. Another point which is important but becomes visible only after moving to a higher level is that the core part of Arduino is the bootloader which allows the microcontroller to program itself therefore saving money on an external programmer.

Next grade would be something I'd call pre-Arduino hobby level. I decided to call it like that because it represents the entry knowledge which people needed to have before Arduino and similar platforms showed up. So the greatest difference is that you're using an 8-bit microcontroller itself directly and that all of its capabilities are exposed. The bad side of that is that you'll need a board which can host the microcontroller or you'll need to learn how make one yourself. There are numerous difficulties associated with making a board for yourself, even if it's made on a simple breadboard. You'll have to read microcontroller datasheets, understand what datasheets say, understand what they don't say and where to find that, understand what you think they say but in fact they don't or you think they don't but in fact they do... This at first may be complicated, especially when you open up datasheet for say AVR ATmega16 and see that the datasheet is 300+ pages long, written in a condensed style with each line being very important. Of course, not all of that is needed to start, but finding out what's needed is a skill that needs to be learned too. Next there's the financial part of the equation. An officially blessed programmer for say AVR or PIC can be in the range of 2 or 3 Arduinos. Of course, there are many third party programmers which can work too, but they may have their limitations such as only working quickly from a real RS-232 port and having extremely low performance with USB to RS-232 cables or not supporting latest chips and so on. Another thing that may be problematic is getting burned by old literature. Microcontrollers change over time and a book written several years ago may be out of date and recommend old chips which may be obsolete or out of production.

This all may be a bit difficult to digest but is necessary if you ever plan to write programs for microcontrollers in a professional setting or do any complex programming. The main good side of focusing on this approach is that once you digest the basics, you'll be able to easily and cheaply make your own boards for whatever project you may have in mind. As I said, you'll have to spend money or effort to get a good programmer and a starting board, plus some effort to learn how to use the standard IDE for the microcontroller you chose to use. A real bench power supply may be interesting to get and you'll have to learn how to solder (if you plan to move on from breadboards), get a multimeter, learn where to buy electronic components, but once you cross this stage, you'll be able to stand on your own feet, be able to understand what you have made and how to actually maintain it. In this stage, most popular microcontrollers are 8-bit AVRs and PICs. There are also other microcontrollers like for example Parallax Propeller (which has 8 cores!) or the MSP430. It's also worth noting that PICkit programmers can do debugging too while AVR programmers can only program and separate in-circuit emulator is needed to actually debug the running microcontroller. At this point, the basic setup costs, but cost of a project itself can be very low and can easily beat cost of a dedicated Arduino.

Next there's the the grade for devices which are on the edge of another field. This is for devices which are on the border of a microcontroller and a system on a chip or microcontroller and a digital signal processor and so on. This grade is somewhat more beginner friendly but is more complex than the previous grade. Devices here may share setup equipment with devices from the previous level which can make transition a bit easier. For example PICkit can work with 8-bit, 16-bit, 32-bit PICs and the 16-bit dsPIC digital signal processors. Devices themselves may or may not be available in easy to use formats, but even for hard to use surface mount packages, adapters into through-hole aren't rare and third party development boards are available too. In addition to devices already mentioned from Atmel and Microchip, at this stage various ARM-based microcontrollers become available. They're mainly interesting because they're very close to "real computers" and are often found in mobile phones. Development of home-brewed boards at this level gets difficult and pre-fabricated ones cost hundreds of dollars. On the other hand, you can expect to have say two cores, embedded Ethernet, ability to produce high quality video and so on.

Next level is what I'd call the budget level microcontrollers. We're still in the 8-bit land, but the cost of the device starts to be the main driving factor and the cost of the setup itself isn't too important. This is mostly of interest to people who are going to spend most of their time professionally writing code for devices which will be produces in large quantities. I don't have too much experience with this area, so I won't comment much on it, but most major semiconductor manufacturers have their own line of microcontrollers and their own proprietary development software and hardware which can get expensive. Chips themselves won't be in a form factor which is easy for prototyping, so you'll need to either get a evaluation board or make your own PCB to house the microcontroller. They also won't be available form the local friendly electronics store and instead will have to be ordered from major distributors which may have minimum order amounts (which may range from hundreds to thousands of units). So my advice would be not to go into this area until you need to do so.

I'd write more, but it's 02:35 here right now and I've noticed that I need to use spellchecker to correct each work word I type, so that's it from me for now.

share|improve this answer
2  
Very good overview, however manufacturer supplied tool chains need not be expensive. Renasis use to give away devlopment kits, including hardware and software as part of an annual competition, all you needed to do was enter (What a great way to learn). Ask around, when I worked in the industry we setup a teenager with everthing he needed from our bin of obsolete dev boards and parts. –  mattnz Oct 3 '11 at 8:46
1  
If you North America/ based have a look at am.renesas.com/products/tools/introductory_evaluation_tools/… –  mattnz Oct 3 '11 at 8:52
    
@mattnz Thank you for providing that information. I'll update my answer when I get the time. –  AndrejaKo Oct 3 '11 at 9:47
1  
It's a weird cultural thing, but you'll notice that professionals and old-school hobbyists look down on the Arduino. It's a shortcut that helps you do meaningful things, and it lowers the bar to entry into the field. That shortcut avoids a lot of pain and hassle, but that's valuable learning experience that you'll have to gain eventually. –  Philip Oct 3 '11 at 14:05

Build a robot! It'll give you a nice introduction to writing software for microcontrollers (and electronics), and at the same time you'll have a blast. I made an autonomous rover a number of years ago - it was a very fun experience.

share|improve this answer

Both arduino and ARM's mbed provide a simple hardware interface and (C++) API for programming micro-controllers. My friend has an arduino and I own an mbed, thus by reviewing them we concluded that an advantage of mbed is that you simply connect it to the USB port of your computer and start coding using the online cloud services of ARM (compiler, debugger, VCS, etc.). Everything is online, you don't need to install anything! As for books, since mbed is newer than arduino I think that the only available is ARM Microcontrollers. Find some more books on mbed.org.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.