Author Topic: PIC first impressions  (Read 2906 times)

0 Members and 1 Guest are viewing this topic.

Offline Razor ConceptsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
PIC first impressions
« on: April 27, 2010, 08:39:10 PM »
Well, after nearly two years of using AVRs, I am branching out to learn PICs. So here is a quick overview of my opinion.

The Microchip equivalent of AVR Studio is MPLAB, and both are free. However, AVR Studio compiles all AVR chips, but MPLAB has limited compiler support. Instead, you have to install separate compiler plugins - mainly because they want you to pay for it. For now I'm using a free lite version of C18 by microchip.

The Microchip equivalent of the AVR ISP MKII is the PICkit 2 or 3. 3 is the newer one, but with some bugs so I went with the PICkit 2. The version I bought also came with a daughter board with the popular 16F887, which brings me to my next point...

Naming of the PIC chips is garbage. The first part, like PIC10F, 12F, 16F, 18F, etc make sense - each higher number is a slightly more powerful family of PICs. However, after that, it seems completely random. AVRs are fairly nice with predictable number patterns - 640, 1280, 2650, etc or 48 88 168. PIC is just weird, and higher numbers have no significance.

Getting started, however, is VERY easy. Basically, I installed what looked to be necessary - MPLAB, and some PICkit 2 software (drivers?). MPLAB started up nicely, and I just had to click on project > open and found the starter tutorials for the daughter board - in ASM unfortunately. But I simply selected the PICkit 2 as the programmer (and it said nice things like "PIC16F877 detected" "Ready to go" etc etc. Hit build all, it built, again with nice lines of text indicating what it was doing. I hit program and within a second it was programmed. Wow, no hassle.

Next challenge - my goal of learning PICs was for my quadrotor project which uses a PIC18F2620. I built up a simple "breakout" board, with just the chip, crystal, and ICSP header. A great feature of the PICKIT 2 is that if it doesnt detect that the target is powered, it will power it! No need to lug around batteries anymore for simple things. Anyways, I opened up the project files I downloaded from the net, and hit compile, where I found out I needed the C compiler. I installed it, and a quick google search later I had it configured. Hit compile, it worked, hit program, it worked! Never been stumped at all, unlike AVRs with "unknown device error (-7)" or other cryptic messages.

Some other features - the ICSP header is a 6x1 header, as opposed to the 2x3 header for standard AVRs. Also, the PICkit 2 doesnt have a cable, the female sockets are built into the housing. The PICkit itself is small enough so that you only have to leave a little space for the PICkit to fit, or just make a simple cable. The 6x1 setup makes for very simple wiring. The 6th pin isnt even used. Two for power, two for I2C programming, and one for reset.

Well, that's about it, I haven't dove into the actual coding, but that won't be for a long time. For any of you not wanting to jump into PIC because it seems daunting, well, it isn't! It took me about 30 minutes to solder the breakout board for the chip and get it programmed.
« Last Edit: April 27, 2010, 08:41:32 PM by Razor Concepts »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: PIC first impressions
« Reply #1 on: April 27, 2010, 09:27:22 PM »
Hi,

Other features of the PICkit2 is that you can load it with a file and bring it to somewhere the board is and then program it without the PC connected.
And there's a mini version of a (slow) logic analyzer built in.
And you can debug several of the chips in-circuit.

And, there's speedy delivery if it's in store. I ordered one of them Saturday, Sunday it wasn't even being picked (closed down for the weekend of course), but I had a call Tuesday morning from a local courier that wanted to know when I was at home so he could deliver it, pretty good for something sent by ship Monday (I arranged for him to wait, as I have a batch of chips coming from their Thailand facility in a few days, so no need for him to burn more gas than needed - I won't get around to play with my new toys for some days anyway).
I'm looking much forward to it though, as it should be better than my present burner w. support for all the new stuff, except the 32 bit processors unfortunately. I hope they get the ver. 3 sorted out soon, as I really would like to have a go at their 32 bit controllers soon.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

paulstreats

  • Guest
Re: PIC first impressions
« Reply #2 on: April 28, 2010, 05:53:57 AM »
A few other things...

C18 free compiler is really only limited in its compiler code optimizations. Other than that, its fully functional.

The MPLAB environment offers many other features like being able to watch code space and memory usage, monitor registers and stacks and allow code simulation. The Pickit 2 allows you to download your code onto a pic and then step through it or run it slowly so you can monitor what happening.

I only ever really use PIC's at home now,the only thing is getting used to them, and going through the datasheets to learn the register names.

The 18F4550 is fully USB functional too...

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: PIC first impressions
« Reply #3 on: April 28, 2010, 07:36:30 AM »
Nice review of starting with PICs.

MPLAB does fully support all PICs and assembler code. Its the C compilers, form Microchip and third parties, that are options but they do fully integrate into MPLAB and the Simulator, programmers and debuggers.

The PIC part number prefixes do have significance, the 'F' means its program store is in FLASH, older PIC have a 'C' meaning that these require UV erasing before programming, and 'L' is a low voltage part.
10F - are small limited pin count (6-8) PICs with 12 bit wide instructions and 8 bit data
12F - Base-line that have a little more functions than the 10Fs, 8-14 pin and 12 bit wide instructions and 8 bit data
16F - Mid-range with 14-44 pins and 14 bit wide instructions and 8 bit data, also with added features like UART, SSP.
17C - High-performance line but are considered obsolete
18F - High-performance line that are FLASH and replace the 17C parts. These have 16 bit wide instructions and 8 bit data, larger code and RAM space deeper stacks & hardware multiplier. The instruction set is different than the Base & Mid PIC and was designed for optimization with C code.
24F - 16 bit data verse the 8 bit data of the lower numbered PICs
30F, 32F, dsPic - More memory wider data faster clocks. Again different instruction sets that are larger and more powerful.

I haven't yet used any PIC higher than the 18Fs so my knowledge of the 24's and up is very limited.
The differences of the different PIC families instruction sets and processor architectures is a good reason to have different compilers for C code. MPLAB and MASM does support all of these PICs.

Microchip does have a larger number of different PICs now and it can be difficult to work out which one is best for your project. Hope that helped.

Offline arixrobotics

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
Re: PIC first impressions
« Reply #4 on: May 04, 2010, 07:07:07 AM »
How come everyone is saying all the good stuff about PICs?

I've used PICs and dsPICs in a couple of projects before, and the most annoying thing that I've found is that at certain times they somehow seemed to be 'dead' for no reason. To get them 'alive' again, depending on the chip, sometimes I had to reboot the computer, sometimes I had to just change to another chip and come back to the 'dead' chip after a couple of months, and sometimes I had to erase the chip for about 20-30 times. And sometimes none of these worked.

I don't know if this is normal for a uC, or is it just PICs or is it just my bad.

But then again, its PICs all the way for me!  ;D

Offline GearMotion

  • Supreme Robot
  • *****
  • Posts: 489
  • Helpful? 24
  • Two decades+ of Embedded Design
    • CircuitGizmos
Re: PIC first impressions
« Reply #5 on: May 04, 2010, 07:14:53 AM »
I say a lot of negative things about PICs (I have my reasons) but one positive thing I'll say is that some will take a lot of electrical abuse.

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: PIC first impressions
« Reply #6 on: May 05, 2010, 08:39:30 AM »
After programming AVR for almost 4 years.... I can't say I'm gonna switch as easy.... especially now that I know C...
And also even more used to AVR core and registers... PIC chaos between families frightens me....

Also with the new Xmega gaining a serious foot out there I think I'll just switch to them than PIC for processing power....

Have you tried AVR studio with an STK???
It's exactly the same as you describe with PIC.... and it's even free.... Unless you go with IAR...

I'm an AVR guy.... sorry... :-P
For whom the interrupts toll...

 

SMF spam blocked by CleanTalk