Escolar Documentos
Profissional Documentos
Cultura Documentos
OK, I know what you people want. You want ultimate fighting,
embedded E.E. style. You want to know WHICH IS BETTER, PIC OR
AVR?
Well, I know what side I'm placing my bets on (AVR of course) but for
99% of beginners, it doesn't matter too much which way you start.
Regardless, I'm tired of answering the same questions over & over, so
here we go!
Wait, what?
In the last few years, D.I.Y. electronics has taken a major leap forward
with the introduction of powerful yet low-cost, easy-to-program
microcontrollers. In this case I'll be talking about 8-bit micros, since
those are so popular. These chips cost a couple dollars, around $5, can
be programmed with a PC and a cheap programmer (usually on the
order of $30). They often have a few K of program ROM, around 1/2K of
RAM and some EEPROM. Theres some 'peripherals' such as built in
PWM, timers, A/D converters, etc.
I am not really an expert here, so please help me fill in this page with
more useful info, post it in forum! and make the topic something like
"PIC v. AVR". Please keep in mind that this page was originally written
in 2004.Thanks!
Packages
This is the first point, one which I think is pretty important. If you're doing
one off/prototype projects, you'll want a chip thats easy to work with.
That means DIP packaging.
Luckily, both AVR & PIC have lots of chips in DIP packages.
Price
Price is a tough one to compare because sometimes one chip will have
more peripherals or RAM. So I'll compare three chip-sets, an 8-pin chip,
a ~20-pin chip and a 40-pin chip. They're also comparable in 'power,'
but you'll have to trust me on that. Prices are for single pieces from
Digikey
Winner? I think the numbers are pretty comparable. So I'm going to call
it a tie.
Languages
Assembly: OK, yes of course you can write in assembly code. Both PIC
and AVR have free assemblers available by default from Microchip
(MPLab) and Atmel (AVRTools) for Windows. For AVR, there is also a
free unix command line assembler avra so you can run it under MacOS
X (which I've done successfully) or Linux. Likewise, PICs have gpasm,
which I've never used but I assume works good.
Overall, I've written some asm for both processors and I hate to break it
to PIC users but writing assembly for PIC is akin to stabbing myself in
the face. (Except its not even that efficient, cause you have to more the
knife into the working register first (movlw KNIFE), and then you can
stab yourself (movwf FACE).)
For people who've written assembly on other platforms, I'd compare it to
writing Intel assembly v. MIPS/RISC style. The Intel platform is
convoluted and very CISCy, whereas MIPS-esque processors have
fewer, simpler instructions.
At least AVRs dont have 'memory banks,' a true horror that makes
hand-written code, especially that with interrupts, nigh impossible.
Winner? On the matter of assemblers, its a tie but in the matter of
assembly itself, AVR is a clear winner.
There's also, apparently, a free compiler for PIC but I havent heard
much about it. Can someone send it in a note? There is a free compiler
for PIC available from Microchip, Dan Nguyen writes:
About the free PIC compiler, you just download it from the
Microchip
website and you can use it in the Microchip MPLAB IDE.
IT's actually
the student version and the only difference is that all
features are
only enabled for the first week. After that the only thing
that changes
is you can only have the compiler "optimize" your code to
level 2
instead of all the way- but most of the optimizations aren't
needed at
all and if you like your code to run exactly how you typed
it,
optimizations aren't for you.
There's also SDCC which I used to use a long time ago and was not a
fan of. However it is free and open source and compiles C code for
many (but not all) of the PIC devices.
On the AVR side pretty much everyone uses avr-gcc, a targeted version
of gcc for the AVR microcontroller. Theres a lot of good things about it.
One, it's completely free & works for Macs, Linux, Windows in a nice
distribution. Second it's 'real' C, which is great when you want things like
standard libs, includes, linking, unions, structs, and pointers (CCS at
least, struggled with these). It also means that porting code is really
easy because everyone uses it (all of PIC compilers aren't 100%
compatible). Third it generates good (fast, small and correct) code: the
optimizer is the same as in every other gcc.
Winner? I'm giving this one to AVRs: a free high quality compiler with full
optimizations, constant updates, supports all devices, and that is
completely cross platform? Hard to compete!
BASIC: I dont write code in BASIC so I dont have a lot of information on
this. I know that the Parallax BASICstamp boards are popular (see
below). I believe that they use the microEngineering Labs BASIC
compiler and I'm sure this compiler is pretty good. $99
On the AVR side, there's BASCOM. Also havent used it. $99
I don't know too much about IDEs although I have played with both AVR
Studio as well as MPLAB and many people say that MPLAB is superior.
Granted, I haven't used the most recent MPLAB (I quit it around 5.x).
They're about the same, offering an easy assembler access.
Winner? Tie!
Caveat: Neither have reasonable C-compiler support, and both only run
on Windows. Mac? Linux? You don't get an IDE, roll one yourself.. So
they both lose in this regard
Note: Eclipse has been suggested to work with WinAVR but I couldnt
quite get it to work myself. YMMV.
Note2: CodeBlocks supports both PIC and AVR and FIRST uses it. If
those teenagers can do it, so can you!
Winner? I'm leaning towards the PICKit1 here, since its cheaper.
These are slightly different than the 'open ended' dev boards above.
These are more for people who are really starting for the first time with
Microcontrollers. There are two real options I see
People support
PIC's and AVRs both have substantial support forums at PIClist and
AvrFreaks. From cursory observation, the fact that AVRfreaks has a full
featured website with forums (with threads!), projects, archives, RSS,
device comparisons etc. gives it ++ points of a mailing list that from their
own admission is constantly inundated with requests to unsubscribe. It
does have a projects selection and archives, despite the webpage looks
like it was made in 1997. (I dont particularly think that mailing lists are
an effective way of sharing electronis info for beginners)
On the other hand, both sites have badmouthed me & this page so I'm
takin this prize away! :-)
Winner? Neither!
Integrated Extras
One of the things you may want with your microcontroller is some
weirdo-extras like Ethernet, CAN, RF or USB support
Winner? PIC!
http://www.ladyada.net/library/picvsavr.html