-
how to choose a PIC?
Posted by
Kidsam
on 13 Oct, 2012 01:53
-
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
-
#1 Reply
Posted by
Smokey
on 13 Oct, 2012 02:30
-
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.
-
#2 Reply
Posted by
TheDirty
on 13 Oct, 2012 03:46
-
You can use the product selector tool.
http://www.microchip.com/productselector/MCUProductSelector.htmlAfter 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.
-
#3 Reply
Posted by
andete
on 13 Oct, 2012 04:26
-
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.
-
#4 Reply
Posted by
mariush
on 13 Oct, 2012 04:44
-
nevermind, things have changed lately and my advice no longer applies that well.
-
#5 Reply
Posted by
Kidsam
on 13 Oct, 2012 05:01
-
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
-
#6 Reply
Posted by
Simon
on 13 Oct, 2012 07:08
-
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.
-
#7 Reply
Posted by
David_AVD
on 13 Oct, 2012 09:16
-
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.
-
#8 Reply
Posted by
ptricks
on 13 Oct, 2012 13:42
-
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.
-
#9 Reply
Posted by
nctnico
on 13 Oct, 2012 15:25
-
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.
-
#10 Reply
Posted by
Simon
on 13 Oct, 2012 15:37
-
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
-
#11 Reply
Posted by
TheDirty
on 14 Oct, 2012 00:22
-
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.
-
#12 Reply
Posted by
Simon
on 14 Oct, 2012 07:41
-
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
-
#13 Reply
Posted by
andyturk
on 14 Oct, 2012 13:49
-
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.
-
#14 Reply
Posted by
mrflibble
on 14 Oct, 2012 17:13
-
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.
-
#15 Reply
Posted by
mrflibble
on 14 Oct, 2012 17:16
-
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?
-
#16 Reply
Posted by
AndyC_772
on 14 Oct, 2012 18:16
-
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.
-
#17 Reply
Posted by
andyturk
on 14 Oct, 2012 19:08
-
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.
-
#18 Reply
Posted by
alm
on 14 Oct, 2012 19:20
-
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.
-
#19 Reply
Posted by
nctnico
on 14 Oct, 2012 20:44
-
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?
-
#20 Reply
Posted by
Smokey
on 14 Oct, 2012 21:06
-
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)
-
#21 Reply
Posted by
AndyC_772
on 15 Oct, 2012 06:25
-
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)
-
#22 Reply
Posted by
Kremmen
on 15 Oct, 2012 07:21
-
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).
-
#23 Reply
Posted by
nctnico
on 15 Oct, 2012 10:49
-
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.
-
#24 Reply
Posted by
Kremmen
on 15 Oct, 2012 11:17
-
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.