PIC vs AVRs

Dave

Joined Nov 17, 2003
6,969
n9352527 said:
No enforcement whatsoever, you can go to Microchip site and download the C18 for free. It will function fully (all optimisations on) for 30 days after installation, and after that time it will disable _one_ optimisation only, which is the procedural abstraction.

Procedural abstraction scans the object code and replaces code sequences that appear multiple times with functions, resulting in smaller code size that is slightly slower than the original due to the function calling overhead. The effect of disabling this optimisation is not that severe, properly structured good code might see a few percents reduction in size.
Thanks, I have seen the download link over at Microchip's website, but having the C18 compiler available through work over the company network, I have never had the need to look any further into the free options. Still its good information to have.

Dave
 

TonySang

Joined Sep 16, 2006
1
Hi everyone
I'm a new member. I have a question like this:
Which microcontroller is the best to read signals from incremental encoder of a DC servo motor ? Resolution: 200 pulses/revolution.
Thank you very much.
 

DKNguyen

Joined Dec 31, 1969
0
But the dsPIC30F microcontrollers (only the motor controller series)have some perhiphreals on them geared to read encoders though ( I am not sure about AVR).
 

Larry

Joined Nov 27, 2006
2
Hello,

I cannot say for or against the AVR processors as I have not used them. I have, however done fairly extensive assembly programming with the PIC processors. Microchip has provided the MPlab IDE which has some very impressive features and template files. For example, the base structure for any of their products can be loaded into the IDE as a starting point for your project. Once you have written your code (I only use assembly langauge with microchip devices my preference, not a suggestion) you can use the simulator, which can simulate (using the stimulus controller) interrupts, pin changes, and a whole lot more with timers dependencies etc. to pretty throughly test your software before you even load it into the chip. So I find the free tools from Microsoft great. Perhaps I will feel the same once I use an AVR processor.

Larry
 

BladeSabre

Joined Aug 11, 2005
105
Since this is back at the top, I'll say something about the Microchip C18 compiler and the restrictions on the free version.

As has been said already, the procedural abstraction results in a slightly smaller code size. And for almost everything, you're not going to need it. But there are a small number of specific cases where it becomes rather important. The one I'm soon going to meet myself is the Microchip USB bootloader. If compiled with the free version of the C18, it comes out slightly too big to fit into the boot block.
Another specialist area I have seen discussed on the forums is Zigbee. I don't recall how much Flash was in the PICs that people were using, but the Zigbee code is huge, and needs to be shrunk as small as possible so it will fit in (and leave a little space for the application).
 

n9352527

Joined Oct 14, 2005
1,198
I coded my own USB bootloader precisely because what you mentioned above, the supplied USB bootloader will compile to more than the available bootblock size with C18 evaluation version.

Now, as the result, I have a few hundred bytes free, which I might fill up with some extra features :D
 

enricong

Joined Mar 13, 2007
1
I have some experience a few years ago programming assembly on a 68HC11 and have spent quite a bit of time programming assembly on a RISC based processor too.

I'm working on a small project that will poll 32 discrete IO pins (once every second) and read messages on an async serial interface (at about 20Hz), then send this data via USB to a PC.

I'm looking at two microcontrollers

Microchip PIC18F4450
Atmel AT90USB1287

I browsed the data sheets and both look sufficient for the task.
I've never programmed on a PIC or Atmel microcontroller. I figured I'd program in C rather than assembly so I think the development environment is probably the most important deciding factor for me. A good emulator will be important too.

From reading this thread, it seems that the Microchip software is easier to use but has limitations.

Any advice?
 

BladeSabre

Joined Aug 11, 2005
105
Since you say "a small project", do you have the facilities to handle the packaging of the Atmel one (TQFP 64 or QFN 64)? That was the deciding factor for me; I went with PIC because the varieties I would want to use are readily available in DIP, including the USB ones.
 

n9352527

Joined Oct 14, 2005
1,198
AT90USB1287 is an OTG USB device. You might want to use the USB function microcontroller AT90USB1286 or AT90US646.

I used 1286 last year, the QFN64 package was way too small to do manually, even with steady hands and good iron. The 1286, unlike 1287, didn't have TQFP64, which would be a better option to solder manually.

Like BladeSabre said, it might be better for you to go with PIC. Unless you want to contract the assembly out.
 

microcoder

Joined Jan 9, 2008
10
Greetings lz5480,

The following reply is strictly IMHO.

Papabravo is correct, your choice of PIC or AVR is largely a matter of what you plan to do with the microcontroller. Both device families have similar features as well as unique features so the process of choosing one can be daunting.

I am blatantly biased as I recently purchased an ATSTK500 Starter kit from Digikey ($80) for use in program development for Atmel's AVR series of microcontrollers.

I chose the AVR over the PIC mainly for economic reasons. Atmel has elected to make all of their AVR series development tools available FREE from their website. You can download their very flexible assembly language development tool called AVRStudio 4.12 from www.atmel.com. The software development tools I looked at for the PIC series cost several hundred dollars.

I am not very familiar with PIC but I believe that the PIC series devices are mainly one-time-programmable. That means that you will probably have to discard the PIC if your code has a bug in it. That means no do-overs.

The AVR series devices are FLASH, EEPROM and SRAM based devices so they can be reprogrammed thousands of times. They are also In-System Programmable which means you can layout your PC board and then refine your program afterwards.

I have had my ATSTK500 for a month or so and it has proven to be a real blast.

I'm certain that the PIC series is a terrific family of microcontrollers with many great features. It is just that the AVR series made more sense for my budget and application.

hgmjr
Almost everything you said about the PIC was wrong. The PIC can be reprogrammed thousands of times, just like every other computer. There are many different flavors of PIC but the ones I am most familiar with have FLASH, EEPROM, and SRAM memory, just like the AVR you described. They can also be programmed in circuit, just like the AVR. In fact, some PICs allow you to install a boot-loader program that resides in memory and can load a new program through the serial port. So, you can distribute updates to your customers if you have them by email or FTP and they don't have to have any additional special hardware to upload your latest release.

I have most recently been working with the PIC16F88, which is very low power, has an internal clock (no need for an external crystal), supports boot loading, has a low-power sleep mode, many different kinds of interrupts, analog and digital I/O, I2C, SPI ports, 4K of Flash memory, etc. The Microchip MPLAB PIC development environment is free and very robust. It includes a free assembler, linker, in circuit debugger, as well as an emulator. The CC5X is a free third party PIC C compiler, although it has limitations. There is a huge community of PIC programmers willing to help folks and tons of free code available, both in C and in ASM.

So, while there might be good reasons for choosing one microcontroller over another, don't make your decision on the basis of what some very badly mis-informed people tell you. In fact, go read some data sheets and see what features the machines have and compare them to the features are that you need. There are hundreds of different PICs to choose from so the chances are that you can find one to meet your needs. And they only cost a few bucks, so you can try one out without a big investment. Do the same thing for the AVRs. This is the only way to really inform yourself.
 

Salgat

Joined Dec 23, 2006
218
I recently purchased the STK500 for programming AVRs, and I am extremely impressed. My first experience with micros was the 68HC11, and compared to that, AVR micros are very feature rich and having 32 registers is amazing. I've found that on many of my programs I don't even need to touch RAM. The one thing that really won me over was how AVR provides a great assembler with a full simulator for free. I was able to program and test out the micros before ever touching one. I guess I'm really biased, but I love AVRs big time (many thanks to hgmjr for suggesting it a while back).
 

hgmjr

Joined Jan 28, 2005
9,027
I recently purchased the STK500 for programming AVRs, and I am extremely impressed. My first experience with micros was the 68HC11, and compared to that, AVR micros are very feature rich and having 32 registers is amazing. I've found that on many of my programs I don't even need to touch RAM. The one thing that really won me over was how AVR provides a great assembler with a full simulator for free. I was able to program and test out the micros before ever touching one. I guess I'm really biased, but I love AVRs big time (many thanks to hgmjr for suggesting it a while back).
Is anyone else having fun with their STK500 development board and AVRs beside Salgat and me?

hgmjr
 

HarveyH42

Joined Jul 22, 2007
426
I started with the AVR Dragon about a year ago, and it's been great. I was most familiar with assembler, and the AVR seemed much stronger in that area over PIC. The free development software for AVR was another point, since it was what was what I found most people were using. Most of the PIC stuff I looked at was done with purchased software, and very little mention of anything free demo that wasn't severly crippled. But if you look around, there are assemblers and compilers for free, but might take some time to learn.

I probably got $70-80 in the Dragon, but haven't had any issues since I first opened the box. For $49, you get a very basic board, which needs headers, ZIF socket, jumpers, and a USB cable. No instructions, CD or documentation, comes when you download AVR Studio from Atmel. Still very happy with it, haven't had any problems or restrictions. It was just the first USB AVR programmer I came across under $100, no regrets.
 

CVMichael

Joined Aug 3, 2007
419
I am not very familiar with PIC but I believe that the PIC series devices are mainly one-time-programmable. That means that you will probably have to discard the PIC if your code has a bug in it. That means no do-overs.
From a data sheet of one of the PICs: "100,000 Erase/Write Cycle Enhanced Flash Program Memory"

The AVR series devices are FLASH, EEPROM and SRAM based devices so they can be reprogrammed thousands of times. They are also In-System Programmable which means you can layout your PC board and then refine your program afterwards.
PICs as also "In-System Programmable", You can map pins, and also re-configure analog pins as analog or digital.

[edit] Ops... after I posted I saw that there are several pages about this, and that you are already corrected about PICs, Sorry... :rolleyes:
 
Last edited:

axeman22

Joined Jun 8, 2009
54
Know 2010 is not far away this thread still ranks high with google.. but.. reading through the comments and noting the time this thread has been running can I say this; I think the PICAXE is almost unbeatable for a beginner. it's super cheap for a 08M chip etc and the programming software is real simple. You can even program is in flowcharts and it's field programmable. I learnt assembler years ago.. and now I just use basic. I'm only JUST starting to read about the limitations of BASIC over assembler. seems to me.. if you're looking for a simple entry point just go PICAXE from Revolution Education(MicroZed in Australia). if you can program in assembler then the world is your oyster and you make your choice between AVR / PIC etc etc.. seems to me AVR might be the go there. I do think you can get a basic compiler for AVR by the sounds of it but with the PICAXE it has it all onboard, you just send your basic code to it and the magic happens. so, for the laymen who;s still a bit gumbie - picaxe - because it's juust so easy, and cheap. I've no doubt the AVr could take the picaxe's place, just seems that Rev Ed have it together for the here and now. not bagging the AVR at all btw, never used one but did do some research into AVr vs PIC vs PICAXE .. picaxe won out for me.
 

hgmjr

Joined Jan 28, 2005
9,027
You can download a full-featured version of Swordfish for free. The only limitation appears to be the amount of RAM it lets you allocate. The full-feature version with no limitations at all is approximately $160 USD.

hgmjr
 
Top