Look Past Your Computer’s Look: An Introduction to Embedded Systems

Sagar Setu
The Startup
Published in
9 min readMay 31, 2020

What is an embedded computer and how is it different from your personal computer?

Photo by Harrison Broadbent on Unsplash

Above is an image of Arduino UNO, an example of a Single Board Computer (SBC). When I show this to my friends from software engineering background and ask them what they know about it, the most common reply I get is “Sorry bro! Don’t know electronics!”. I will try to show through this article how similar it is to the personal computer most people are familiar with, and that embedded development is perhaps just a week of introduction away if you know how to program.

During my days as a graduate student, I assisted quite a few peers in getting that motor running or hooking up a sensor in their experimental setup. All of them were people with decent experience in programming and great analytical skills. However, I have found that wires confuse people. Embedded computers come with their own set of jargon, and sometimes the learning curve can be steep. I intend to pen down below a set of information that I always found helpful in bringing such an embedded enthusiast up to speed. This is not supposed to be theoretically coherent or even factually precise at all times. The intention is to minimise the time needed to introduce embedded systems to anyone with basic programming experience and help them quickly develop that MVP/experimental setup.

Technically, what they were all looking for is a computing hardware and software that performs data acquisition, processing, storage and transfer as a part of a bigger system/project — by definition, an embedded system. But that’s what a computer does anyway, right? Right! And we need the same, at a lower cost, smaller size, smaller power consumption and with LOTS of options to connect different kinds of sensors, motors, screens or any other external unit. Get comfortable with the fact that it is just like the personal computer you are so familiar with, and you will get started in no time.

Components of a computer

I don’t know what they are teaching kids in schools these days (is pluto still a planet??), but if you grew up in the 90's like I did, you were probably introduced to the block diagram of a computer similar to this:

Von Neumann Computer Architecture (source: Wikipedia)

What an absolutely garbage way of teaching kids anything! But over time, as I became a user of personal computer, and then a programming enthusiast, the different components started to make sense. Let us break down what happens when we write a computer program:

  1. Information is input using keyboard and mouse (input devices)
  2. We see what we are typing on a screen, or hear music over speakers, or finally display the result ‘Hello World’ (output devices)
  3. We can save our program on the computer’s hard disk (secondary memory)
  4. The machine can convert the program we wrote in to a machine readable set of instructions and run it whenever we want (the processor or CPU)
  5. The computer needs to temporarily store information in the RAM about the ‘Hello World’ program while it is running (primary memory)

The input and output devices can be clubbed into one category of peripherals, which are connected to the essential components of the computers via ports or buses (eg. Universal Serial Bus, or USB). These are precisely the components we have on the Ardunio UNO single board computer pictured in the beginning of this article. It contains the ATmega328P microcontroller, a few tech specs of which are listed below:

  1. Speed upto 16Mhz — Your PC probably has a CPU with speed in GHz
  2. 32 KB Flash Memory (secondary memory) — Your PC has a hard disk that can store hundreds of GB
  3. 2 KB SRAM (primary memory) — Compared to a few GB on your PC
  4. Options to connect peripherals (input and output devices) using PWM, SPI, I2C, SPI, ADC etc. — On your PC, you must be using input devices on USB, or your display peripheral using HDMI.

So, essentially, Arduino UNO can do everything that our personal computer can, but in a relatively rudimentary way (with some use cases it does better in!). Most of the essentials are packed into a single chip, the ATmega328P. This kind of tightly integrated unit on a single chip is called a microcontroller. A microcontroller needs some basic accessories to run, like a power management circuit and crystal for timing. When all of these are packed on a single board, it is called a Single Board Computer and we get a fully functional unit like the Arduino UNO.

Let us look at another Single Board Computer Raspberry Pi, the specifications of which might seem a little more relatable.

Raspberry Pi 4 Model B

From the first peek, we might be able to tell a few familiar features on this computer. We can see 4 USB ports, one Ethernet port to plug the LAN cable in, and an audio jack to plug the headphones in. Additionally, it has onboard WiFi and Bluetooth. You can view more details here, but some of the main specs are below:

  1. Speed: 1.5 GHz CPU
  2. Up to 32 GB secondary memory on SD card. We can also connect external hard disk to one of the USB ports if we need
  3. Up to 8 GB RAM (primary memory)
  4. Peripherals (input and output): USB, HDMI, GPIO, CSI camera port, DSI display port, options to use SPI, I2C, UART

Sounds pretty much like our typical personal computer, doesn’t it? It is also capable of running a flavour of Linux called Raspberry Pi OS, so it feels pretty much like using a Linux computer once we have attached a screen, keyboard and mouse to it. All for a price of $35!!

So, what’s different?

Now that we have established that these tiny units may look quite different from each other, but at their core have the same components, let us point out some differences and terms you might come across. At the same time, we will try to establish some guidelines on how to choose an SBC based on your requirements.

Peripherals

Perhaps the new terms like SPI, UART, I2C stood out in the article. Think of them as different methods of communications like WiFi or Bluetooth, some faster than the other, some more power efficient, capable of supporting more devices, and so on. If we are out to build an embedded system, we need to check the communication method on any sensor or other device we want to use, and then check if that kind of communication is available on the SBC we intend to use. After all, you wouldn’t try to pair a Bluetooth device to WiFi, right? For example, connecting an analog temperature sensor to the Analog to Digital Converter (ADC) on Arduino would be a breeze (like here), but we would need to use additional hardware if we want to use it with Raspberry Pi. Although, Raspberry Pi has much more computational power, it is not ideal for this use case. Similarly, if we want to use a USB web camera, and want to display something on a screen that connects using HDMI and stream it online using Ethernet, we are better off using a Raspberry Pi. Choosing the right input and output device with compatible SBC is perhaps the most important step in building your next embedded prototype.

Operating System

You probably use a system that runs Linux, macOS or Windows. But you might have guessed that you wouldn’t have that luxury (or constraint!) on all embedded devices, specially the tiny ones. Here are the most common options you would have:

  1. General Purpose Operating System: Raspberry Pi lets us run a version of Linux, while there are tons of other SBCs support some other form of Linux or even Windows. One of these is the choice to make if you want a familiar development and deployment environment as your PC.
  2. Real-time Operating System (RTOS): On most of the embedded platforms, we would not have the resources (CPU and memory) to run a popular general purpose OS. Additionally, general purpose OS is not even the right choice to make! For example, our desktop OS might choose to load a web page sluggishly while we perform some computationally intensive task in parallel. However, this sluggish performance is unacceptable on a drone and will lead to a crash, so, all the applications running on it need to run smoothly with guarantee. This is where Real-time operating systems come in. They usually have a much smaller footprint in terms of CPU and memory utilisation and can guarantee hard real-time performance. A couple of popular RTOS are FreeRTOS and NuttX. This real-time performance is another reason why microcontrollers are preferred for mechatronic devices like drones over more powerful SBCs that support general purpose OS.
  3. Baremetal programming: Going back to the example of reading a temperature sensor, some tasks are quite simple and a ‘for loop’ may be sufficient for it. In such a case, there is no need to burden the computer with running any OS, and one can directly write a single simple program that runs indefinitely on it. Such a practice is called baremetal programming, and suits most of the single if-this-then-that scenarios.

Few other jargon

Some of the common terms you might encounter:

A. Toolchain (cross-compilation): When we write a program on a desktop and compile and run it, everything happens on the same computing platform. However, if we write and compile the program on the Desktop and deploy and run it on another system (the embedded computer), we need a different compiler known as toolchain. However, you won’t need toolchains if you are developing on the SBC itself or a platform similar to SBC, like in the case of Raspberry Pi.

B. Firmware: Think of Firmware as the software that does low-level interaction with the hardware. This allows us to use high-level languages and easily write our application software using the abstraction provided by the Firmware. Typically, Firmware is provided by the device manufacturer and most of the user code goes into writing the application.

C. Bootloader: Similar to Firmware, there are pieces of software on the embedded system that are used to device management that run only once when the device boots. The bootloader usually configures the computer for usage, sets up the clock, memory and peripherals so that your application software does not need to handle these things. The bootloader gets stored at the beginning of the secondary memory, and hence, is the first program to get executed. Once it is done executing, it kick-starts the Firmware and application software.

D. MCU/ MPU: Microcontrollers (MCU) and microprocessors (MPU) consist of the core computing components of all the computers, but differ in how the components are packed. In an MCU, everything is on a singe chip, while in an MPU, the components are placed on separate but tightly interconnected chips. MCUs tend to be cheaper and offer lower computing power and memory than MPUs. However, since everything is placed on a single chip, it provides better startup times and real-time performance. However, as systems get smaller and applications get more and more demanding, the line between MCUs and MPUs seems to be disappearing.

E. SoC/SoM/SBC: You already know what an SBC is. Imagine if we removed the physical USB ports on the Raspberry Pi, so that a SBC manufacturer could choose where to place them. They might even decide to omit USB ports altogether if the application requires none. Same could be done with the Ethernet port, and other similar components on the SBC. This stripped down version of SBC is called a System on Module (SoM), like the Raspberry Pi Compute module. In turn, the SoM is built around a System on Chip (SoC), the Broadcomm BCM2837, which has all the core computing components inside it. SoCs are built around an MCU or an MPU, along with other specialised units like neural network processor, encryption accelerator, audio/video encoders , memory units etc.

Photo by Harrison Broadbent on Unsplash: The black chip at the centre is the SoC.

In general, MCU/MPU+ other special units -> SoC -> SoM -> SBC.

Hopefully, this article will help developers planning to prototype an embedded system by removing the perception of “so much electronics” and getting lost in jargon. Pick your use case, pick your sensors and output devices and treat your embedded computers just like your personal computers. Feel free to drop your comments and requests for articles that may help you take the leap into embedded development.

--

--