What is a microcontroller?
The easiest way to think about a microcontroller is to see it as a small computer on a single part, also known as a chip. The main components include a processor, memory, and input/output pins.
A developer can use a programming language to program the microcontroller to do many different types of things based on its capabilities.
Beyond the basics that a microcontroller has, there are many more capabilities available. These include EEPROM memory, Pulse Width Modulation (PWM), bus protocols (I2C, SPI, UART), LCD interfaces, and much more.
Most microcontroller companies will have 1000's of different microcontroller products to choose from.
This allows the designer to pick and choose which specific features they need in a design and precisely select a microcontroller product that meets their needs.
Many microcontrollers come with reprogrammable memory so that you can change the code that is run by the processor. Different code means you can change the behavior of the microcontroller.
However, most designs that are in a high number of production and that have very polished programs will have a write once only memory. It works fine since the design does not need to change. This saves a lot of cost per unit by shaving off the extra costs for the reprogrammable memory that isn't needed.
How many Bits?
Microcontrollers come in different configurations, including 4-bits, 8-bits, 16-bits, 24-bits, and 32-bits.
Typically, designers will try to select the least expensive chip that can accomplish all of the design requirements. Therefore, more bits generally means more processing capability on average.
Often, there are many more factors that go into choosing how many bits. Power consumption is a big concern in portable devices, which could lead the designer to go with a fewer bit microcontroller in order to reduce power.
Sometimes, pricing can be affected where companies produce more higher bit chips than lower bit chips, making the cost of the higher bit chips less expensive.
It is a constant design tradeoff between cost, requirements, and capabilities to select the right microcontroller.
What is it used for?
A microcontroller is a great middle ground capability where there is a need for many different requirements in functionality. They work well when creating that functionality in discrete hardware circuits (like resistors, transistors, etc) is too expensive in terms of design/test time and parts.
The designer must make a trade between how much cost and work it is to use discrete hardware in comparison to using a microcontroller.
Different design groups will have different rules for when using a microcontroller is warranted.
Also, once a microcontroller is included in a design, many more features and capabilities are possible. The flexibility of the design allows change during development in the realm of programmable code.
What can it do?
Microcontrollers are very flexible systems on a chip. There are many core capabilities and additional capabilities depending on which microcontroller is selected.
Some capabilities include:
- Clock generator
- Digital input pins
- Digital output pins
- Analog to Digital converter
- Digital to Analog converter
- Pulse Width Modulation (PWM)
- I2C interface
- SPI interface
- UART interface
- Watchdog timers
- LCD interface
- USB interface
With these core capabilities in mind, the designer can mix, match, and combine any of them to meet the needed functionality for a design. This offers a lot of flexibility at a cheap price.
Some device examples with microcontrollers:
- MP3 player
- Washing machine
- Automoble subsystem
- TV remote control
What are the top companies?
In no particlular order, here are some of the top microcontroller companies:
Renesas is a big player for large quantity sales. Microchip is one of the more popular companies with their PIC microcontrollers. Atmel is also well known because of the Arduino platform for developers.
How do I program it?
Each microcontroller company will have its own specific development tools.
These tools usually include a software development environment and a hardware programmer.
For example, the Microchip PIC chips use the MPLAB software and a programmer like the PICKit 3.
There are often in circuit programmers as well as chip socket programmers depending on the company.
One example of socket programmer is the one offered by Melabs that is sold in addition to their PIC complier.
Development layer tools like Arduino have a preloaded bootloader on the chip that allows the user to reprogram the microcontroller without the need of a hardware programmer.
That means the chip was originally programmed by the creator of the Arduino board.
Some development groups find it easier to create their own bootloaders in house or to go with open source options. This means they can program their microcontrollers once with a hardware programmer, and then from that point forward it can be programmed by some other bus interface (like USB or serial).
Microcontrollers operate in an Assembly language that is native to its processor design. What happens is that most development software environments have a higher level programming language, like C, that compiles the designers code into Assembly.
The Assembly file is then translated into a hex file that is then stored in the microcontrollers memory so that it can execute the program.
There are many companies out there that create compilers for designers that are often easier to use and develop with than the environment created by the microcontroller manufacturer.
The general suggestion on whether or not to use an "easier" compiler comes down to a couple of key factors.
First off, if you are new to microcontrollers and want to get quicker to an end result, then typically the 3rd party compilers will help you get there faster and easier.
Second, if you plan on the design being low quantity and it is more of a research or hobby scenario, then this might be a great option.
However, if you plan on designing something for a production environment and for the long term, then usually you should stick with the manufacturer's development environment.
Why you ask? It turns out that many companies that make 3rd party compilers don't last near as long as the chip company they intend to support.
After a few years if your 3rd party compiler company calls it quits, all of your hard work in the form of code could become useless. When that happens it will often cause a lot of trouble for the product or company that is using that code.
An example 3rd party compiler for Microchip PICs is the PIC Basic Pro compiler by Melabs. It uses a Basic type language instead of C, and has been around for over 15 years.
Another example is the Arduino development platform, which has several board designs and lots of documentation. Often, Atmel microcontrollers are used with these designs.
In summary, microcontrollers are some of the most useful chips in the electronics designers tool kit. They have a ton of capabilities and are very flexible given their ability to be programmed by a high level language.
It's a great idea to choose one of the top companies in the industry for new designs so that you have a better chance of your design not going obsolete on you over the years.
It is also wise to use the manufacturers software tools for production level designs. If you are a hobbyist or small quantity developer, then it might make sense to invest in a 3rd party tool to help you get up the learning curve faster or help cut down code time.