system Archives - Electronic Guidebook https://electronicguidebook.com/tag/system/ A place to help you with your electronic needs Mon, 27 Jul 2020 23:03:07 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://electronicguidebook.com/wp-content/uploads/2020/02/cropped-electronicGuidebookLogoTransparent-1-32x32.png system Archives - Electronic Guidebook https://electronicguidebook.com/tag/system/ 32 32 230945861 Do microcontrollers have operating systems? https://electronicguidebook.com/do-microcontrollers-have-operating-systems/?utm_source=rss&utm_medium=rss&utm_campaign=do-microcontrollers-have-operating-systems Mon, 27 Jul 2020 23:03:04 +0000 https://electronicguidebook.com/?p=331 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 […]

The post Do microcontrollers have operating systems? appeared first on Electronic Guidebook.

]]>
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.

The post Do microcontrollers have operating systems? appeared first on Electronic Guidebook.

]]>
331
Why a microcontroller is used in an embedded system https://electronicguidebook.com/why-a-microcontroller-is-used-in-an-embedded-system/?utm_source=rss&utm_medium=rss&utm_campaign=why-a-microcontroller-is-used-in-an-embedded-system Wed, 20 May 2020 23:44:08 +0000 https://electronicguidebook.com/?p=271 Think of the human body as an embedded system. It has inputs in the form of our 5 senses (Sight, Hearing, Touch, Taste, Smell), outputs like our fingers, hands, toes, legs and communication means like speech.  However, all these abilities that we possess are useless without one vital human anatomy, the Brain. The Brain has […]

The post Why a microcontroller is used in an embedded system appeared first on Electronic Guidebook.

]]>
Think of the human body as an embedded system.

It has inputs in the form of our 5 senses (Sight, Hearing, Touch, Taste, Smell), outputs like our fingers, hands, toes, legs and communication means like speech. 

However, all these abilities that we possess are useless without one vital human anatomy, the Brain.

The Brain has the task of processing all information it receives from inputs, as well as telling the outputs what to do, and has its own memory where it can store data.

The microcontroller is essentially the brain of an embedded system. 

So, why is a microcontroller used in an embedded system?

A microcontroller is used in an embedded system because it is tasked with processing the flow of data that comes in and goes out. It makes decisions according to code which are written by a developer. It performs operations based on data it obtains via inputs and sends data telling outputs what actions to perform. It also stores information onboard its inbuilt memory.

Just like a human body without a brain, an embedded system without a microcontroller would be redundant.

Embedded systems range in complexity, and specifications, but one thing that is certain is that at the center of it all is a microcontroller controlling all operations.

What is a Microcontroller?

A microcontroller is an Integrated Chip (IC) which includes onboard memory, programmable peripheral Inputs and Outputs, Timers, Serial Communication and many more features that I will cover below.

It is essentially a small computer on a single chip.

While computers come with an Operating System (program that tells the computer what actions to perform), Micrcontrollers do not come installed with an Operating System.

The operating system or program code needs to be written by a developer (in a programming language like C, C++, or Java) and then loaded onto the microcontroller.

Main purpose 

As we saw earlier, the main purpose of a microcontroller is to process data and perform operations based on its program code as well as information received via inputs or serial communication.

It is the main component in an embedded system.

Basic structure

The microcontroller is a very versatile device that has many features depending on the needs of an embedded system.

They range in physical size, memory, speed, and other features.

Below are the features of a common used (by me as well) microcontroller, the AT Mega 8 from the AVR family of microcontrollers produced by Microchip:

  • 8 Kbytes in-system, self programmable Flash program memory
  • 512 Bytes EEPROM
  • 1 Kbyte Internal SRAM
  • Two 8-bit Timer/Counters
  • One 16-bit Timer/Counter
  • Three PWM channels
  • Six 10-bit ADC channels
  • Two-wire serial interface
  • SPI Serial Interface
  • 3 x 8 programmable input/output ports

These are just some of the features. For a full list of features consult the AT Mega 8 datasheet

There are many other microcontrollers from the AVR family which are produced by Microchip.

Microchip isn’t the only manufacturer of microcontrollers. There are many companies that produce microcontrollers built on different architectures. 

However, they all share similar specifications and features. 

The other common microcontrollers available are the PIC, 8051, and ARM.

Difference between Microprocessor and Microcontroller?

Microcontrollers aren’t the only type of processor used in embedded systems.

Microprocessors are very similar to microcontrollers but have their differences.

Both are at the center of an embedded system and are responsible for controlling operations.

Microcontrollers can be seen as stand alone devices that contain memory, timers etc.

While microprocessors do not have their own memory and require extra memory modules to be interfaced.

For an in-depth look at the differences, check this article

What is an Embedded System?

I gave the example of the human body as an embedded system earlier. 

But, what does an electronic embedded system look like? 

What does it consist of? 

Basics of an Embedded System

The basic definition of an electronic embedded system is a system that contains a combination of hardware and software. 

Hardware includes the processing unit (microcontroller or microprocessor), inputs and outputs. 

The software which is loaded onto a microcontroller is a set of instructions that govern how the system runs.

An embedded system is designed for a specific function or functions of a self contained system or part of a larger subset of systems.

An example of an electronic embedded system is a desktop computer.

The computer has software (its operating system) which governs how it operates. This operating system is loaded onto the microprocessor.

It has hardware which include a central processing unit (CPU), inputs (keyboard, mouse, usb ports, HDMI etc) and outputs (computer screen, speakers, printers etc).

Different components of an Embedded System

We now know that an Embedded system consists of Hardware and Software.

I gave a simple example of what an embedded system consists of above. 

But, there are many more components within the Hardware and Software. 

Let’s take a quick look at what they are.

Hardware

Power Supply 

I know I said an embedded system would be redundant without a microcontroller. 

But, it would be utterly useless without a power supply. 

The power supply supplies the entire system with electricity which is needed for all parts of the embedded system to operate.

The voltage requirements of the embedded system all depends on the voltage specifications of devices being used.

The maximum voltage rating of any device should never be exceeded.

Processor

As I have discussed earlier, the processor (either a Microcontroller or Microprocessor) is a vital part of an embedded system.

It gets programmed with all instructions on how the embedded system should operate. 

It has the job of communicating with other components of the system and controlling the flow of data.

Memory

Memory is needed to store the program code (set of instructions which determines how the embedded system functions), and data like variables and constants .

There are three types of memory:

  • Random Access Memory (RAM)
  • Read Only Memory (ROM)
  • Electrically Erasable Programmable Read-Only Memory (EEPROM)

Each memory type plays a specific role when the embedded system is running.

RAM is a volatile type of memory, which means when power is removed from the system, all data in RAM is erased. It is used to store temporary data.

ROM is memory where the program code is stored.

EEPROM is a memory where variables can be stored and once power is removed, does not get erased making it non-volatile.

Microcontrollers have the advantage of having memory in-built on their chips. 

Timer/Counters

Timers and counters are needed when you need to generate a delay, count time between two specific events, and generate pulse-width-modulation (PWM).

Communication 

In order to talk with other devices in an embedded system, it will require some means of communication.

Below are some of the communication methods available:

  • UART
  • SPI
  • I2C
  • USB
  • ETHERNET
  • RS-232
  • RS-485

Input and Outputs

Inputs provide information to the embedded system from the external world.

This can be in the form of a button press, or sensors sensing changes in temperature.

Outputs allow the embedded system display information via LED screens or rotate a motor like in a car.

Software

The next ingredient that will complete our embedded system is software. 

Software is a set of instructions (program code) that can be written in a programming language.

Programming languages can range from C, C++, Java, and Python.

But, the programming language is only one part of the Software component.

Other components include:

  • Integrated Development Environment (IDE)– is a software where the developer can write code in a specific language. 
  • Compiler– converts the code that has been written in an IDE  into machine code which is then loaded onto the microcontroller

Choosing the right Microcontroller for an Embedded system

While microcontrollers are different in size, specification, and complexity, it can’t be said that one microcontroller is better than another. 

It all depends on the specifications of the embedded system. 

If your system needs to process and calculate information at high speeds, you will need to pick a microcontroller with high processing speeds.

If, however, speed is not of concern, but you need a lot of input and output ports, then you will pick a microcontroller with lower processing speeds and more input and output ports.  

So, defining the needs of your embedded system will allow you to make the right choices when picking a microcontroller. m

Example of Embedded Systems that use a Microcontroller

There are many applications where an embedded device uses a Microcontroller as the processing unit.

Below are some examples (this is just some of the common ones. There are many more):

  • Electronic Development boards (Ardunio, AVR Dragon)
  • Automobile
  • Consumer Electronics (mobile phones, Laptops, gaming systems)
  • Household appliances (washing machines, toaster, microwaves)
  • Medical
  • Aviation

The post Why a microcontroller is used in an embedded system appeared first on Electronic Guidebook.

]]>
271