Author Topic: how to choose a PIC?  (Read 16440 times)

0 Members and 1 Guest are viewing this topic.

Offline Kidsam

  • Contributor
  • Posts: 11
how to choose a PIC?
« on: October 13, 2012, 01:53:02 am »
greetings
i'm trying to figure out how to choose a pic, for a couple of future projects of mine, though im not sure how, as i'm pretty new to them

the things i'm looking for on one chip are:
13 or more outputs
PWM capabilities
and the project i want to use it for is a LED array cube, with some animations programmed in
this one may wait untill im more experienced, but i will probably make smaller cubes in the meantime, i figure i need 4 outputs, 4 for each length segment, 4 for height, and 4 for width, and one for PWM , though i could cut it down to needing 9 pins, though it would require using alot more external components

another project is for a small solar powered robot(beambot)
and i hope to use a PIC chip on it
would need 2-6 outputs and low power needs (it would switch on+off alot as power is avaliable)



i've been using http://australia.rs-online.com to look at parts, and i can look up chips for example with 20 pins and PWM capable that look like they would suit my LED projects, however i can find "suitable" chips for $1.20 and chips that appear just as suitable for $8 or so
for example
http://australia.rs-online.com/web/p/microcontrollers/7432647/ $1.87
vs
http://australia.rs-online.com/web/p/microcontrollers/6669848/ $6.50, same amount of pins

so what specifications do i need to actually look at when i buy a chip? are those two chips both suitable for the project, or do i need to look for extra memory or something like that
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: us
Re: how to choose a PIC?
« Reply #1 on: October 13, 2012, 02:30:28 am »
if you are new to PICs, and plan on using the XC compilers, my advice is to use one of the chips that they use for the official development boards.  You don't actually have to use the dev board itself, just the same chip.  I say this because all of the sample code from microchip is built for the official dev boards.  If you use the same chip then you won't have to do much porting.   They usually use good general purpose chips for the dev boards as well.

I know that doesn't really answer your question, but its a place to start.
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: how to choose a PIC?
« Reply #2 on: October 13, 2012, 03:46:01 am »
You can use the product selector tool.

http://www.microchip.com/productselector/MCUProductSelector.html

After that, you need to check which chips that fit your criteria are available from your distributor.

Usually people pick chips that are generic and have a decent amount of peripherals.  It's easier just to grab 20 of those and use them even if they are overkill rather than grab 1 of 10 different uC's that better match the requirements of the individual projects.

There are some common starter ones like 16f877A and 16f628A.  I would highly suggest starting out with one of the enhanced (updated) cores.  The enhanced cores usually come in a LF version as well as a regular F version, the L is for low voltage, which you'll want for a solar project.  I have used a few 16f1933's and for low pin count 12f1840.
Mark Higgins
 

Offline andete

  • Contributor
  • Posts: 19
  • Country: be
  • famous for its killer edible poets
Re: how to choose a PIC?
« Reply #3 on: October 13, 2012, 04:26:24 am »
You can use the product selector tool.

http://www.microchip.com/productselector/MCUProductSelector.html

After that, you need to check which chips that fit your criteria are available from your distributor.

Usually people pick chips that are generic and have a decent amount of peripherals.  It's easier just to grab 20 of those and use them even if they are overkill rather than grab 1 of 10 different uC's that better match the requirements of the individual projects.

There are some common starter ones like 16f877A and 16f628A.  I would highly suggest starting out with one of the enhanced (updated) cores.  The enhanced cores usually come in a LF version as well as a regular F version, the L is for low voltage, which you'll want for a solar project.  I have used a few 16f1933's and for low pin count 12f1840.

Is it me or is that selector really slow? It's been calculating for 3 minutes now.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 3936
  • Country: ro
  • .
Re: how to choose a PIC?
« Reply #4 on: October 13, 2012, 04:44:14 am »
nevermind, things have changed lately and my advice no longer applies that well.
« Last Edit: October 13, 2012, 04:53:39 am by mariush »
 

Offline Kidsam

  • Contributor
  • Posts: 11
Re: how to choose a PIC?
« Reply #5 on: October 13, 2012, 05:01:24 am »
if you are new to PICs, and plan on using the XC compilers, my advice is to use one of the chips that they use for the official development boards.  You don't actually have to use the dev board itself, just the same chip.  I say this because all of the sample code from microchip is built for the official dev boards.  If you use the same chip then you won't have to do much porting.   They usually use good general purpose chips for the dev boards as well.

I know that doesn't really answer your question, but its a place to start.

well, i'm not sure about the development boards, i just bought the pickit 3
i also have the chips
PIC16F84A-04/P and
PIC12C508A which the seller has bundled with the pickit, though from the datasheets they look like faster chips, but without PWM functionality 

anyway thanks for the replies
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 14441
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how to choose a PIC?
« Reply #6 on: October 13, 2012, 07:08:13 am »
Don't use the 16F84, it's so old, time to let sleeping dogs lie. I tend to consider the 16F88 for anything needing a few pins although I'm yet to do anything significant.
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: au
Re: how to choose a PIC?
« Reply #7 on: October 13, 2012, 09:16:44 am »
I've started using the PIC16F1827 in some new designs.  Quite cheap (< $2) and capable.  Also the PIC16F1822 (8-pin) has a UART, SPI, etc and less than $1.
 

Offline ptricks

  • Frequent Contributor
  • **
  • Posts: 670
  • Country: us
Re: how to choose a PIC?
« Reply #8 on: October 13, 2012, 01:42:21 pm »
Any of the pic32mx chips can do what you want and they are fast, low cost, and current technology. The dip versions of these chips would work well.
Also, microchip is very friendly when it comes to free samples. Just go to the microchip site and register, they usually allow hobbyist about 5-6 chips a month for free.


If I was just starting out with pics then I recommend the pic16f1823. It isn't because that chip is the best of the best, it is because the datasheet for that chip is probably the best, easiest to understand that I have ever seen for a MCU.
« Last Edit: October 13, 2012, 01:48:31 pm by ptricks »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18908
  • Country: nl
    • NCT Developments
Re: how to choose a PIC?
« Reply #9 on: October 13, 2012, 03:25:37 pm »
I agree. I'd stay away from the 8 and 16 bit PICs. That is 80's technology. Go for PIC32 or an ARM based controller. Another advantage of the latter are that the C compilers and debuggers are available free.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 14441
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how to choose a PIC?
« Reply #10 on: October 13, 2012, 03:37:34 pm »
oh here we go again. Why use a ferrari to go 100 metres down the road ? if the project is simple then why use such powerful devices. You can run C even on 10F micro's. Granted it's not a great idea but if you just want to flash a LED I bet it's work fine. Microchip and most others do C compilers for 10-16F parts as well as the compilers for 18-32F. Of course the issue with anything under 18F seems to be the paged memory but if it's a small program under one page size or you split it appropriately there won't be a problem
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: how to choose a PIC?
« Reply #11 on: October 14, 2012, 12:22:01 am »
I have not used PIC32, but I've used my share of ARM chips, older ARM7, and now CM3, CM4, and CM0.  They do not replace 8/16bit micros for easy low requirement projects.  Beginners should still start out on these.  The peripherals are easier to understand and less things to go wrong.

To be controversial on another topic, I wouldn't even bother with assembler anymore if you are just a hobbyist.  Unless you really want to get into low level, there's just no need.  I've given up learning assembler for new architectures.  I used to learn instruction sets for new architectures I would get into, but I just started using PICs about a year ago and never even bothered learning the instruction set.  The last uC I got into was MSP430, I learned the instruction set and outside of the practice programs never ended up using any of it in any actual project.
Mark Higgins
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 14441
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: how to choose a PIC?
« Reply #12 on: October 14, 2012, 07:41:08 am »
I spent years trying to head the advice of assholes on that other forum banging on about the purity of assembler. I nearly gave up until I made a final dash for it and "sinned" with basic, oh it felt so good to be liberated.

I'm now trying C  :)
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 892
  • Country: us
Re: how to choose a PIC?
« Reply #13 on: October 14, 2012, 01:49:28 pm »
I spent years trying to head the advice of assholes on that other forum banging on about the purity of assembler. I nearly gave up until I made a final dash for it and "sinned" with basic, oh it felt so good to be liberated.

I'm now trying C  :)
C *is* the new assembler. C++ is more useful though, if your compiler supports it.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1982
  • Country: nl
Re: how to choose a PIC?
« Reply #14 on: October 14, 2012, 05:13:56 pm »
I spent years trying to head the advice of assholes on that other forum banging on about the purity of assembler. I nearly gave up until I made a final dash for it and "sinned" with basic, oh it felt so good to be liberated.

I'm now trying C  :)

Yeah, going the asm only route is a bit silly in 2012. My most recent additions to the mcu menagerie are msp430 and stm32f4, and I haven't written a single line of asm for either yet. All the asm exposure I've had on those is reading the startup code to get an idea of what's being done there. Other than that it's C all the way.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1982
  • Country: nl
Re: how to choose a PIC?
« Reply #15 on: October 14, 2012, 05:16:37 pm »
C *is* the new assembler. C++ is more useful though, if your compiler supports it.

On that subject, anyone have practical experience with C++ on the stm32f4? Right now C does the trick, but for some of the stuff I'm writing now a bit of OO would be nice. And the same C++ question for msp430... any experience anyone?
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 3547
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: how to choose a PIC?
« Reply #16 on: October 14, 2012, 06:16:37 pm »
I agree. I'd stay away from the 8 and 16 bit PICs. That is 80's technology. Go for PIC32 or an ARM based controller. Another advantage of the latter are that the C compilers and debuggers are available free.

The smaller PICs are perfectly suitable for many purposes and in some cases contain a better peripheral set than the 32 bit parts. The debugger and C compilers are free for all the PICs; all you don't get for free is the code optimising stuff, which by all accounts is of questionable value anyway.

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 892
  • Country: us
Re: how to choose a PIC?
« Reply #17 on: October 14, 2012, 07:08:19 pm »

On that subject, anyone have practical experience with C++ on the stm32f4? Right now C does the trick, but for some of the stuff I'm writing now a bit of OO would be nice. And the same C++ question for msp430... any experience anyone?
I'm using C++ with STM32F1xx, which is essentially the same. My code runs equivalently on the F4 and VL Discovery boards (with mods to the linker script). I thought about using an MSP430 until codespace issues started to crop up.
 

alm

  • Guest
Re: how to choose a PIC?
« Reply #18 on: October 14, 2012, 07:20:49 pm »
The smaller PICs are perfectly suitable for many purposes and in some cases contain a better peripheral set than the 32 bit parts. The debugger and C compilers are free for all the PICs; all you don't get for free is the code optimising stuff, which by all accounts is of questionable value anyway.
Code optimization may not be critical if the uC is way overkill in terms of memory size and performance, but pretending that the past ~forty years of compiler development is of questionable value is wrong in my opinion. Compiler optimization is probably the number one reason why programming languages like C have mostly replaced assembly these days. I wouldn't use a non-optimizing compiler for any application if I can help it.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18908
  • Country: nl
    • NCT Developments
Re: how to choose a PIC?
« Reply #19 on: October 14, 2012, 08:44:18 pm »
I agree. I'd stay away from the 8 and 16 bit PICs. That is 80's technology. Go for PIC32 or an ARM based controller. Another advantage of the latter are that the C compilers and debuggers are available free.

The smaller PICs are perfectly suitable for many purposes and in some cases contain a better peripheral set than the 32 bit parts. The debugger and C compilers are free for all the PICs; all you don't get for free is the code optimising stuff, which by all accounts is of questionable value anyway.
Well, you could use a Model-T Ford to go to work every day. It will get you there and back but would it be wise? If you refer to PIC32 parts I guess you are right. IMHO they are Microchip's half assed attempt to hop on the 32 bit boat. Half assed because they choose a MIPS core instead of ARM. Not that MIPS is really bad but the general community support for MIPS is extremely limited because there are very few MIPS based devices out there.

And yes, you really want optimisation in a compiler. Sometimes you need to cram a little bit more code into a controller or get a bit more speed from certain parts of the code. In some cases I find myself compiling one C file with optimisation for speed and the rest with optimisation for size. With any ARM controller you get those for free with GCC but for PIC32 you have to pay. How dumb is that if you want to penetrate a very crowded market?
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: us
Re: how to choose a PIC?
« Reply #20 on: October 14, 2012, 09:06:27 pm »
If you want another stupid PIC compiler optimization fun fact.....
The official microchip USB bootloader example code only fits in the right memory footprint if optimizations are on.  After the trial you have to alter the offsets on all your code.  Fun huh..

I brought this up to the microchip rep during a site visit.  Dunno if they can really do anything about it though. 


(edit to add official microchip compiler)
« Last Edit: October 14, 2012, 11:57:47 pm by Smokey »
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 3547
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: how to choose a PIC?
« Reply #21 on: October 15, 2012, 06:25:42 am »
OK, I get the philosophical argument, though it hasn't stopped me from completing numerous successful projects using PICs with the free tools. Lack of optimisation hasn't caused me any issues at all, and it's certainly not a reason to avoid using a perfectly good range of microcontrollers.

Can anyone provide quantitative data on just how effective Microchip's optimisation actually is? (ie. not the manufacturer's claims, but actual project performance and/or code footprint improvements)


Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: how to choose a PIC?
« Reply #22 on: October 15, 2012, 07:21:02 am »
The weary argument that one can write more efficient code in asm than in C expired long long ago. In some exceptional cases of minutely detailed optimization, maybe. Generally a competent C/C++ compiler can match and exceed the ability of a human to produce code with consistent high quality.

My recommendation would be to learn C++ and how to use it to create proper structure to the code. By this i mean things like classifying functionality into object classes that have well defined behavior and that hide their internal variables and only publish an interface. This helps to create cleaner, more understandable and maintainable code and there is no penalty in doing so.
The myth that introducing classes into an application will automatically result in bloated code has also been busted long ago. For example i just completed and delivered a series of CNC mill spindle rpm meters/speed monitors powered by a Mega328P - the same Arduino uses. I wrote the code in AVR Studio 5 (and 6) as a C++ project (i.e. using the GCC compiler). There are some 5-6 classes handling eeprom/configuration, encoder input, rpm calculation, display formatting and configuration user interface. Less than half of the available memory spaces were needed, so another similar app would still fit easily. The meter is easily able to count revs up to the max displayable 65535 rpm and beyond (limited only by the fact that the final number is a uint16_t in this version).
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18908
  • Country: nl
    • NCT Developments
Re: how to choose a PIC?
« Reply #23 on: October 15, 2012, 10:49:07 am »
That is a good hint. OTOH you don't need C++ to write object oriented code. In C you can declare variables and functions as static within a source file which means they are not visible to the rest of the program. A few 'public' (non static) functions serve as an API to the rest.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: how to choose a PIC?
« Reply #24 on: October 15, 2012, 11:17:51 am »
Depends on what exactly you mean by "object oriented". Generally speaking, no, you cannot write OO code just using C, but you certainly can emulate some OO features using it. Providing well defined data structures and procedures that operate on those structures is a step towards that. But other features like proper information hiding are harder, and some like inheritance, polymorphism, class templates and other "true" OO features just cannot be done in C. How much of those you want or need in a small microcontroller environment is of course a different question but just for the sake of the argument that is so.

Personally, I much prefer to use the proper features of a reasonably well defined standard, such as C++ language, instead of coming up with what may be called neat tricks or in the worst case, kludges. (I don't specifically mean your example. That is a standard scope/visibility feature of C and in my book it does not count towards OO especially. Of course you did not make that claim either).
So anyway, whatever floats your boat, it is not for me to dictate. This is just my opinion.
Nothing sings like a kilovolt.
Dr W. Bishop
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf