Monday, July 13, 2015

10 steps to selecting a microcontroller


Selecting the right microcontroller for a product can be a daunting task. Not only are there a number of technical features to consider, there are also business case issues such as cost and lead-times that can cripple a project. At the start of a project there is a great temptation to jump in and start selecting a microcontroller before the details of the system has been hashed out. This is of course a bad idea. Before any thought is given to the microcontroller, the hardware and software engineers should work out the high levels of the system, block diagram and flowchart them and only then is there enough information to start making a rational decision on microcontroller selection. When that point is reached, there are 10 easy steps that can be followed to ensure that the right choice is made.


Step 1: Make a list of required hardware interfaces
Using the general hardware block diagram, make a list of all the external interfaces that the microcontroller will need to support. There are two general types of interfaces that need to be listed. The first are communication interfaces. These are peripherals such as USB, I2C, SPI, UART, and so on. Make a special note if the application requires USB or some form of Ethernet. These interfaces greatly affect how much program space the microcontroller will need to support. The second type of interface is digital inputs and outputs, analog to digital inputs, PWM’s, etc. These two interface types will dictate the number of pins that will be required by the microcontroller. Figure 1 shows a generic example of a block diagram with the i/o requirements listed.


Step 2: Examine the software architecture

The software architecture and requirements can greatly affect the selection of a microcontroller. How heavy or how light the processing requirements will determine whether you go with an 80 MHz DSP or an 8 MHz 8051. Just like with the hardware, make notes of any requirements that will be important. For example, do any of the algorithms require floating point mathematics? Are there any high frequency control loops or sensors? Estimate how long and how often each task will need to run. Get an order of magnitude feel for how much processing power will be needed. The amount of computing power required will be one of the biggest requirements for the architecture and frequency of the microcontroller. 
Step 3: Select the architecture
Using the information from steps 1 and 2 an engineer should be able to start getting an idea of the architecture that will be needed. Can the application get by with eight bit architectures? How about 16 bits? Does it require a 32 bit ARM core? Between the application and the required software algorithms these questions will start to converge on a solution. Don’t forget to keep in mind possible future requirements and feature creep. Just because you could currently get by with an 8 bit microcontroller doesn’t mean you shouldn’t consider a 16 bit microcontroller for future features or even for ease of use. Don’t forget that microcontroller selection can be an iterative process. You may select a 16-bit part in this step but then in a later step find that a 32 bit ARM part works better. This step is simply to start getting an engineer to look in the right direction.


Step 4: Identify Memory Needs

Flash and RAM are two very critical components of any microcontrollers. Making sure that you don’t run out of program space or variable space is undoubtedly of highest priority. It is far easier to select a part with too much of these features than not enough. Getting to the end of a design and discovering that you need 110% or that features need to be cut just isn’t going to fly. After all, you can always start with more and then later move to a more constrained part within the same chip family. Using the software architecture and the communication peripherals included in the application, an engineer can estimate how much flash and RAM will be required for the application. Don’t forget to leave room for feature creep and the next versions! It will save many headaches in the future.  

Step 5: Start searching for microcontrollers
Now that there is a better idea of what the required features of the microcontroller will be the search can begin! One place that can be a good place to start is with a microcontroller supplier such as Arrow, Avnet, Future Electronics or similar. Talk with an FAE about your application and requirements and often times they can direct you to a new part that is cutting edge and meets the requirements. Just keep in mind that they might have pressure on them at that time to push a certain family of microcontrollers!
The next best place to start is with a silicon provider that you are already familiar with. For example, if you have used Microchip parts in the past and had a good experience with them, then start at their website. Most silicon providers have a search engine that allows you to enter your peripheral sets, I/O and power requirements and it will narrow down the list of parts that match the criteria. From that list the engineer can then move forward towards selecting a microcontroller. 
Step 6: Examine Costs and Power Constraints
At this point the selection process has revealed a number of potential candidates. This is a great time to examine the power requirements and cost of the part. If the device will be powered from a battery and mobile, then making sure the parts are low-power is absolutely precarious. If it doesn’t meet power requirements then keep weeding the list down until you have a select few. Don’t forget to examine the piece price of the processor either. While prices have steadily been approaching $1 in volume for many parts, if it is highly specialized or a high-end processing machine then price might be critical. Don’t forget about this key element.


Step 7: Check part availability 
With the list of potential parts in hand, now is a good time to start checking on how available the part is. Some of the things to keep in mind are what the lead times for the part? Are they kept in stock at multiple distributors or is there 6 – 12 week lead time? What are your requirements for availability? You don’t want to get stuck with a large order and have to wait three months to be able to fill it. Then there is a question of how new the part is and whether it will be around for the duration of your product life cycle. If your product will be around for 10 years then you need to find a part that the manufacturer guarantees will still be built in 10 years. 


Step 8: Select a development kit
One of the best parts of selecting a new microcontroller is finding a development kit to play with and learn the inner working of the controller. Once an engineer has settled their heart on the part they want to use they should research what development kits are available. If a development kit isn’t available then the selected part is most likely not a good choice and they should go back a few steps and find a better part. Most development kits today cost under $100. Paying any more than that (unless it is designed to work with multiple processor modules) is just too much. Another part may be a better choice. 

Step 9: Investigate compilers and tools
The selection of the development kit nearly solidifies the choice of microcontroller. The last consideration is to examine the compiler and tools that are available. Most microcontrollers have a number of choices for compilers, example code and debugging tools. It is important to make sure that all the necessary tools are available for the part. Without the right tools the development process could become tedious and expensive. 

Step 10: Start Experimenting
Even with the selection a microcontroller nothing is set in stone. Usually the development kit arrives long before the first prototyped hardware. Take advantage by building up test circuits and interfacing them to the microcontroller. Choose high risk parts and get them working on the development kit. It may be that you discover the part you thought would work great has some unforeseen issue that would force a different microcontroller to be selected. In any event, early experimentation will ensure that you made the right choice and that if a change is necessary, the impact will be minimal! 


7 Steps to select microcontroller:


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.

No comments:

Post a Comment