You might be familiar with operating systems, as all computers require an operating system.

An Operating system is a low level software that helps a device like a computer carry out operations such as scheduling tasks and controlling peripherals. 

But, do microcontrollers have operating systems? Unlike computers, microcontrollers do not have operating systems. A microcontroller is essentially empty and void of any software or operating system. You, as the designer, have to write a specific program which is a set of instructions (depending on the specifications of the application) that the microcontroller will run and carry out tasks. 

What is an operating system?

An operating system is a software that acts as a bridge between the hardware and you the end user. 

It manages computer hardware, software resources and provides a service for a computer program. 

Every computer must have at least one operating system that helps it run programs. Many applications that you use like your web browser, Microsoft Word, games you play etc. Since you do not know how to speak computer language, the operating system bridges the gap. 

So, you have the hardware of the computer (Computer screen, Hardware, Memory etc), the Operating system, and you the end user. 

A computer will most of the time come pre-installed with the operating system. If not, a CD with the operating system is provided so you can install it. 

Different structures of operating systems

There are seven distinct types of operating systems.

Single-tasking 

A single tasking operating system can only run one program at a time. 

Multitasking

A multitasking operating system has the benefits of being able to run multiple programs at once.

Single-User

A single user operating system has no factors to distinguish between users. But, it has the ability to run multiple programs at a single time. 

Multi-User

The multi-user operating system on the other hand allows multiple users to use the system at the same time. 

Distributed

Distributed operating systems are designed to manage a group of distributed computers that are part of a network. This gives them the illusion of a single computer.

Templated

In the context of cloud computing, a templated operating system is a virtual machine. This virtual machine is essentially a guest operating system that is tasked with running other virtual machines. 

Embedded

Embedded operating systems are specially created to work on embedded computer systems, which are designed with a specific task in mind.

Real-time

Real-time operating systems are designed to process data or events at specific moments in time.

Library

Last but not least, is Library. The library operating system provides its services in the form of a library. 

Are computers the only electronic devices that have operating systems?

Operating systems are commonly associated with computers or laptops.

But, are there any other devices that use an operating system?

Other devices that use an operating system include Mobile and Embedded systems. 

Smartphones are a standard part of all our lives. They enable us to make calls, surf the net, play games and much more. This device that can fit in your pocket has more processing power than most computers did 5-10 years ago.

They need an operating system just like a computer to manage programs and hardware. However, their operating systems are designed specifically to meet mobile computing needs. Also, the size and complexity of a mobile operating system is scaled back.

Embedded systems are a combination of a computer processor, memory and input/output peripheral devices.

The computer processor can either be a microcontroller or a microprocessor.

While a computer is general purpose, embedded systems are designed for a specific task. Things like an  ATM, home automation, airplane systems etc. 

These types of systems are complex and require an operating system to control software programs and hardware. But, its operating system is far less complex in nature compared to a computer’s operating system.

You also have embedded systems like your toaster, or hair dryer. These devices aren’t very complex and do not require complicated processing and therefore they do not require an operating system.

Different types of operating systems

There are many different companies that manufacture computers. Each computer uses a specific type of operating system.

While there are many operating systems available, below is a list of the most common:

  • Microsoft Windows
  • Apple mac OS
  • Linux 

For mobile devices like smartphones and tablets, the most common operating systems are:

  • Apple iOS
  • Google Android OS

Some examples of embedded operating systems are:

  • Windows CE
  • Minix 3

Why microcontrollers do not have an operating system?

A microcontroller is essentially a computer on an integrated chip. It is designed for use in an embedded system

It has memory, peripherals, and input/outputs just like a computer does. So, why doesn’t it have an operating system?

While computers are designed for a specific purpose and are standardised in their operations, microcontrollers are devices that are customisable. 

Micrcontroller are used for applications where a specific purpose needs to be achieved. 

Computers also carry out complex operations like multitasking, scheduling, and queuing. Therefore require an operating system to manage these tasks.

Microcontrollers weren’t created to carry out complex operations, therefore do not need an operating system. 

Every microcontroller is shipped void of an operating system. 

How does a microcontroller operate without an operating system?

If a microcontroller doesn’t have an operating system how does it carry out operations?

Depending on what the application is, a program will have to be written that will carry out tasks specific to the application. 

For example, if you need to blink an LED every two seconds, you as the designer will have to write a program that does just that. As you can see, there isn’t a specific operating system that exists that is designed for the sole purpose of blinking an LED every two seconds. 

It would be overkill if a microcontroller had an operating system just to blink an LED.

A microcontroller program is typically broken down into two parts; Setup and Loop

Setup

In the setup portion of the program, things like variables, input/outputs, timers, ADC, serial communication etc, are initialized. This happens once.

Loop

The loop is the main part of the program. This is where you as designer writes functions, and tasks for the microcontroller to carry out depending on the needs of the application. This loop runs infinitely while power is applied.

Do you need to write the operating system for a microcontroller? 

Yes, since microcontrollers do not come with an operating system, you will need to write a program code which essentially acts as the operating system.

The program code is a set of instructions that tells the microcontroller what it needs to do. Without it the microcontroller is just an empty device.

But, what instructions do you give it?


Well, that all depends on what you need to be done. If you need to turn on a light when motion is detected, then you will need to write a set of instructions that does just that. So, as the designer, you are in full control of the microcontroller’s ‘operating system’.

What if you do not know how to program a microcontroller?

If you are a beginner just getting started with microcontrollers, writing an operating system for a microcontroller can be a daunting task. 

What if you haven’t got any prior programming experience?

Fear not, even if you do not know how to program a microcontroller, there are many resources available online that can help you with whatever project you want to get involved in. Resources like tutorials, and open source code for many different types of projects. 

Since the microcontroller has been around for a long time, there have been many projects written by hobbyists and makers. The good news is that they have made these available for everyone online at no cost. 

If you want to get started with microcontrollers, I highly recommend the Arduino Platform. It has a great community, multiple tutorials, and code available online .

What programming languages are used to write an operating system for a microcontroller?

Just like there are many different languages that we use to communicate to each other, there are different languages that you can learn to write an ‘operating system’ for a microcontroller. 

A microcontroller can only understand machine code (assembly language). In the early days programmers had to learn to write programs in machine code.

But, this was a very cumbersome process. Therefore, higher level programming languages were developed that made it easier for programmers.

A programmer would write a program using a higher level language, and then used a compiler to convert it into machine code that a microcontroller could understand. 

Common higher level programming languages include :

  • JavaScript
  • C++
  • Python

Loading a program code (operating system) onto a microcontroller

If you have written the program code for a microcontroller but have no way to load it onto it, all your hard work writing that program is wasted.

Loading the program onto a microcontroller is a crucial step and requires a few different tools. 

You will need a compiler that converts the code you have written into machine code, a programmer (that connects your microcontroller to the computer) and software that can send the machine code to the microcontroller via the programmer. 

The great news is that the manufacturers of microcontrollers develop their own Integrated Development Environment (IDE) that has the ability to compile and send the code to the microcontroller.

Common used IDE’s are:

  • Atmel Stuio
  • Arduino IDE

Do microprocessors have operating systems?

Microprocessors are very similar to microcontrollers, but have some differences.

A microprocessor does not include peripherals (memory, timers, serial communication etc) like a microcontroller does. It only has the ability to provide processing functions. External peripherals need to be added to extend its capabilities.

Just like microcontrollers, they do not come with an operating system. They are not devices that serve a specific purpose. Depending on the specifications of the project, the programmer can write a program that meets those specifications.

However, many microprocessors are used in devices that have operating systems like computers, and mobile phones. 

Final thoughts

A microcontroller is not a general purpose device. What this means is that it does not serve any specific task. It has many features and capabilities, but does not have an operating system.

An operating system is designed to help an embedded system (like a computer or mobile phone) manage its hardware and software resources, and has a specific purpose.

You as the programmer has the job of writing the program (which is essentially an operating system) that governs how the microcontroller will operate.

Categories: Microcontrollers