Getting started with Embedded Systems — 2: Microcontrollers
In this second article of the getting started with Embedded Systems, we go over one of the main component of the system, the brain, the microcontroller.
1. What is a Microcontroller?
A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. A typical microcontroller includes a processor, memory and input/output (I/O) peripherals on a single chip. (techtarget.com)
The following block diagram shows what a typical microcontroller is made of.
I will go over few of the most important components of a typical microcontroller.
CPU and Memory
The most important component of a microcontroller is without a doubt the CPU (Central Processing Unit) that is essentially the brain. All the operations go through it. ARM is nowadays the dominant architecture for CPUs. ARM has three different categories of microcontroller: A for Application processors, R for Real-Time Processors and M for Microcontrollers. In the block diagram of the Silicon Labs EFM32™ GG11 32-bit microcontroller, it shows an ARM Cortex-M4 a typical processor for simple embedded systems.
A microcontroller also contains a few types of memories. I will briefly go over the two main ones: ROM and RAM.
ROM (Read Only Memory). Type of memory where the information is programmed into the device once, but can be accessed quickly. This is where the firmware running on the microcontroller is typically stored.
RAM (Random Access Memory). Type of memory where the information can be stored and retrieved easily and quickly. Being volatile, the memory is lost when power is removed.
Serial Interfaces
To communicate with other components of the embedded systems such as sensors, actuators or boards, the microcontroller must have different interfaces available. I will go over few of the most popular ones.
I2C (Inter-Integrated Circuit) is a communication protocol widely popular in the industry and consists of only two lines SDA (Data line) and SCL (Clock line). Each chip (slaves) that wants to communicate with the microcontroller (master) on this data bus has an address. One chip can communicate with the master at a time. For more information about this protocol, I would recommend reading about it on Sparkfun.
SPI (Serial Peripheral Interface) is another extremely popular serial interface. It consists in four lines: CL (Clock), MOSI (Master-Out-Slave-In), MISO (Master-In-Slave-Out) and CS (Chip Select). One disadvantage of SPI is that it requires an additional CS line for each slave that wants to communicate with the master. For more information about this protocol, I would recommend reading about it on Sparkfun.
UART (Universal Asynchronous Receiver/Transmitter) is a block of circuitry responsible for implementing serial communication. It consists in only two lines RX (Receive) and TX (Transmit). The RX of one device is connected to the TX of the other and vice versa for the other line. For more information about this protocol, I would recommend reading about it on Sparkfun.
CAN (Controller Area Network) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other in applications without a host computer. It is a message-based protocol. For more information about this protocol, I would recommend reading this TI document.
Analog Interfaces
In order to interface with the analog world, a microcontroller typically contains ADCs, DACs and Analog comparators.
ADC (Analog-to-Digital Converter) convert analog signals into digital signals. One example use is to sample the temperature coming out analog from a temperature sensor.
DAC (Digital-to-Analog Converter) convert digital signals into an analog signals. One example use is to play music on a speaker.
Analog Comparator compare two incoming signals. For example, it can be used to detect a pulse coming in.
2. Development boards
Now that we know a little more about microcontrollers, how do we work with them? A good way to get started with microcontrollers is to get a development board. These boards typically contain a microcontroller along with some exposed GPIOs (General Purpose Input Output) for connecting other devices, IOs (USB, HDMI,…) and networking capabilities (Ethernet,…).
Arduino
The easiest way to start in the Embedded System world is probably to get an Arduino. These boards are readily available, relatively cheap and comes with a lot of support from the dev community. Arduino are programmable in C++ through the Arduino software. A lot of tutorials and codes are available online to build simple or complex systems.
Launchpads
The next step would probably be to get a development board to program an actual microcontroller in C or Assembly.
Texas Instruments (TI)
TI provides great support for its TM4C123 launchpad. It has an ARM Cortex-M4, a few push buttons, LEDs, micro-USB, JTAG for debugging and quite a bit of GPIOS to develop a simple application.
Bluetooth: Nordic Semiconductor
If you would like a microcontroller with Bluetooth connectivity a great way to get started is to play with the low-power Nordic Semiconductor microcontrollers. Their SDK (Software Development Kit) is extensive and allow rapid prototyping. It also supports NFC.
WiFi: Particle Photon
Particle offers cheap modules such as the Particle Photon to build IoT products that connect to the Internet using Wi-Fi. They provide an IDE, SDK along with a Cloud service. The hardware starts at $19.
Raspberry PI
Another alternative are the more expensive boards that can run more advanced Operating Systems such as Linux distribution.
The Raspberry Pi 3 is a popular choice in the community, it is under 50$, includes HDMI, Ethernet, Wifi, USBs, GPIOs, a CPU that can run a Linux distribution. It has a big community willing to help online and a lot of great tutorials.
The next article in this Getting Started with Embedded Systems series will be about Hardware: Schematic, PCB design, Manufacturing. If you have any question or comment feel free to reach out to me on twitter @cDugue.