37

Which family should I start to learn? (Never did any programming on microcontroller)

freespace
  • 16,529
  • 4
  • 36
  • 58
Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341

20 Answers20

54

Today AVR and PIC are probably the most common microcontrollers among hobbyists. Both have a very wide range of device variants and both can be used to achieve similar results.

For a beginner I would suggest AVR due to various reasons:

  • AVR family (tiny, mega) is coherent and easy to understand. The architecture is powerful and modern, and is especially suitable for C compilers. AVRs can of course be programmed in assembly too.

  • Due to its C-friendly architecture, there are quality C compilers available, both commercial and free. The ubiquitous GCC is ported to AVR and called avr-gcc.

  • For getting started all you really need is a handful of basic components, the AVR chip itself and a breadboard. Even the programming cable between PC and AVR can be built essentially for free (a so called wiggler). However, several commercial development kits are available, most notably Atmel's own STK500. A commercial development kit is more expensive way for getting started, but doesn't require practically any prior knowledge about electronics. Some development kits contain for example LCD displays so it's easy to get interesting stuff done.

  • It has a rich hobbyist community.

PIC is notorious for its peculiar architecture. Many love PIC for this, some hate it. AVR is more straightforward and doesn't seem to cause as much extreme and polar opinions.

Both AVR and PIC are used in many serious commercial applications. However, they are not the only options of course. My personal favorite microcontroller for both hobby and commercial work is Silicon Laboratories' C8051 family, most notably C8051F530. There is an excellent free C compiler and assembler for the C8051 family called SDCC.

Summary: There are lots of options, but please don't let that overwhelm you. Just pick one and start learning with it. Microcontrollers are, really, surprisingly easy to master once you just decide to get going!

smt
  • 1,171
  • 1
  • 10
  • 13
  • Thx, I ordered for Christmas the Arduino board to start with it (ATM 168 ... AVR) – Patrick Desjardins Dec 11 '08 at 20:41
  • 3
    This writeup is outdated by years, and only goes for the legacy devices PIC12 and PIC16. The pincompatible PIC18+ got a hw stack, and are orthogonal enough to be programmed in C (albeit with a 256 byte structure limitation) The 16-bit line comes with gcc _standard_. I mostly chose for PIC due to the great variance in devices and periphery. – Marco van de Voort Jul 07 '09 at 08:04
  • 4
    @Marco: It was your own imagination that "outdated" the writeup. There's no mention that PICs couldn't be programmed in C. But as you know, programming PICs in C (especially the older ones) isn't as straightforward as it is with AVRs due to pitfalls in the PIC architecture. Life tends to be easier with an AVR, and that's why I consider it more suitable for a beginner. But hey, you just proved my claim that whenever a PIC is under debate, there's shouting. :) – smt Jul 13 '09 at 19:08
  • 1
    Again, that only goes for a few legacy devices. Microchip has been promoting the PIC18 followups (that are pincompatible) for years now, and they are cheaper. Is the state of AVR really so sad that you need to play up such artificial difference? – Marco van de Voort Jul 14 '09 at 08:07
  • Hi guys,can you take a look at http://stackoverflow.com/questions/1447502/whats-the-difference-relationship-between-avr-and-arduino? – omg Sep 19 '09 at 02:20
  • Just as a small update, I want to add that AVR programming is much cheaper too. With any microcontroller, you need a programmer to program it. While it will run you upward of $30 for PIC (assuming you're just starting out with this stuff and don't know how to DIY, which would still cost you at least $15), you can grab a wonderful little programmer compatible with a huge array of AVR devices called the USBasp. The best part is that it only costs $3-4 - check out eBay. I've been using these extensively for months, and they are excellent! If you have an Arduino, can use it as a programmer too. – capcom Jan 17 '13 at 12:58
  • capcom: there are cheap pic programmer clones too. Basically they are all just SPI so the only difference is firmware. – Marco van de Voort Oct 07 '16 at 18:18
11

My boss picked up the basics using AVR within a week without prior experience.

J.J.
  • 4,856
  • 1
  • 24
  • 29
8

I would suggest AVR. It has far surpassed PIC as the microcontroller platform of choice for general hobbyist projects. Most notably, consider the Arduino (and other *duino) platform, which provides a high end AVR in an easy to interface and popular form factor.

Sparr
  • 7,489
  • 31
  • 48
  • Arduino also comes in handy when you start buying expensive robot toys :D – ryansstack Jun 11 '09 at 00:32
  • 1
    Arduino is mostly only interesting if you are not able to design/create/solder your own simple PCBs. – Marco van de Voort Oct 14 '11 at 13:24
  • @Marco why design something when you already have one designed to fit your requirements. Its like reinventing the wheel. – 4aRk Kn1gh7 Jun 28 '14 at 19:30
  • Arduino is mostly targeted at beginners. If you try to get beyond the very simplest stuff, the wheels fall off IMHO. – Marco van de Voort Jun 28 '14 at 23:12
  • @MarcovandeVoort You might be thinking of popular Arduino tutorials? The arduino platform is just an AVR microcontroller with a bootloader and a few peripherals on a breakout board, no less powerful than those same components on a breadboard. – Sparr Nov 11 '14 at 20:42
7

I very much prefer the AVR over PIC, whose architecture I find a bit messy. This may be just me, and it won't trouble you if you can write in a high level language, most likely (some dialect of) C.

Since you're new to microcontrollers I presume performance will not be the issue, so instead I would look for availability of development tools: prototyping boards, IDE and simulation/debugging tools. Personally I liked AVR Studio (Atmel's free development environment) a lot.

Jason mentions the TI's MSP430, which is an excellent controller indeed, especially if you're in very low power applications. But I wouldn't recommend it for a newbie, since configuration is a bit cumbersome. (I recall that the description of the oscillator covered 20+ pages in the user manual.)

stevenvh
  • 2,971
  • 9
  • 41
  • 54
6

I've done some PIC programming - mostly because I liked the idea the chip were only a dollar or two. However, for a beginner, making a decision solely on price is premature optimization.

Programming in assembler is an experience. You basically have to learn about 100 concepts before you can blink an LED. (Watchdog timer, reset pins, 8-bit counters/overflows, delay loops, hex, binary, bit-masking, interrupts, interrupt service requests, IO ports, etc.) It's all very educational - and a great feeling to get so close to the machine - but being able to code something in C will hide some of this complexity so you can focus on results. For this reason I would say go with the AVR. (And I believe the prices are now closer to PICs.)

Also: If you're interested in getting things done (and don't mind spending ~$30) check out the arduino. A guy selling them at my local electronics shop was saying he's selling tons of them to art students. (It uses the IDE from the Processing project, and compiles code with avr-gcc.)

Update: Fixed comment that Arduino runs interpreted code. Also updated the approx Arduino price.

Jason Moore
  • 7,169
  • 1
  • 44
  • 45
  • Arduino is NOT interpreted! It is pure C/C++ that gets compiled down to native machine code. I'll give you that the Arduino library is not the most efficient software, but it's definitely not interpreted. – davr Feb 18 '10 at 06:33
  • You're right. I was confused by the fact that the IDE is from the Processing project. I've also used the Arduino much more since I originally wrote this. Updated. – Jason Moore Feb 18 '10 at 20:59
6

Some people commented on the strange (and C unfriendly) architecture of the PIC micro. This is true of the smaller PICs, but the 16 bit chips (PIC24F, dsPIC30, etc) have very clear architectures that work very well with C.

The PIC24F line has the ability to assign pins to functions (timers, A/D, serial I/O) on the fly, making it a bit easier to design with. The MPLAB environment for debugging and development is quite nice.

J. Peterson
  • 1,996
  • 1
  • 24
  • 21
  • (the 8-bit PIC18 is already significantly better with a compiler, but they still have segmented memories (256 byte arrays/structures maximally) They are even cheaper, since PIC12 and 16 are legacy. I migrated to dspic33 33F128jmc510, but still use 18F60's because they are the only ones with ethernet integrated. Integrated ethernet should have arrived in the 16-bit cores already, but it seems the crisis slowed it down. – Marco van de Voort Jul 07 '09 at 07:55
5

My vote goes to PIC for the extreme variety of devices availables. But I must say that when I started to use PICs, they was almost nothing else. Maybe now things are changed.

Axeman
  • 349
  • 1
  • 7
5

I vote for TI's MSP430 series. I've used PICs extensively (also Atmel chips a little) and by far the most important thing to me is a good debugging IDE. TI has done a pretty good job on this, and their C++ compiler works really well. You can get going with an eval board for less than $100 including an IDE + USB-debugger. The PICs have better & more diverse hardware peripherals, but MPLAB is a piece of crap and the only C++ IDE for PICs is one by IAR which is rather expensive. (more than $2K)

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • postscript: MPLAB X (based on NetBeans) is a huge improvement over the old MPLAB. I work at Microchip now, and one of the reasons I did so is because I heard about MPLAB X. The 32-bit microcontrollers have the free C++ compiler XC32; the 8- and 16- bit microcontrollers are limited to C. – Jason S Nov 11 '14 at 13:45
  • Even with MPLABX, the XC8 compiler stills beeing a piece of crap, there is no librarys for baseline and mid-range, is a desperate trying to import your own libraries since XC8 doesn't support as I said. On the other hand, there is the CSS compiler, but I also hate it since is far away from the standart C. Eventhough I'm a really intensive user of Micrichip devices, so, I'm trying to move to SDCC compiler, and also Migrating to MSP430 (16 bit but simpliest as an 8 bit micro) and 32 bit TM4C ARM Cortex (some hard but really overfeatured) *-*, and in less manner 8051 family too. – Daniel N. Apr 08 '15 at 13:07
5

I don't understand what the big deal with arduino is, it will ruin your chance of ever understanding what is actually happening. I program with AVR's and PIC's regularly, basically there is not much difference, I can't see what the big fuss is all about. However for a beginner stay away from arduino, it may be simple, but thats the trap, it gives you no concept of hardware architecture, and no idea what is happening behind the scenes, the stuff beginners need to learn to be an effective programmer. When I was a beginner I started out with an ATmega32 a $20 USBasp programmer, AVR Studio (Free) and AVRDude (Comes with WinAVR) and followed the intro tutorials in AVR Freaks. That is all you need, Done!!!

P.S. If you want to really learn how to program micros and have the time learn the assembler for your micro and you will be 20 times the C programmer than someone who started out using arduino.

Troy
  • 59
  • 1
  • 1
  • 1
    I think the purpose of Arduino is different than programming PIC or AVR. I have an Arduino at home and a PIC, and maybe I will get some AVR chips as well to compare it with PIC. I got the PIC to learn about microcontroller architecture and do meaningful assembly programming. Arduino is for getting projects done quickly. – Hugo Estrada Mar 05 '11 at 13:07
  • 3
    My own experience is the exact opposite of what you say: I started with an Arduino and was amazed at how easy it is. Then, after the first successes, I dove into the MCU datasheet, learned avr-libc, got into poking the registers directly, started learning assembly... Now my Uno serves mostly as an USB programmer for my other AVRs. Looking back, I realize the Arduino was the opposite of a "trap". It was a great learning experience that made the learning curve easier and gave me the motivation to learn more and dig into the lower-level details. – Edgar Bonet Feb 28 '14 at 11:58
  • The first sentence very much wraps up the problem with Arduino. – Joris Groosman Dec 23 '15 at 10:23
  • @EdgarBonet I have had a similar experience. Arduino is supposed to be a quick-start/prototyping platform and is excellent for its intended purpose. If someone is interested, they can dive as deep as they want. It's a great teaching and learning tool on an abstract level before digging into the details. – shredalert Oct 19 '18 at 12:25
5

I/we chose PIC mostly because there is more peripheral hardware for the same price. And more importantly, you can't even find comparable AVRs. I did choose one of the legacy free versions though (started with PIC18, migrated to dspic33)

The IDE is free, the (C) compiler is free in the student version (that disables optimization after the first month). Entry level programmers are fairly cheap too. If you have heaps of interrupts, counters and timers, there is a chance you won't need optimization at all. A programmer straight from Microchip is $30.

Note that the above remarks about AVR catering more to HLL development are slightly outdated unless you really go for the legacy architectures like PIC12 and 16.

One typically programs the more modern PIC18 (8-bit) and the 16-bit architectures (24F,30F and dspic33 which are based on the same principal core) in C. The 16-bitters even use GCC. There are also MIPS based 32-bitters now, but they rival more with ARM in the audio/video processing scene. Strangely enough, the modern ones are often cheaper than the old ones. Probably they are produced on in a more modern process that has higher yields.

Another note: meanwhile Microchip/PIC bought Atmel/AVR, but I assume that for the first few years that won't affect the productlines much.

I'm really looking forward to the 60MIPs ethernet enabled 16-bitter that is going to be released this summer (afaik streetprice just above EUR 10)

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • Superb simple documentation is what made programming (in assembler) the PIC16F84 a delight for me. The data sheet (PDF) is a joy to read. To be honest, good documentation is what makes any product fun to use for me. – PP. Aug 27 '10 at 07:20
3

My first experience with microcontrollers was with an OOPic-R. It allowed me to make simple robotic experiments without worrying too much about the code. The object oriented programming flow makes everything work fast and is easy to program.

Recently, I tried another variety of PIC's, the dirt cheap PICAXE. The included programming interface is a breeze to work with. Also, to physically interface the PICAXE, you only need an RS-232 port to program it and two pins on the chip (no need to do level shifting). I've embedded the PICAXE in very small containers (SMD and DIP chips available) and it has worked quite well.

I have no experience with programming microcontrollers in assembly. If you want to try that, the AVR might be more suitable because of it's bigger user community.

As far as I know, the cheapest way to program an AVR using ATMEL's tools is the ATMEL AVR ISP mkII for 35$. You can find third-party programmers for 10-15$.

JcMaco
  • 1,258
  • 3
  • 16
  • 31
  • 2
    The cheapest way to program an AVR is with $0.25 worth of resistors and some wires, connected directly to your parallel port. Next there are 3rd party tools which start around $10-$15. Then there is the official Atmel programmer AVR ISP mkII which costs $35. The Dragon is a specialized tool that has some unique features, but it is definitely not the cheapest way to go. – davr Feb 18 '10 at 06:32
  • Is the information for doing this the cheap way in AVR Freaks? – Hugo Estrada Mar 05 '11 at 13:03
3

If you just want to know what is MCU programming, start from Arduino is a good idea. It's cheap, with a novice-friendly IDE (based on processing programming language, which has a similar syntax with C).

But this did not answer your quesiton, beacuse altough Arduino is based on AVR, you cannot feel there is an AVR MCU behind that modern IDE. :)

rIPPER
  • 447
  • 4
  • 12
3

I had much more success with PIC while I was just getting started. I tried to get a simple starter kit from Arduino and just couldn't get a good basic kit without spending more than $100-200 nickel and diming the setup together. Got a great little starter kit from PIC for about $40 and it has everything: IDE, programmer, starter board with built in circuitry for demos and tutorials. One purchase. Also, the PIC environment was very easy to get set up and working. I was playing with it within an hour.

PaulG
  • 401
  • 1
  • 6
  • 6
2

I would make my choice based on availability of a C cross-compiler. In the past, that would make AVR the choice. I'm not sure what the status is now.

I've programmed a PIC in assembler, and it was not much fun. C is much nicer in many ways.

Craig McQueen
  • 41,871
  • 30
  • 130
  • 181
1

I would say that i fount the 8051 microcontroller the most easiest and Atmel has come up with microcontrollers with so many inbuilt functions .... but still people are more preferably using the AVR's... my hand would go up with the 8051 family ( if found comfortable ) else the AVR's ...

Dharavk
  • 498
  • 2
  • 6
  • 17
1

I love AVR. its easy to program and resources available. there are few community like arduino works with it.

Shuvro
  • 11
  • 1
1

http://www.arduino.cc/

HTH

plan9assembler
  • 2,862
  • 1
  • 24
  • 13
1

On of the best features of AVR is the community in the forums at www.avrfreaks.net. You get a bunch of experienced electronics engineers hanging out, willing to help newbies to get going.

markus_b
  • 4,433
  • 2
  • 19
  • 15
0

Some more dicussion about the superiority of AVR, on the other Stack Overflow: http://embeddedgurus.com/stack-overflow/2009/04/pic-stack-overflow/

The popularity of 8 bit PICs baffles me. It’s architecture is awful – the limited call stack is just the first dreadful thing. Throw in the need for paging and banking together with the single interrupt vector and you have a nightmare of a programming model. It would be one thing if this was the norm for 8 bit devices – but it isn’t. The AVR architecture blows the PIC away, while the HC05 / HC08 are also streets ahead of the PIC. Given the choice I think I’d even take an 8051 over the PIC. I don’t see any cost advantages, packaging advantages (Atmel has just released a SOT23-6 AVR which is essentially instruction set compatible with their largest devices) or peripheral set advantages. In short, I don’t get it! Incidentally, this isn’t an indictment of Microchip – they are a great company and I really like a lot of their other products, their web site, tech support and so on (perhaps this is why the PIC is so widely used?)

Gauthier
  • 40,309
  • 11
  • 63
  • 97
-1

I started on a Motorola M68HC11, it was simple enough. I think you'll get about the same experience with any 8Bit controllers.

Issac Kelly
  • 6,309
  • 6
  • 43
  • 50