Connect with us

How to choose a micro controller?

Discussion in 'Microcontrollers, Programming and IoT' started by AndreeU17, Aug 5, 2014.

Scroll to continue with content
  1. AndreeU17

    AndreeU17

    42
    1
    Apr 23, 2014
    I was curious, when looking at a list of AVR and PIC micro controller, how do we go about choosing the right one for our projects? What about size? RAM? What are the benefits of choosing a 16 pin 8 bit AVR over a 20 Pin 8 bit? How beneficial is an 8 bit over a 16 bit besides the more allowance in processing? I was just curious since i have multiple projects for my Electrical Engineering degree that requires me to choose one and i want to make sure that choosing the right Microcontroller is a must.
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,293
    2,732
    Jan 21, 2010
    In general, more pins means more I/O. If you need more I/O, then you'll probably pick a device with more pins.

    There are *many* factors involved in picking a microcontroller. They may include:
    • Which one are you most familiar (and possibly competent) with?
    • If you have code, which one will run that code with the least modification?
    • Which one has the peripheral devices you require?
    • Which one uses a language you are familiar with?
    • Which one works with hardware programming devices that you have?
    • Which one is cheaper?
    • Which one has sufficient RAM/code space/EEPROM/etc. for the required task?
    • Which one interfaces more easily to the hardware?
    • Which ones come in the package we require?
     
    chopnhack and KrisBlueNZ like this.
  3. AndreeU17

    AndreeU17

    42
    1
    Apr 23, 2014
    Dude this
    Dude this is amazing, this is exactly the checklist I need when choosing a microcontroller !!! Thanks so much you've solved my problems haha ☺️
     
  4. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Be careful asking anyone if PIC or AVR is better, there have been many battles on the 'best' micro controller.
    It all comes down to preference and application.
    PIC requires a 12V for programming which may make it difficult to do in-circuit programming or upgrades. AVR tends to be a little more power hungry.
    If you know PIC, don't bother getting an AVR because it might allow you to more easily re-program your product. (There are workarounds for almost anything)

    I liked these posts:
    http://www.electricstuff.co.uk/picvsavr.html
    http://www.ladyada.net/library/picvsavr.html
     
  5. Ehsan

    Ehsan

    100
    1
    Jun 12, 2014
    What do you exactly mean by that ?

    I have a Pickit 3 that I can plug it into a usb socket and it can program my ucontoller and also do in circuit debugging and all the rest... We all know the USB power supply is 5v.
     
  6. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    MCLR requires 12V for programming does it not?
    I am aware of the programmer being driven by 5V, I have one as well. The Vpp line on the programmer supplies 12V for programming.

    I should have clarified that the only time this would be a drawback would be for in-circuit programming if it was not clearly planned out, or if you wanted to make your own programmer.
     
  7. Ehsan

    Ehsan

    100
    1
    Jun 12, 2014
  8. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Page 2 has the required voltages for the MCLR which looks to be a wide range based on the part.
    Looks like minimum is +3.5V higher than Vdd, or 10V depending. For anyone with a PICkit though, and proper planning to break that pin out to an accessible header it should not be an issue.
     
  9. BobK

    BobK

    7,673
    1,684
    Jan 5, 2010
    Many PICs also have low voltage programming.

    Bob
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,293
    2,732
    Jan 21, 2010
    That's true. However I believe they're also like AVR microcontrollers in that if you accidentally program them incorrectly, you might get yourself into a situation where the only way out is high voltage programming. (Beware using low voltage programming to program the chip with a set of fuses saying you can't low voltage program the chip -- not a wise thing to do in most cases!)
     
  11. Solidus

    Solidus

    349
    4
    Jun 19, 2011
    Comparing PICs vs. AVRs is a difficult battle to wage (and not the holy war of micros).

    AVRs
    - Arguably, much more readily-available ideas seem to be out in the market for AVRs as of late, with things like the Arduino as well as derivative designs getting much attention.
    - Arguably, better single-cycle performance. Individual instructions will execute faster.
    - More of an emphasis on high-level language development (i.e. C/C++). Assembly can be done but it seems to be a lesser-used end of AVR development, at least from my standpoint.
    - Lower speeds, but lower-cost in terms of the development chain.
    - Primarily available in a 8-bit variant, which is known as AVR. AVR32s do exist, which extend the instruction format to 32-bit, but this is a different core that functions differently from the 8-bit flavor. Also, it's worth noting that the AVR32 has not seen the hardware acceptance (from an end-user perspective) that the AVR does, and information on it is scarce in comparison. This variety will clock up to, as stated again below, 66MHz.

    PICs
    - Scales higher in the speed grades - PIC32s can clock up to 200MHz, compared to the 66MHz effective of AVR32s.
    - Homogeneous (for the most part) core architecture across word and instruction sizes - how the processor manipulates its data will not change based on the architecture, and PICs range from 12-bit (I believe) to 32-bit, with the -32MZ family being most optimized for performance.
    - Arguably, more difficult in terms of programming. I say "arguably" because it takes more care than simply wiring an ICSP header to its pins. As the discussion above entails, particular care needs to be taken around MCLR# and the Vpp programming lines, which require a higher voltage, substantially higher than Vdd, to "burn" the data into EEPROM or flash memory.
    - Much more of an emphasis on assembly development, and this is especially true for the smaller PICs. This stems from multiple things, one of which that I discussed a while back being that Microchip used to not supply optimizing compiler chains, so the only way to obtain code that would be guaranteed to fit and work as intended was to work with assembly. AVRs use a subset of GCC, so they can attain high-levels of optimization even operating from within a high-level language. That being said, Microchip has in many ways worked on this drawback and worked to support C/C++ development more so their newer compiler chains do work better for hobbyist applications.

    I might as well preface this by saying that this is my opinion that follows.

    If you're new to the idea of microcontrollers and haven't played with one before, I'd suggest picking something up like an Arduino. This will take the fuss out of working with programming interfaces and flashing and all that stuff and provide you with a very-cheaply-had microcontroller board that is ready to program out of the box. It will get you used to the idea of writing code and the concepts in play on a microcontroller, such as how to interface with peripheral units and what not. Decidedly, the Arduino platform is much more suited to C/C++ development and you will need AVR studio to do any real legwork in assembly. For learning how to work with a microcontroller though, from someone who learned via that exact route, it was perfect.
     
  12. Puranjay Mohan

    Puranjay Mohan

    1
    0
    Aug 22, 2014
    I would say for starting get an arduino Uno and learn that..
     
  13. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
    It depends on what you want to do with the microcontroller program and project you have been designing or working-on.
    If you want to develop a project that can be sold as cheaply as possible in enormous quantities, you need to look at something like a PIC micro where the program can be converted to a "die" for 5 cents (COB module) and sold for $2.00 like the Whistle Key Finders.
    If you want to build a robot for your own enjoyment, then one of the other "ready-to-run" platform will be ideal.
    We need more input from you.
     
  14. JoeM

    JoeM

    33
    9
    Sep 5, 2014
    I think his goal is to learn.

    I agree with Puranjay, get an Arduino Uno and learn to program it with the help of a million people willing to help you for free. All of the development software is free. The Arduino is ready to go out of the package, just plug it into your USB port, load the software, and start learning to program in C. Arduino is the best way to start, and all that you learn about programming an Arduino will apply to the PIC. The PIC will require more money, an much more effort, so much more, that you might give up before reaching your goal. There are thousands of how-to articles to help you do nearly anything with an Arduino. There are some more powerful Arduino chips, like the 2560 Mega, and all that you know about the UNO, will apply to the more powerful Mega. It is programmed the same way, but has much more to it.
    The PIC has nothing wrong with it, and it is one of the most used micro-controllers on the planet. This year marked the biggest year for sales of 8 bit PIC micro controllers. I know that sounds strange to some, but you can verify that in Google. If you needed a more powerful micro controller, PIC would have one for you, but it is not the way to learn, it is the slowest, most difficult way to learn, and the most expensive.

    About programming in C. C is the most desirable, and most used programming language in regards to computers, and micro controllers. Assembly language is very useful, but in most cases it is not required.

    If you start in any other way, you will eventually reach a point where you realize that this was your best advice

    Good luck, Joe
     
    chopnhack likes this.
  15. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    I would put that in a grey area Joe.
    PIC may be a little more expensive as a start-up because you need to buy a programmer. AVR is the same way.
    This only applies if you are only buying one or two microcontrollers though, as the added cost of an Arduino adds up fairly quickly when you need to buy multiples.
    $50 for a PIC programmer, and $2-5 per PIC to learn with as opposed to the $10+ mark for basic Arduinos.

    They are much easier to start with, but the programming language and many of the examples don't transfer well to other microcontrollers unless you spend the time to learn the low-level functions available to control the Arduino.

    You end up with mixed results, and there is no 'right' answer when it comes to buying your first microcontroller. There are however 'right' answers when there is a given project that needs to be accomplished, but the differences only make a difference in some minute details.
    I've learned on a BASIC Stamp and a PICKit and would encourage others to learn micro-controllers on a more basic level before using some of the more advanced items.
    Of course, there is always a RaspberryPi or other SoC... you can program in Java, PHP, Bash, etc and control the pins, but this is not really learning microcontrollers. It's more of an intro to encourage learning the electronics you would use as add-ons.
     
    chopnhack likes this.
  16. JoeM

    JoeM

    33
    9
    Sep 5, 2014
    ----------------------------------
    I’m not so sure that it is grey at all. I have been involved in both worlds for a long time. PIC requires a programmer, but it is possible to make one yourself. PIC has learning type development boards, but the most popular of them is the one with the most support, and I would have to give that to the LabX board from Microchip. That board can cost from $50 for a used, older rev, up to much more for a new recent model. Sure there are a lot of others, but the LABX is the one that has many books written about it in an effort to teach programming. Others cost way more, and have limited support by the company who produced it. There are free compilers for the PIC, but if you want a Compiler with similar support as Arduino, you may have to stick with the student version of PIC Basic. The program is limited to small code size, but there is enough space to learn about Pic Basic programing.
    It is true that a lot of this is subject to opinion, and that is all I have here, is my educated opinion.
    Arduino was designed from the ground up to support free open source micro controller education. It is the most used micro controller of its type in the world. It has the largest collection of free support in the form of people, web sites, and documents for free down load. The UNO can be bought from any number of manufactures, and they are all the same. I have bought many for $6.95 and free shipping. In many cases, the board will come with the USB cable to connect it to a PC.
    The compiler is also free, and so are at least hundreds of library files. The libraries cover the use of sensors, and displays, of every type. The libraries have an equal level of free support. The word Free does not come up when you talk about a PIC.
    True, it is very easy to learn Basic, but I happen to know basic, and I found C to be almost as easy. With Arduino there is only C, and that is for good reason. C programming is widely used throughout the business, and academic world. The same cannot be said about Basic. The only true statement about basic is that it is easy. Knowing C can lead to a job that pays very well.
    The way Arduino teaches is awesome, and it speeds up the learning process, as well as keeping it fun for the student.
    Between the PIC and the Arduino I would say that they are opposites when it comes to learning. The Arduino is easy, and fund to get started, and it is fun to progress through learning, with the process going into more complication as you get further into the programming of microcontrollers. The opposite can be said about PIC, it can be a bit complicated to get started, and the complication will continue for a while, getting easier as you go. This does not address the programming language, because you can program the PIC in C too. The problem with the PIC process is that everybody learns at a different speed, and in fact, in different ways. Many people will quit studying the PIC long before they get anywhere, and getting anywhere is the whole goal with Arduino. You will get somewhere on the first day. On the first day almost anyone will have a program running that controls something on an Arduino. How many days, and how much money do you think it will take the average person to get anywhere with a PIC?
    Currently, this is my opinion on the best way to get started in learning about using and programming microcontrollers. I don’t see that changing anytime soon.
     
    chopnhack likes this.
  17. JoeM

    JoeM

    33
    9
    Sep 5, 2014
    Sorry for the speech on which chip line would be easiest to get started on, it did not answer your question in the proper way. In order for you to know which processor would suit your needs, you would first need to know what you need it to do. The Arduino has analog to digital converters, PWM, timers and counters, and interrupts. With those things, and more than a few digital and analog ports, you can do a lot. There are bigger chips in the Arduino lineup that extend the amount of I/O, and speed.
    You can do much more with some PIC controllers, but by the time you learn to work with much more powerful chips the learning curve will get much steeper. if you don't know what processor to use, you would first learn something about microcontrollers, and soon after you start that process, you will start to form a good understanding of what you will need for a project, and how to go about doing that.
    There are many support chips that can be used to expand I/O, on a processor, so the questions soon become about cost, space, power, and speed.

    Get yourself an Arduino UNO, or DUO, or MEGA, and a USB cable. The chips will all work as a starting point to learn, and the software you write for one can easily be ran on another. I suggest that you start with an UNO. Then go to the Arduino web site and download the compiler package. The software is excellent to say the least. It has many features, and with check your syntax as you work. It will show where your mistakes are, but it does not proof your code, because you can get code to compile, but still not work. You can search the internet with Google and find a book in pdf format, the title is Beginning Arduino Programming by Brian Evans. You will find it, but you may also buy it on Amazon. A hard copy might work better than a PDF copy. Brian does a pretty good job of making learning to program the Arduino in C easy.
    Once you have the book, you will need a few parts to get started. The book will identify those parts. they are very cheap parts, and some web pages sell al the parts in a kit. You only need the parts that involve the function you want to use. So if it does not involve stepper motors, or servos, you won't need to buy those things. You will need a few types of LED's, and some resistors at the very least. Good luck, and feel free to ask questions.
     
  18. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    JoeM, with all due respect I feel it is very important to learn microcontrollers how they operate, and not with vague ideas being hidden behind an IDE. This is not an argument against Arduino, they have a strong foothold and are used in many applications, but the op should be encouraged to make his own decision instead of suggesting the Arduino route right away.
    How far can you remove someone from the microprocessor before it starts to feel like programming a computer instead? We could very well suggest a Lego Mindstorm.

    This is not a problem if the OP is willing to actually look at and learn the low level operations and how they work instead of relying on the more advanced Arduino functions as a crutch.

    The Arduino references don't even list port manipulation unless you dig for it:
    http://arduino.cc/en/Reference/HomePage
     
  19. JoeM

    JoeM

    33
    9
    Sep 5, 2014
    Very true, a lot of the complexity of setting option registers, clock sources, and the such are hidden behind the IDE of Arduino. I guess that is why I suggest that it is an easy way get started, and develop more interest to encourage the user to delve into the more complicated, more powerful processors. Nothing learned in Arduino is wasted when moving to a PIC, but there is a whole lot more to know to get a PIC to do what Arduino makes doing easy. However, I hold firm on my opinion that learning C is the best way to get started in programming. Many hobbyists never get past Arduino, nor have any wish to. I have every PIC resource I need to build just about anything, but I like tinkering with my Arduino for fun. I spend a lot less time with a soldering iron in my hand, and more time having fun. My full time job is in computers, not electronics, but my electronics knowledge has helped me with computers more than a few times.
    It is good for people to hear more than one opinion, especially when it is on such a subjective topic.
     
    chopnhack and Gryd3 like this.
  20. chopnhack

    chopnhack

    1,573
    352
    Apr 28, 2014
    Not to detract from the OP's thread, but can you provide a list of resources for both the PIC and Arduino? I am curious to see what you would recommend for someone to get started with Arduino - you made a reference to get some for about $7 - I imagine E-Bay is involved, from my limited searches they seem to be imitations. Are they compatible in your opinion? As for basic, is there any program you could recommend (Basic compiler or IDE) - my last use of Basic was long ago with QBasic if I recall correctly.

    Thanks!
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-