Friday 26 July 2013

HOW TO SELECT A MICRO CONTROLLER

 Choosing an MCU for your project is not easy.There are a large number of suppliers, offering varying architectures, peripherals, price points, power consumption, packages and what not. This article helps you get a better idea of the current situation and select the right MCU for your application.
A search in an online catalogue for microcontroller units (MCUs) would lead you to a massive collection of thousands upon thousands of various MCUs, leaving you spoilt for choice. There would be so many good choices that it would be difficult to make a decision. The following is what the experienced designers in the industry advise.


Architecture

            For most embedded systems you have the choice between 8-bit, 16-bit and 32-bit cores. When it comes to applications involving computations, 32-bit cores have a clear edge over 8-bit and 16-bit, in addition to making the most of the compiler features.
            The RISC and CISC architectures have become a little less meaningful with continued evolution of both the CISC and RISC designs and implementations. 
            The architecture of a microcontroller refers to the philosophy of the internal implementation, It includes details like how many registers are used, whether the code can execute out of the data memory, whether the peripherals are treated like memory, registers or something else, whether there is a stack and how it works, and so on. A RISC processor can handle simple math functions much faster, but a CISC processor will handle complicated functions faster because it can do them all at once instead of the several processing commands that a RISC processor would have to take to complete the same function.” MCU process technology, architecture and memory technology also need to be considered as these affect the real calculation speed rather than MHz and memory size requirements.

TOP 7 Factors to be Considered:-

 1.      8-bit vs 32-bit core. 8-bit cores are currently the most widely used MCU cores. For almost all tasks, an 8-bit core like 8051, PIC and AVR will suffice. However, as the project complexity increases, some may want to utilise the 32-bit cores like ARM, which provide you with more features and faster clock speeds but tend to have a higher learning curve than 8-bit cores. Some 32-bit cores also have floating-point units, which enable you to process math/DSP related functions faster and much more efficiently. However, you should get familiar with 8-bit cores before moving to 32-bit cores.




2.      Programming language. This is indirectly related to the MCU but directly to the tool chain used. The most popular programming languages for MCUs are Assembly (ASM) and Embedded C.
Working with ASM is much more time-consuming but gives you great insight into the architecture and actual working of the MCU. However, when the code size efficiency does not matter as much as the time to develop, Embedded C is the way to go. Again, you can write efficient code in ‘C’ and some projects require you to use ‘C’ to keep things simple.
For most of the 8051s available in the Indian market, Keil supports the code in ASM and Embedded C. For the PIC series, MPLAB has a CCS plugin (I use this as opposed to Hi-Tech Compiler), which enables you to code a PIC in ‘C’. So before you select the chip, make sure a tool chain with the right options is available for development. Do consider the cost of the same as many of them do not have free versions.

3.       GPIOs and features. Manufacturers release many MCUs of similar specifications but different features and resolutions. Select a chip that has all the features with the resolution as per your needs. Try to keep external chip interfacing to a minimum. This will help you in your design. Also make sure your MCU has sufficient input/output (I/O) pins for your needs. Try using alternate modes for peripherals—like 4-bit LCD mode—to save some I/O pins.

4.       Cost. If it is your first time working with an MCU, there is no need to purchase an expensive MCU. We all have had our share of burnt MCUs, and likely you will too. So keep the cost low initially. Weigh all the points mentioned here (and elsewhere too) and select an appropriately priced MCU that suits your budget. For absolute beginners,  I would recommend AT89S series and P89V51RD2 (expensive but has PWMs) from 8051 family, and PIC16F877A (has ADCs too) from PIC family. In general, 8051s tend to be cheaper than PICs, which are cheaper than Atmega’s, but PICs have much more functionality.

5.      Availability. Select an MCU that will be available for a long time to come. There is no general rule of thumb to know this, but selecting a popular one is your best bet. (The ones mentioned above are most widely used in many universities.) If for some reason you select an MCU which is not available in India, you may have to pay additional shipping charges to get it, which will be costly as well as frustrating.

6.      Online support. This is crucial when you’re just venturing out and when you move on to 32-bit cores. Selecting an MCU which has good online support will help you with your ideas and solve most of your problems as the experience of other users is available for your reference. Getting to know existing bugs with tool chains or MCU documentation will help you avert the problem in advance and speed up development.

7.      Packaging. For most DIY projects, a DIP package is suitable and easy to work with. SMD packages are a bit difficult to work with without proper tools and therefore not recommended for first timers. Once the design is ready, you can always use SMD equivalents to make it more compact.