Electronics A few PIC questions...

Discussion in 'Modding' started by compjinx, 13 Mar 2005.

  1. compjinx

    compjinx What's a Dremel?

    Joined:
    21 Feb 2004
    Posts:
    61
    Likes Received:
    0
    I have been wanting to get into PIC programming. I am thinking about purchasing this
    http://www.microcontroller.com/news/microchip_pickit.asp
    in order to start off this new hobby.

    Now, I am kind of confused as to which PICs I should actually purchase.
    I looked up some on Mouser ( http://www.mouser.com/index.cfm?&ha...Ckit&Ntt=*PICkit*&Dk=1&Ns=SField&N=0&crc=true ) but they all have odd postfixes... I/P? I/SL? Are these even the ones I should be getting?
    As a person who just wants to tinker around and learn how to do this, which PICs should I get? Obviously ones that are reprogrammable are what I would need, but I am not quite sure how to determine which ones can and which ones can't be reprogrammed.

    Any light on this subject would be appreciated.
     
  2. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    i'd recomend against the FLASH usb kit.

    google up a JDM programmer, and IC Prog.

    thats a very low cost ($5) way of programming a wide range of PICs.

    As for PICs themself, depends on what ur doing, first of i'd get some 16F88's and a 12F675, mabye a larger one like a 16F877A.

    Then once u've learnt about the 'hardware' features, and seen how little memory you need when programinng in MASM, you will be able to pick the PIC best suited to your projects.

    make sure u've got some nice prototype board, a few LEDs, some tantilum bead capacitors (for de-coupling) and some buttons.
     
  3. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    The following PICs might be useful in addition to the ones TheAnimus suggested: 16F870 or 16F872 (they're quite similar so one or the other), 16F648A, and maybe the 12F683 which is the upgraded 12F675. You'll also want the I/P or I/SP types.


    For a programmer, I'd also recommend the cheap option of just a JDM and icprog. You'll require a serial port though.
     
  4. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    I second most of that.

    You can purchase a JDM programmer for less than $10USD. It works with a free programmer software called ICProg.

    For chip types, always get the 'F' version as Animus said (ie- 16F, 12F, 18F...etc). These are the flash reprogrammable types that do not need a UV light to erase.

    As for the suffix, try to stick with I/P. This stands for industrial speeds in PDIP package. Ive had some problems using the speed suffix parts with the JDM programmer (ie: -20/P, -4/P etc).

    To start learning, I highly suggest either a 28pin (16F873, 16F876A) or a 40pin (16F874A, 16F877A) PIC since you can have multiple 8bit ports without sacrificing other peripherals.

    A list of suggesting starting parts for learning:

    The PIC (duh).
    0.1uF tantalum caps for decoupling
    4 or 20 MHz ceramic resonator (easier than using a crystal oscilator)
    A resistor kit (I really like the 500pc set from all-electronics)
    A breadboard
    LEDs (either an LED bargraph array or single rectangular LEDs are the best)
    small momentary push buttons
    either a 5V wallwart or 12V walwart with a LM7805 voltage regulator

    A more advanced list would consist of ULN2803 for driving higher current loads, opto-isolators for input protection, 24C256 I2C serial memory chip, an HD44780 LCD for display, tec.

    You can find most of this stuff from www.glitchbuster.com, he carries PICs and all the support stuff for pretty cheap and is real trust-worthy. His shipping is dirt-cheap and requires no minimum order (unlike digikey).
     
  5. agray1

    agray1 What's a Dremel?

    Joined:
    12 Jan 2005
    Posts:
    9
    Likes Received:
    0
    Picaxe

    If you're new to PIC programming or don't want to program in C or assembler then you could take a look at www.picaxe.com

    Just depends what level of programming you are wanting to use.
     
  6. kbn

    kbn What's a Dremel?

    Joined:
    17 Mar 2004
    Posts:
    603
    Likes Received:
    0
    I was learning to use pics... but I think ive almost given up now.. untill I thinkof some thing really usefull I can do with them...

    Make sure you get a chip with plenty of I/O's to start off with...

    I would recoomend the one Hazer used with his tutorials (the link in his sig) becuase then you can follow them much easyer. I bought a 12F675 and I cant really find much code to use with it.. even on google... and im useless at coding atm :)

    Also give lots of thought to what you want to do with the pic, and buy the other parts you would need to do it.. - something I keep forgetting.. atm I only have a few leds.. which makes anything I do with it quite pointless...
     
  7. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    picaxe eat memory, cost more, and make baby jesus cry.
     
  8. compjinx

    compjinx What's a Dremel?

    Joined:
    21 Feb 2004
    Posts:
    61
    Likes Received:
    0
    Also, anyone know offhand of any equivilent linux programs there are to ICProg or MPLab? I got ICProg running via Wine (I haven't tested serial port access, however). The installer for MPLab crashed in Wine.

    Hmmm... is there another name for the JDM programmer? what does JDM stand for, anyways? I am having a bit of difficulty finding a seemingly reputable web site (ie: one without blue text and animated GIFs on a pink background) that sells a "JDM programmer". Also, you suggest purchasing 28-40 pin PICs, does that mean I have to get JDM with a 40 pin socket?

    How many should I get? There have been about 10 suggestions thus far; should I get one of each? Do I need more than one of a given type? They are reprogrammable, so logically I should only need one of each type (or is it common for a newby to fry them somehow).
     
  9. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    The schematic for the JDM programmer is on the icprog website:
    http://www.ic-prog.com/index1.htm

    There's also one on hazer's website:
    http://members.cox.net/sonjarob/TUTs/uP4Idiots.html

    This schematic will work for most of the devices supported by icprog.

    All of the flash devices are electronically re-programmable.
    As for which PICs to buy, either get one or two of each. At this stage it's not worth getting more than one different type of PIC with the same number of pins, so pick one from each category depending on your needs:

    1 - 8 pin devices: 12F629 or 12F675
    2 - 18 pin devices: 16F628A, 16F648A or 16F88
    3 - 28 pin devices: 16F870, 16F872, 16F873 or 16F876A
    4 - 40 pin devices: 16F871, 16F874A or 16F877A

    A breadboard is a must - you can even build your JDM on the breadboard too.
    Get some resonators or crystals - 4, 8, 10 or 20MHz (2x 15 or 22pF capacitors per crystal (if you go for crystals)).
    Get a regulated supply and some bypass capacitors to put at the supply pins of the PIC.
     
  10. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    www.sparkfun.com has JDM programmers. They carry Olimex programmers of all different types.

    JDM was the first serial home-made programmer that was used by hobbyists. Its relatively cheap to build on your own (like $3 worth of parts).

    If you dont feel like making your own, goto sparkfun and under Programmers-->PIC you will find the PIC-PG2 near the bottom for $13.

    I would suggest that for now you just buy 2 PICs to start with. You can reprogram them 10,000 times. As for which one, thats upto you. I preffered using a 28pin PIC for my tutorial since it gave me 2 8bit ports. But what you want to do with it should ultimately make your decision.

    The PICs followed with an 'A' are newer ones that incorporate a comparator circuit. In my opinion, its kinda useless and makes you have to shut it off everytime you want to do something simple. The PICs with internal oscilators are nice, but if your learning its a pain in the ***. You have to be fluent with timing schemes to know what your getting into, and ICProg starts getting confusing too since it is very possible for a 'newbie' to over-write the factory calibration of the internal osc circuit during programming. 14pin PICs dont allow 8bit ports and make things harder to learn by also. Another consideration is that chips like the 16F688 are very new and are NOT supported by ICProg. You have to be careful about this.

    To be honest, your best bet is to get a 16F874A. Its a 40pin PIC. Its cheaper than the flagship 16F877A because it has half the programming memory, but it will take you some time before you would need it (by then you should be buying PICs for specific projects). It has all the bells and whistles of all the other chips except internal oscillation (which you can live without until your ready). The specs on the chip are:

    3 8bit ports, 1 6bit port, 1 3bit port.
    8 analog channels of 10bit ADC.
    2 capture/compare/PWM modules.
    SPI and master I2C serial modules.
    USART module.
    2 8bit timers and 1 16bit timer.
    2 comparators.
    Internal EEPROM.
    and all the standard uController options such as watchdog timer, sleep mode, brownout detection and code protection.

    IMHO, a good chip for learning the basics and more without getting real complicated.
     
  11. sparkfun

    sparkfun What's a Dremel?

    Joined:
    16 Apr 2005
    Posts:
    1
    Likes Received:
    0
    A customer of ours pointed me to this forum. Thanks for recommending us, Hazer!

    To add my two cents: JDM is a great way to start. The PIC-PG1 and PIC-PG2 from Olimex work very well on desktops. Laptops have low power serial ports and will (almost) never work with JDM programmers.

    I learned on a 16F84A - which is now a really bad choice. Too expensive and few peripherals.

    The 16F874A is a wild one - I've never touched one actually. Any PIC in the 87xA family is good (16F877A, 876A, 874A, 873A).

    My highest recommendation is the 16F88. It is a 18 pin PIC with a ton of features like an internal 8mhz osc (there are few PICs that still use the osc calibration bits - most new PICs use internally trimmed osc instead), 8 channel? ADC, 4K of program space, UART, and a couple others. One really nice feature is that the 16F88 can reprogram itself - a process called boot loading. So can the 16F87xA family, but you'll notice a distinct difference in price with an 18-pin PIC vs a 28 or 40-pin.

    Using a hardware programmer is great for a few months of learning. Once you get used to using the UART and a serial connection to a computer for debugging, checkout our boot loader we scraped together for 16family PICs : Boot Loader
    With a boot loader, you can make the PIC reprogram itself rather than using a hardware programmer. IMHO, *much* faster, much easier, and if you know what you're doing, it's even cheaper than the PIC-PG2 programmer. The only catch is that you'll need some sort of a programmer to get the boot loader onto the PIC. After that, all you do is run a windows program and connect the PIC to the computer via an RS232 converter circuit (MAX232 or a passive shifter circuit).

    Get ready. Once you get into PICs, it's hard to stop tinkering. Soon you'll find yourself cramped for program space and hungry for more speed. Phrases like ARMs and MIPs will make you salivate :eyebrow:.

    Best of luck!
    -Nathan
     
  12. g0th

    g0th What's a Dremel?

    Joined:
    12 Apr 2005
    Posts:
    319
    Likes Received:
    1
  13. Starbuck3733T

    Starbuck3733T Look out sugar, here it comes

    Joined:
    16 Sep 2002
    Posts:
    920
    Likes Received:
    0
    Sparkfun OWNS.

    And I'm a big fan of CCS compiler for C on PICs. MASM isn't hard, but I'm 10X faster in C.
     
  14. ConKbot of Doom

    ConKbot of Doom What's a Dremel?

    Joined:
    2 Jul 2003
    Posts:
    2,160
    Likes Received:
    6
    Yes, the JDM is very effective. You could get by with that untill you decided that you wanted to use an ICD.

    Good luck with your learning.

    PS. Starbuck, check your private messages.
     
  15. iamnafets

    iamnafets What's a Dremel?

    Joined:
    24 Feb 2005
    Posts:
    112
    Likes Received:
    0
    Since this is the "PIC Question Thread", does anyone know of a "8051 compiler/assembler/whatever". I was looking at the PIC Basic tutorials and they were explaining how much simpler their BASIC was than ASM, but 8051 looked a lot nicer than ASM (particularly how it handled a bit test jump, I can't seem to for the life of me put together test and skip). If no one can find one, I may just write one for the heck of it, seems like every sort of compiler/whatever nowadays charges more than every sort of hardware component you could possibly need for your PIC project, which is rediculous. On a side note, I recommend the 16F84A mostly because it's popular online and in books and therefore easier to learn. I got a 16F877 (I think that's right), for later on with the D/A and more IO ports, but I haven't touched it yet (it's so big :)). Thanks in advance for any help guys.
     
  16. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    erm BASIC on uC's is stupid, its clunky and gets in the way.

    aditionally it often stops people learning about a log of the neat hardware functions, makes people think like total beginers for the rest of their life, and actually makes stuff harder (you don't think of tricks with comparitors etc).

    so get a copy of MASM, i much prefer it to 8051 ASM.

    but MASM (MPLAB from www.microchip.com) is RISC remeber, but there are predefined jumping macros, like the 8051's :thumb:
     
  17. iamnafets

    iamnafets What's a Dremel?

    Joined:
    24 Feb 2005
    Posts:
    112
    Likes Received:
    0
    Higher level languages aren't necessarily only for beginners. For PIC programming, when you're not getting too complex it may be an unneeded shortcut (I was looking at CH Basic which throws in 4 variables for loops and stuff even though I hadn't created any, inefficient), but for a computer doing anything besides most rudimentary tasks taking the high level road is definitely not stupid. Meanwhile, I figured 8051 was another assembly notation, not basic, but I guess not? If so, what are these predefined jumping macros. I'll be googling so I may find it, but it'd save me the trouble :)
     
  18. iamnafets

    iamnafets What's a Dremel?

    Joined:
    24 Feb 2005
    Posts:
    112
    Likes Received:
    0
    :duh: I totally misread that, I'm guessing you meant an include file with the macros. Geeeeeez. :duh:

    And a sidenote, just got to Macros in my book/the web. Very nice :) :idea:
     
    Last edited: 18 Apr 2005
  19. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    PICs aren't as stable as i'd like to tell cpemma they are :D

    Hence the watchdog timer, and the need for a good decoupling cap.

    8051 is a CPU type, so i'm assuming you ment asm.

    BASIC on PICs is WRONG, SO VERY VERY VERY VERY VERY WRONG.

    C on PICs when your not doing oodles of flops is wrong, and my god to i HATE CCS, i mean, i would happily pull the trigger on anyone on that team. Its just bug ridden peice of ****. Its so bad someone might as well stick a borland sticker on it.

    High-tech C compiler isn't bad, but again i don't see the point, enless your doing lotsa floating point, but even then once you've got your macro's made, theres little benefit.

    You should find the PIC a welcome break from the 8051, check the "mid range referance manual" for some good tricks, and make sure you get the way the PICs tick (excuse the pun).
     

Share This Page