Skip to content


Where to start with Microcontrollers

uCHobbyLogo_thumb In this article Jacob Woj gives his take on which tools are best for a hobbyist getting started with Microcontroller projects. He compares that Arduino, Make Controller Kit, and more direct programming using AVR-GCC and an AVR-ISP to program the parts. The article includes cost comparisons and example code for a simple project in the various development environments.

Where to start is a common question at AVR Freaks, Lets Make Robots, Instructables, and even on MetaFilter for people wanting to get started in uC programming. I decided to take a swing at answering this question with some of the most popular choices for a beginner.

The Arduino, Make Controller Kit, and the AVR-ISP mkII programmer are all popular options. They all have their positives and negatives, but I cannot just leave it at that. In this article, I will be briefly analyze those three choices to find out where each of them would fit for someone new to Microcontroller (uC) programming.

Each system is compared in terms of scalability (how practical they would be in real world, mass production situations), feature set, and programmability.

Coding

Starting off, our code will be the de-facto ‘hello world’ of uC programming – the blinking LED. On a bit of a tangent, these 3 solutions/products were chosen for a comparison because if you choose any of these three, it will be relatively easier to migrate to another one. All of the programming for each of the solutions is done in C (using some libraries).

Arduino code:

//run initially as power is applied to Arduino

void setup() {

    pinMode(13, OUTPUT); // sets a digital pin as output

};

//run continuously as long as uninterrupted by another command

void loop(){

    digitalWrite(13, HIGH); // sets the pin 13 on

    delay(1000); // pauses program for 1000ms

    digitalWrite(13, LOW); // sets the pin 13 off

    delay(1000); // pauses program for 1000ms

};

As you can see this code is easy to read. If you have any experience in programming C, the comments are essentially useless. I think this is one of the advantages of the Arduino – its libraries make the code very high level.

AVRISP (AVR-GCC) code:

//essential libraries
#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 1000000UL
int main(void) {
    //infinite loop
    while(1) {
        //defines which port will function as output
        DDRB = 0xff;
        //sets a bit value high
        PORTB = 0b00000001;
        //creates a 1000ms delay
        _delay_ms(1000);
        //sets bit value low
        PORTB = 0b00000000;
        //delay before loop
        _delay_ms(1000);
    };
    return(1);
};

As you may be able to see, the plain AVR code in AVR-GCC is a lot more low level and many parts mimic assembly language. While it may seem simple enough in this example, low-level code can create a steep learning curve for new hobbyist when addressing on-chip peripherals. In AVR-GCC, in order to use the ADC (analog to digital converter) you will probably write between 10 and 20 lines. On the Arduino, if you are not too fussy, this can be done through one function: analogRead(pin). Of course, on the flip-side, writing the 10-20 lines gives you a lot more control over the ADC.

On a very important side-note, even if you choose to go with the AVR-ISP but you are not comfortable using all of the features that require low level programming, ‘sketches’ made in the Arduino IDE can be burned onto plain chips with virtually no modification (since the code is compiled in AVR-GCC), so essentially you can get the convenience and support of the Arduino community and the low cost and flexibility of the ISP programmer in one package.

The code for the Make Controller Kit is a lot more abstract, so I did not feel a need to post it here. There are two ways to do it, either enable it through the Firmware API through the Io_SetValue function, or sent an OSC message to the board, such as ‘digitalOut/6/value 1’. Again, since there are many ways to package these commands for the Make Controller (because it is so versatile) I did not feel as if it would be fair to use one just for a comparison.

Cost

The cost of each of these solutions (for this sample test) is approximately as follows:

Arduino $35 Only the board is needed as there is an onboard led
AVRISP mkII $45 Includes LED, breadboard, the actual AVRISP mkII and chip
Make Controller $100 Only the board is needed as there is an onboard led

Community

clip_image002[4]

Looking through some of the officially condoned forums for each of these solutions, I quickly realized that not all user base communities are made equal, there were huge differences in each, perhaps large enough to make you change your mind on what solution you would like to work with. While these differences may not be positive or negative, it may be easier for a new Microcontroller hobbyist to understand one forum over another. Let’s take a look at each:

AVR Freaks.net – By far the largest forum on the subject of AVR’s, a beginner may find himself lost here. A lot of the conversations revolve around assembly language (C is considered ‘high-level’) and many of the members are professional electronics engineers. All-in-all it’s an excellent forum, just maybe not best for a beginner.

Arduino.cc – As the official forum for the Arduino, I find this one the friendliest and most useful of the three. Complete with projects, code samples, and quick responses.

MakingThings.com – The Make Controller Kit’s forum is a shoe-in for the number-two spot. Almost as friendly and approachable as the Arduino forum, it is not intimidating at all. The response times to questions seems to be a bit slower, and often the answers are a bit more ambiguous, which may be overwhelming for a new Microcontroller Hobbyist.

Scalability

The most scalable solution is the AVR-ISP, which allows one to program real industry-standard, Atmel AVR chips. The Arduino, on the other hand, requires boot loaded chips, and the Make Controller Kit requires you to use $60 Controller Boards (first one is included), if you wish to have more than one, or if one breaks. The good news is that there are ways to program all of these solutions in machine code, and plain C.

The price of making permanent projects with the AVR-ISP is the lowest, as the chips cost next to nothing, and you can add only the bare minimum of components, unlike the pre-fabbed boards, which already include a lot that you may not use.

Features

clip_image004[4]

In terms of features, the board that wins by a landslide in this category would be the Make Controller Kit. Complete with Ethernet, USB, motor drivers, a JTAG and CAN ports, screw terminals, integrated pull-up resistors, as well as many other features, it has just about anything you may need for the core of any robotics project. A new board is actually fabled to be coming out before Christmas, which may add even more features, including I2C.

The Arduino’s features encompass easy pin naming, virtual serial port (through USB), a power regulator, auto reset, and easy integration with Processing (an IDE/computer language). Additional features can be added in packages called ‘shields’, which can deliver anything from SD card-reader to GPS. All in all, the Arduino has a good set of features if you know what you want, but more parts will be needed for experimenting.

With the AVR-ISP, your feature set varies depending on which chip you program, but the AVR series is relatively well featured when compared to Microchip PIC or Parallax chips. Other than that, if you have a collection of bread boarding components lying around, they will serve you well.

Conclusion

In conclusion, I was not able to ‘crown’ one of the solutions as ‘the best’, but I was able to figure out what niche each of these three fall into. The AVR-ISP mkII is the most scalable solution, very economical, and is good for someone with breadboard experience. The Make Controller Kit is suitable for somebody very ambitious, but perhaps less experienced, or somebody who is very experienced wanting to make a powerful robot. The Arduino is perfect for somebody in the middle, looking for a low cost solution. The Arduino seems to be the best supported by a very creative hobby community.

Stay tuned for an article on setting up AVR Studio 4 as well as AVR-GCC, and creating/debugging projects…

Posted in Arduino, Development Tools, Discovering, Electronics Links, Ideas, Microcontroller, Parts, Projects, Review, Workshop Tips, Workshop Tools.

Tagged with , , , , , , .


9 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Berni says

    That make controller kit is very powerful since it uses a ARM7, but that probably means a lot of complication.

    I personaly use PICs

  2. Jacob says

    Good point, but it’s not entirely the case. The Make comes with libraries that are prebuilt for many of the functions both on the chip and on the board, in standard C++, so it’s not too complicated to get started.

  3. WestfW says

    You make it sound like porting the relatively simple Arduino runtime environment to other CPUs and/or boards would make them significantly easier to use. That’s an INTERESTING observation; most of the arduino project is tied up in the IDE and backward/forward compatibility. I would think that it would be relatively easy to implement the core arduino library on nearly ANY cpu, if you can do things make the “pin numbers” equal to chip numbers or something…

    Also, I think you skip over hardware complexity a bit too much. With either Make Controller or Arduino, you can ask basic questions and people can assume a particular (and WORKING) hardware configuration. Whereas when dealing with bare AVR chips, you might need to start with “well, how are your fuses burnt? Did you remember a pullup on RESET/ ? Having “known working” and “common” hardware is a big advantage when getting community help…

  4. Winston says

    After initially buying a $20 TI eZ430-F2013 and finding their documentation on the controller’s ADC section sorely lacking, I went with a $25 Boarduino, a very compact breadboard compatible version of the USB Arduino Diecimila. Plenty of ADC docs are available for Boarduino’s ATMega168 and I’m very happy with the unit in other respects, too.

  5. Eric says

    I personally use the Roboduino microcontroller board

    Its basically a better version of the Arduino and is 100% compatible with the Arduino software

    More info: http://curiousinventor.com/kits/roboduino

  6. Larry says

    I was a little amazed that the fact that the Arduino platform is open sourced both on it’s software and hardware and it’s IDE (now at version 12) runs on all three major PC platforms, MS-Apple-Linux, was not mentioned. Lets face it, the low cost access to these great chips is only possible because of the PC platform they all rely on for developing ones projects.

    While I’m not trying to imply that the Arduino is the end all & be all, the fact is that being open sourced was already spawned a large available choice of compatible and competitive priced hardware choices. This lack of vendor lock in and active open source software development was a large reason for me to choose it recently.

  7. Jacob says

    Well the fact of the matter is that all of the solutions are cross platform and the only one that is not open source is the AVRISP (though o/s ISP programmers do exist). For that reason, I didn’t really feel a major need to highlight it.

    I guess I could have dealt with hardware a bit more, but then again, there is not one universal configuration in ISP programming that works for all projects.

  8. Kai says

    I’ve been programming AVR chips in C using ISP/JTAG, but using Arduino based hardware in addition to breadboarding. Like Winston I like the Boarduino and also the Sanguino (ATMega64 based board). That said I have two decades of programming experience but very little electronics background so figuring out electronics bugs has actually been quite entertaining and educational.

Continuing the Discussion

  1. Getting Started with AVR Studio | uC Hobby linked to this post on January 4, 2009

    [...] this article Jacob Woj continues with his getting started with Microcontroller projects theme. In the first article he compared the Arduino, Make Controller Kit, and more direct programming using AVR-GCC and an [...]