Microcontrollers Archives - Electronic Guidebook https://electronicguidebook.com/category/microcontrollers/ A place to help you with your electronic needs Wed, 10 Nov 2021 04:39: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 Microcontrollers Archives - Electronic Guidebook https://electronicguidebook.com/category/microcontrollers/ 32 32 230945861 Is raspberry pi a microcontroller? https://electronicguidebook.com/is-raspberry-pi-a-microcontroller/?utm_source=rss&utm_medium=rss&utm_campaign=is-raspberry-pi-a-microcontroller Wed, 10 Nov 2021 04:39:03 +0000 https://electronicguidebook.com/?p=1054 The Raspberry Pi has made a massive mark in the electronic world. It is essentially a tiny computer that can fit in the palm of your hand.  You can connect outputs like monitors or televisions, as well as connect inputs like a keyboard and mouse just like you would a normal computer. The great added […]

The post Is raspberry pi a microcontroller? appeared first on Electronic Guidebook.

]]>
The Raspberry Pi has made a massive mark in the electronic world. It is essentially a tiny computer that can fit in the palm of your hand. 

You can connect outputs like monitors or televisions, as well as connect inputs like a keyboard and mouse just like you would a normal computer.

The great added benefit of the raspberry pi is that it can be programmed according to your needs for a certain purpose or project. It is programmed using coding languages like Scratch and Python

You might be on the lookout for a new raspberry pi, or already have one lying around and are wondering if it is a microcontroller. 

So is a raspberry pi a microcontroller? The raspberry pi is not a microcontroller. It is a single-board (the size of a credit card) that emulates a computer. However, just like a computer, it requires a processor as its brains to operate. It uses a microprocessor (not a microcontroller) as the main processor.

This article shall take a deeper look as to why a raspberry pi is not a microcontroller. 

What is a raspberry pi? – A closer look

To better understand why a raspberry pi is not a microcontroller, it will help to take a closer look at the raspberry pi individually. 

The first raspberry pi was launched in 2012, created by the Raspberry Pi Foundation, which is a UK charity whose main focus is to make it easier and more accessible for people to learn about computing.  

So, what exactly is it?

The raspberry pi has all the makings of a small computer which can fit in the palm of your hand. It uses Linux as its operating system.

It is very similar to a development board as it includes a set of General Purpose Input-Output (GPIO) pins allowing you to connect a range of inputs and outputs for prototyping personal projects such as home automation.

Different parts of a raspberry pi

Just like a computer, the raspberry pi is an embedded system comprising different hardware sections that each have its own functionality contributing to the overall system. Below are the hardware components;

  • Central Processing Unit (CPU)
  • Memory (RAM)
  • Graphics Processing Unit (GPU)
  • Ethernet port
  • GPIO pins 
  • Xbee socket
  • Power source connector 
  • Universal Asynchronous Receiver-Transmitter (UART)
  • HDMI 

Central processing unit (CPU)

The first and most crucial hardware component of a raspberry pi is the Central Processing Unit (CPU)

The CPU is the brain of the entire system which has the job of undertaking all operations (logical and mathematical) that occur within the raspberry pi. 

It is very similar to how our brain handles all operations and tasks within the system of the human body. 

The raspberry pi uses an ARM11 series microprocessor as the CPU (we shall take a more in-depth look at this when we discuss why a raspberry pi is not a microcontroller).

Memory (RAM)

Random Access Memory (RAM), is where a computer stores its short term memory. It uses it for all active programs and apps. 

It is used for the same purposes in a raspberry pi for things like compiling large pieces of software, running server workloads, and running applications. 

Graphics processing unit (GPU)

The Graphics Processing Unit is a chip within the raspberry pi that is responsible for accelerating the process of graphics rendering. It is capable of processing many pieces of information simultaneously. 

Ethernet port

The great ability of the raspberry pi is to be able to access the internet. It does this through its Ethernet port which connects to a router. 

GPIO pins

The General Purpose Input Output (GPIO) pins are used to interface digital and analog inputs and outputs to the raspberry pi such as buttons, sensors, motors, LEDs, etc. This allows you to give the raspberry pi added abilities. 

XBEE socket

Wireless communication is very prominent in the electronic scene. The Xbee socket is used to give the raspberry pi the means of wireless communication.

UART

The Universal Asynchronous Receiver Transmitter (UART) is another form of communication that the raspberry pi utilises. It is an input/output port used to transfer data serially (one at a time) in the form of text. 

HDMI

Last but not least, is the HDMI port.

HDMI or High Definition Multimedia Interface is an audio/video interface used for transmitting uncompressed video and audio data. The raspberry pi has an HDMI port to be able to interface with other HDMI compatible devices such as monitors and televisions.

Why the raspberry pi is not a microcontroller

Now that we have taken a closer look at the raspberry pi, we can answer the question if it is a microcontroller or not.

So, is a raspberry pi a microcontroller? 

No, the raspberry pi is not a microcontroller. As we just saw, it is essentially a miniature embedded computing system the size of a credit card, which comprises different parts such as the CPU, GPU, GPIO pins, etc. It is a development board similar to an Arduino (however, a raspberry pi has greater computing power). 

A microcontroller on the other hand is also very similar to a computer, which is embedded on a single integrated chip. It is used as the brain of embedded systems to handle computations and manage tasks.

The key difference is that a raspberry is an embedded system already set up with all necessary hardware components which we saw earlier, whereas the microcontroller is just a single chip and does not come set up. 

Does a raspberry pi use a microcontroller or microprocessor?

Earlier we saw that one of the key components of the raspberry pi is its central processing unit (CPU), which has the job of undertaking all operations (logical and mathematical).

The CPU is the brain, and without it the raspberry pi would be useless. 

We just saw that a raspberry pi is not a microcontroller. 

But, what you need to know is that the CPU in embedded systems use devices like a microcontroller which are capable of handling operations. 

There are two main options of devices used for CPUs; Microcontrollers and Microprocessors.

The real question is, does a raspberry pi use a microcontroller or microprocessor? 

The raspberry pi uses a microprocessor. Since the raspberry pi is a mini computer, it needs to have hardware specifications to match. For that reason, a raspberry pi primarily uses a microprocessor as the CPU. This comes down to the microprocessor having faster processing speeds than the microcontroller. It is capable of handling more instructions per second. 

Differences between a microcontroller and microprocessor

The speed of a microprocessor and microcontroller is just one of the key major differentiations between the two. However, there are many other notable differences. 

Let’s take a look at some of them. 

The first difference is that a microprocessor contains only a CPU within a single chip, whereas a microcontroller consists of a CPU, memory, input/outputs and other peripherals all on a single chip.

A microprocessor uses an external bus to connect to memory and other peripherals, while a microcontroller uses an internal bus. 

The architecture that these two devices are built on is also different. A microcontroller utilises the Harvard architecture, and a microprocessor is built on the Von Neuman architecture.

Microprocessors are capable of much higher speeds compared to a microcontroller (in the order of gigahertz vs megahertz). 

Applications of microprocessors include;

  • Computers
  • Home security systems
  • Gaming systems
  • Transportation such as planes and cars
  • Medical devices
  • Mobile phones 

Applications of microcontrollers include;

  • Calculators
  • Washing machines 
  • Robotic arms
  • Cameras
  • Digital multimeters 

Why does raspberry pi use a microprocessor and not a microcontroller?

By looking at the differences and some of the applications, you can see that microprocessors are used in more complicated systems where millions of instructions are executed every second. 

The raspberry pi isn’t any different. It is used for many complex applications such as home automation, internet of things, etc, which would require a microprocessor for its heavier and faster lifting powers. 

Is there a raspberry pi that uses a microcontroller?

There isn’t one single version of the raspberry pi.

It has many different versions and variations, each having its own unique uses and characteristics. Things that will vary from one pi to the next include speed, memory, physical size and weight, cost, and number of input/outputs.   

For example, one version might have more GPIO pins, lower power consumption, a different type of microprocessor etc. 

Below are some of the different types of raspberry pi;

  • Raspberry Pi 1 model B
  • Raspberry Pi 1 model A
  • Raspberry Pi 1 model B+
  • Raspberry Pi 1model A+
  • Raspberry Pi Zero
  • Raspberry Pi 2 B
  • Raspberry Pi 3 B
  • Raspberry Pi Zero Wireless

All the versions listed above use a microprocessor as the CPU. However there is one specific, raspberry pi board that uses a microcontroller; the Raspberry Pi Pico.

This particular board is created using the RP2040 microcontroller, designed by the Raspberry Pi foundation.

What types of microprocessors does a raspberry pi use?

As different  raspberry pi boards will have their own specific uses and characteristics, each of them also use different types of microprocessor specific for certain applications. 

The table below highlights the different types of microprocessor used for the different raspberry pi boards.

Raspberry Pi Board Microprocessor
Raspberry Pi A+700 MHz ARM11
Raspberry Pi B+700 MHz ARM11
Raspberry Pi 2 B900 MHz Quad-Core ARM Cortex A7
Raspberry Pi 3 B 1.2 GHz, Quad-Core 64-bit ARM Cortex A53
Raspberry Pi 3 B+1.4 GHz 64-bit ARM Cortex A53
Raspberry Pi Zero1 GHz single-core ARM11
Raspberry Pi Zero Wireless 1 GHz single-core ARM11

The post Is raspberry pi a microcontroller? appeared first on Electronic Guidebook.

]]>
1054
Application of a microcontroller - 10 most common https://electronicguidebook.com/application-of-a-microcontroller-10-most-common/?utm_source=rss&utm_medium=rss&utm_campaign=application-of-a-microcontroller-10-most-common Tue, 19 Oct 2021 21:37:32 +0000 https://electronicguidebook.com/?p=1025 Our world is filled with electronic products that entertain us, make our lives easier, allow us to communicate with each other, help us prevent diseases, and much more.  More often than not, at the heart of all these electronic products is a Microcontroller. This awesome device is the brain that controls all actions and takes […]

The post Application of a microcontroller - 10 most common appeared first on Electronic Guidebook.

]]>
Our world is filled with electronic products that entertain us, make our lives easier, allow us to communicate with each other, help us prevent diseases, and much more. 

More often than not, at the heart of all these electronic products is a Microcontroller.

This awesome device is the brain that controls all actions and takes care of computations within an electronic device. 

Because of its endless capabilities, there are many uses of microcontroller and it is not confined to one singular application

A microcontroller can be found in applications such as consumer electronics, medical devices, the automotive industry, aviation, marine, and much much more.

This article shall take an in-depth look at the microcontroller and its many applications.

Deeper look at the microcontroller

To better understand why a microcontroller is used for a specific application, it will help to take a closer look at its history, how it is constructed, the different types available, etc. 

What it is a microcontroller

The world is filled with electronic devices that have a specific purpose whether it be playing music, making coffee, toasting bread, etc. 

I would be surprised if you didn’t find a Microcontroller at the center of most of these systems.

A microcontroller is an Integrated Circuit (IC), which has all the capabilities of a computer. It consists of a central processing unit (CPU), onboard memory and inputs/outputs all of which are programmable. 

A microcontroller has the task of ‘controlling’ operations (much like a traffic cop controls traffic) hence why the second half of its name is ‘controller’. The ‘micro’ is aptly there because of its size. 

It is used by professional engineers, students, and hobbyists for many different applications (which shall be discussed in more detail later).

History of the microcontroller

The field of electronics has been around for some time. But, the microcontroller wasn’t the star of the show from the very beginning. 

It came to the forefront of electronics a bit later.

Before the arrival of the microcontroller, Logic Gates were used to perform Boolean logic functions (which is the basis of digital electronics).  

These logic gates were built using Transistors. A large assembly of logic gates would form many digital circuits (which meant many transistors). 

Later, with the invention of Integrated Circuits, many transistors could be fitted onto a single chip (this meant a reduction in size of digital circuits).

By the early 1970’s these integrated circuit chips could hold as many as 10,000 transistors. This crucial advancement in digital electronics is what made the invention of the microcontroller possible. 

The first microcontroller

We can thank one Gary Boone, who worked for Texas Instruments for giving the world the first ever microcontroller in the early 1970s.

He designed and created an integrated chip that had over 5000 transistors, 3000 bits of program memory, and 128 bits of access memory. 

This meant it but could be programmed to have a variety of functions. 

This first microcontroller was called the TMS1802NC.

Over the years, the microcontroller has had further advancement with the help from many different companies. 

In the early 1990’s Electrically Erasable and Programmable Read Only Memory (EEPROM), meant that the microcontroller wasn’t limited to one function for its lifetime after it had been programmed.

Now, you could program the microcontroller, erase the current program, and reprogram it multiple times.

Application of a microcontroller

At the start I briefly mentioned some of the applications of the microcontroller. But, those are just a few of the many applications. 

Rather than name every single device that uses a microcontroller, I will name the main fields under which devices are most likely to use them.

Note, this isn’t an exhaustive list by any means. These are just the most common. 

Let’s take a look! 

Application #1 of a microcontroller: Consumer Electronics

First on the list is Consumer Electronics.

Consumer electronics is a term that defines electronic equipment that is used on a daily basis (mostly in one’s own home).

This is a very broad term that encompasses many other categories such as Entertainment, Communication, Recreation, Kitchen Appliances, etc. 

Consumer electronics are often referred to as ‘black goods’ due to their electronics being housed in a dark casing. 

Below are some example of consumer electronics that would have a microcontroller;

  • Radio
  • Microwave
  • Television
  • Heater/ Fan
  • Calculator
  • MP3 Players
  • Kindle
  • Christmas lights 
  • 3D Printers

Application #2 of a microcontroller: Medical

The Medical field has benefited immensely from using microcontrollers. 

As you can imagine, medical practices before the advent of the microcontroller would have been quite primitive. 

Also, we have all heard the phrase ‘prevention is better than cure’. In the medical applications this means that if you can find a problem at the early stages, you have more chances of eliminating it.

While us humans have amazing abilities, and intelligence, there is a limit to what we can detect within a human body. 

Microcontrollers, along with other technology enable us to be able to detect a disease with a human body before it is too late. 

These devices include;

  • X-ray
  • Magnetic Resonance Imaging (MRI)
  • Electrocardiogram (EKG)
  • Computed Tomography (CT scan)
  • Sonography (Ultrasound imaging)
  • Heart rate monitors
  • Blood pressure monitors

As well as detection, microcontrollers are used in medical devices to help perform the functions of organs that might have deteriorated with time, are not working right, or might have been damaged. Devices such as;

  • Dialysis machines (performs function of liver)
  • Pacemakers (used to control abnormal heart rhythm)
  • Hearing aids
  • Robotic prosthetic limbs
  • Glucose monitoring systems (for Type 1 Diabetes)

Microcontrollers can also now be found in the surgery room. Robots are used to help surgeons with many different types of surgeries.

Application #3 of a microcontroller: Entertainment

In the age before electronics and microcontrollers you might have been limited to a few activities to help pass your time. Things like reading a book, going for a walk, playing the guitar, playing hide and seek, etc (Not that any of these are bad).

Nowadays, we are all spoiled with a plethora of devices to entertain ourselves.

Even before the microcontroller, there were electronic devices which could help entertain and pass your time. 

But, these devices grew not only in quantity, but complexity and quality as well with the help of the microcontroller. 

Your old transistor radio might have been limited to a couple of stations, with subpar sound quality. But, now your digital radio will have the capability to access all stations on the FM and AM bandwidth with superior sound quality, while being able to play CDs as well. 

Below are some examples of electronic devices to help entertain you in one way or another;

  • Television
  • Computer/Laptop
  • Projector
  • Ipad
  • Ipod
  • Digital radio
  • Xbox
  • Playstation
  • Nintendo
  • Kindle
  • Smartphone

Application #4 of a microcontroller: Instrumentation and process control

Instrumentation and Process control is a field of Engineering that deals with control theory. It is used to manufacture equipment to help design, monitor, and control many different processes across many different industries.

These processes ensure that the overall system is productive, efficient, and repeatable. 

The overall system consists of software and hardware which includes, sensors, actuators (mechanical and electrical), and of course a microcontroller. 

For example, in a chemical plant,having a system that monitors the temperature and ensures it stays within defined limits is crucial to avoiding potential disasters such as explosions.

Below are industries that use implement instrumentation and process control;

  • Oil and Gas
  • Petrochemical
  • Wastewater treatment
  • Fabric
  • Food and Beverage

Application #5 of a microcontroller: Communication

Communication is a necessity in everyday life. They say communication is one of the pillars to a happy marriage (so it must be very important!).

We use communication for many different purposes; to share information, make a statement, ask questions, express wants/needs/desires, keep in touch with loved ones, express emotions and much more.

But, most of the time you might not be in the same room with the person you might want to communicate with. 

They might be in another household, city, or country. 

Before you might have had to write them a letter, post it and wait a couple weeks for a reply. 

Lucky for you and me, nowadays, microcontrollers are used in many of these electronic communication devices to allow us to communicate with loved ones, colleagues, strangers, instantaneously, even if they are in another country (they might as well be in the same room as us!).

Devices such as;

  • Smartphones
    • Calling
    • Video calling
    • Texting
    • Email
  • Computers and Laptops 
    • Video calling
    • Email
    • Blogging
  • Walkie talkies
  • Telephones
  • Fax machines 

Application #6 of a microcontroller: Office

Whether you are an Accountant, Engineer, IT specialist, Receptionist, work in Human Resource, etc, you will more often than not be working in an office environment. 

This is the space where you carry out your daily tasks which help take the company you work for closer to their goal whatever it may be.

These tasks might be specific to your job, or might be similar across different disciplines. 

There are a myriad of electronic equipment which have microcontrollers to help you complete tasks in a more efficient manner (helping keep your boss happy).

Each different device has a specific ability to complete a specific task. Below are some of the most common devices that have microcontrollers  which you would find in an office setting;

  • Scanners
  • Printers
  • Paper shredders
  • Laminators
  • Calculators
  • Projectors
  • Binding machines
  • Automatic staplers (in case you have a lot of stapling to do)

Application #7 of a microcontroller:  Kitchen

Imagine having to wake up, go outside, collect firewood, start a fire, and then prepare your breakfast. These are a lot of steps to just make an omelette. 

Also, imagine having to repeat the process for lunch and dinner. This would get annoying quite fast.

Luckily, people realised this early on and created devices that are much more efficient at preparing and making food and drinks in the kitchen.

These days our kitchens are filled with appliances that make many cooking tasks much more efficient as well as tasks that we might not be able to accomplish, like preserving food. 

Common kitchen appliances include;

  • Microwaves
  • Ovens
  • Toasters
  • Refrigerators 
  • Coffee machines
  • Blenders
  • Air fryers 

Application #8 of a microcontroller:  Housekeeping

There are many mundane tasks that we need to carry out around the house.

Tasks like washing the clothes, drying the clothes, washing the dishes, cleaning the floor, cleaning the toilet, and the list goes on.

Without sounding like a broken record, we are blessed these days with electronic devices that help make these mundane tasks, well, less mundane! 

Devices such as;

  • Washing machines
  • Dryers
  • Dishwashers
  • Vacuum cleaners 

Application #9 of a microcontroller:  Safety

Unfortunately, the world is filled with many dangers.

But, we cannot live our lives scared all the time of every danger that exists. This is not what living should be. 

However, having systems in place to ensure that we are aware of dangers, or when a danger is imminent, is the best way to avoid injury or death. 

Since we are limited by our sensing abilities, we can harness the power of the microcontroller to help us stay one step ahead of the game. Technologies such as;

  • Fire alarms
  • Smoke alarms
  • Security systems
    • PIR sensors 
  • Gas monitoring systems 

Application #10 of a microcontroller:  Transportation

Whether you need to go to your local grocery store, across the ocean to another country, and now even space, you can do so thanks to the advancement in Transportation

Microcontrollers are used extensively within sub-systems of  cars, motorbikes, boats, ships, trains, aeroplanes, spaceships, for a variety of different functions (safety, guidance, monitoring, etc). 

Below are some subsystems for the different transportations, that use microcontrollers;

  • Guidance
    • GPS
  • Safety 
    • Airbags
    • Automatic braking system (ABS)
  • Monitoring
    • Temperature levels
    • Oil levels
    • Speed
    • Distance
    • Acceleration
  • Entertainment 
    • Radios
    • CD players
    • Televisions
  • Communication
    • Bluetooth
    • Wi-Fi
    • Radio

Main purpose of a microcontroller for these applications

But, what is the main purpose of using a microcontroller for these applications?

As I mentioned earlier, the microcontroller has the main task of making computations and controlling tasks much like a traffic cop directing traffic.

A better analogy and way to visualise this is the human body. 

So, the human body will represent an electronic system. It has many inputs (senses), outputs (muscles), and other subsystems (organs such as the heart, liver, kidney, etc).

The brain is one of the most important pieces of the human body (the other being the heart of course). The brain best represents the functionality of the microcontroller.

It receives signals from your senses, and sends signals to other parts of the body like the organs and muscles, controlling the overall operation.

An embedded system is the combination of hardware and software components. 

Microcontrollers are used in the exact same manner in embedded systems in many of the applications we just covered. 

They ensure that all parts of the system work cohesively to achieve what that specific system was created to do. 

The flowchart above shows the typical flow of information within an embedded system. 

Different manufacturers of microcontrollers

Even though the first microcontroller was created by Texas Instruments, there have been many other companies who were part of the initial race to create the first microcontroller, as well as others who joined later on.

While the overall purpose of each microcontroller stays the same, the Architectures on which they are built on will vary across different manufacturers.

There are two main architectures which microcontrollers are built on; Harvard and Von-Neumann.

Harvard Architecture  defines separate memory spaces for program and data which allows both to be accessed at the same time. 

Whereas in the Von-Neuman architecture, data and programs are stored in the same memory space. 

Also, there are many other microcontroller features such as number of inputs, outputs, Timers, etc,  (which will be discussed in more detail in  the next section) which will vary from one manufacturer to the next. 

Below are the different manufacturers of microcontrollers;

Texas Instruments

First on the list has to be Texas Instruments. Their microcontrollers range in 16-bit and 32-bit options, which are high-performance and low in power consumption. They are also available in wired and wireless options. There are a range of software and development tools to help you implement your ideas faster. 

Cypress semiconductor

Cypress semiconductor offers low-power and high performance microcontrollers tailored towards consumer, industrial, and automotive applications. 

Infineon

Infineon is one of the leading companies in the microcontroller scene based in Germany. They create 32-bit microcontrollers which are ideal for connectivity, safety and security.  

Maxim Integrated

Maxim Integrated develops robust 32-bit microcontrollers for Internet Of Things (IOT) applications. Their microcontrollers offer the biggest memories with efficient power management They also integrate high cryptography for high levels of security. 

Microchip

Microchip are at the forefront of the development of microcontrollers which offer a range of options which include 8-Bit, 16-Bit, and 32-Bit. They provide many software libraries and design options making them a first choice for many customers.

NXP

NXP also offers 8-bit, 16-bit, and 32-bit microcontrollers, which combine the technologies of Kinetis and LPC. 

ON semiconductor

Have a range of 8-bit and 16-bit microcontrollers for general and specific applications. Applications like Radio Frequency applications because of their ultra-low power consumptions.  

Panasonic

A well known name for many electronic devices, Panasonic also manufactures microcontrollers. They are used for many different applications as they combine high performance and low power consumption. 

STMicroelectronics

Another dominating name in the industry, STMicroelectronics provides a large portfolio of microcontrollers which are very robust. Features include power, efficiency, security, high performance and scalability. 

Features of a microcontroller

Microcontrollers come in a variety of shapes, sizes, as well as features. 

These features are crucial in choosing the right microcontroller for the right applications.Let’s take a brief look at the different features.

CPU size

We now know that a microcontroller consists of a CPU, memory, and other various peripherals all contained within a single chip. 

The first major feature when looking at a microcontroller is its CPU Size, which refers to the bit-width.

In the early days, you were limited to 4-Bit microcontrollers which meant they had a 4-Bit CPU. But, what does having a 4-Bit CPU mean?

This meant that operations were carried out using 4-bit numbers, variables were stored in 4-bit blocks, and inputs/outputs were accessed via 4-bit data busses. 

Nowadays microcontroller CPU sizes are available in 8-Bit, 16-Bit, 32-Bit and 64-Bit

Clock frequency

If we break down the microcontroller into modules, you would see that it is composed of digital circuits. There are two types of digital circuits; Combinational and Sequential.

The digital circuits inside a microcontroller are Sequential

In order to function properly, these sequential circuits require a Clock

The main job of the clock is to manage the operations between different blocks within the microcontroller such as the CPU, memory, and peripherals (just like a microcontroller has the job of managing the operations of an embedded system). 

The Clock Frequency is the speed at which the microcontroller is able to manage these operations.

Instructions are executed at every ‘tick’ of the microcontroller clock. So, the higher the clock frequency, the faster that instructions can be executed. 

So a microcontroller with a clock frequency of 1MHz is able to complete 1 million instructions per second. 

Common clock frequencies of microcontrollers 1MHz, 8MHz, 16MHz, and 32MHz. 

Memory

Another major building block, Memory is a crucial part to every microcontroller. Memory is used to store data such as program code, and variables. 

There are two two types of data; data that does not change and data that changes during program runtime.

A microcontroller will typically have three different types of memory; SRAM, FLASH and EEPROM to accommodate these two types of data. 

SRAM (static random-access memory) – This type of memory holds data that can be accessed and changed during runtime. SRAM is volatile memory which means that when power is removed, all data stored in SRAM is lost. 

FLASH  – Holds memory that does not change and  is where the program memory is stored. 

EEPROM (Electrically Erasable Programmable Read Only Memory) – EEPROM is similar to SRAM, in that it can be accessed and changed during runtime. However, this type of memory is non-volatile, which means that the data remains even after power is removed. 

GPIO ports

An input device sends information to a microcontroller, whereas information is sent to an output device to control it.

There are a multitude of input and output devices that can be interfaced to a microcontroller;

Inputs such as buttons, switches, sensors, variable resistors, and outputs such as motors, Light Emitting Diodes (LEDs), Liquid Screen Displays (LCDs), etc. 

The microcontroller has General Purpose Input Output (GPIO) ports that these I/O devices are connected to.

GPIO ports of a microcontroller are Bi-Directional which means that they can be programmed to be either an input or output.  

Note, these ports are limited to the amount of current they can sink (as an input) and source (as an output). You will need to consult the microcontroller’s datasheet to check these values. 

Timers

Timing is crucial in all aspects of life.

It governs how long our workdays are, how long we exercise for, flight departures and arrivals, when to eat food, and so much more.

Timing is also crucial when it comes to microcontrollers.

Timers are modules within a microcontroller which are used for setting precise delays, calculating time between events (internal and external), and generating PWM.

They are linked to the system clock we saw earlier. However, with the help of something known as a prescaler, the main clock speed can be scaled down to generate slower speeds.

Most microcontrollers come with a 16-Bit and an 8-Bit timer.

16-Bit timers count up to a digital value of 65535, and 8-Bit timers count up to 255.

16-Bit timers have a greater resolution which gives you more options for the number of delays you can generate.

ADC and DAC

One of the many input devices that are used with microcontrollers are Sensors.

Sensors have the ability to detect changes in the real world and provide an analog voltage at its output (which is sent to the microcontroller).

For example, a temperature sensor detects changes in the ambient temperature and outputs an analog voltage accordingly. 

However, microcontrollers are devices that only deal with digital data. For that reason, it has a module known as an Analog to Digital Converter (ADC).

As the name might suggest, it takes an analog voltage and converts it to a digital value which the microcontroller can use for further processing. 

On the other side, you might want to take a digital value and convert it to a digital value. This can be done with the help of a Digital to Analog Converter (DAC).

PWM outputs 000 

Pulse Width Modulation (PWM) is the process of being able to generate different levels of an output signal.

This is achieved by varying the ratio (which is known as the Duty Cycle) of time that a signal is ‘on’ vs the time that it is ‘off’. PWM signals are square waves. 

PWM has many applications, with the main ones being; motor speed control, and brightness control of Light Emitting Diodes. 

As we saw earlier, the Timers have capability to generate PWM. A microcontroller also has designated PWM output pins where you connect outputs such as motors, and Light Emitting Diodes. 

Serial communication

While the microcontroller is a stand alone device, sooner or later it is going to need to communicate with peripheral devices (Liquid Crystal Displays, Bluetooth modules, accelerometers, etc), as well as other microcontrollers. 

There are two ways of communication; Parallel and Serial.

Parallel communication involves transferring 8-Bits of data at the same time, across eight individual data lines to parallel input/output devices.

This method of communication is faster, however it has notable disadvantages;

  • It requires more wiring which adds to the overall costs
  • Distance is limited due to the number of wires required
  • Susceptible to noise as wires are in close proximity 

Serial communication transfers one bit of data at a time. While this is slower, it solves many of the problems associated with parallel communication mentioned above. 

A microcontroller is limited by the number of pins it has, so serial communication is ideal when it comes to designing a system.

There are two main types of serial communication; Asynchronous and Synchronous.

Asynchronous serial communication is not synced with the main clock (data transfer happens at random time intervals). The Universal Asynchronous Receiver Transmitter (UART) is the most common method that a microcontroller uses for asynchronous serial communication. 

Synchronous serial communication is synched with the main clock (data transfer happens at known time intervals). Inter-Integrated Circuit (I2C) and Serial Peripheral Interface (SPI) are two common protocols that a microcontroller utilises for synchronous serial communication. 

Internal and External interrupts

Interrupts are certain conditions that cause the microcontroller to temporarily jump out of the normal program and execute the code within the interrupt. 

Interrupts can be caused by Internal or External circumstances.

Internal interrupts are when a certain condition is met within the microcontroller modules. For example, if you are using an 8-Bit timer to count to a certain value, there is a certain interrupt called Compare Match specific for the 8-Bit timer that is executed when the timer value ‘matches’ the value you set.

External interrupts are when certain physical events occur outside of the microcontroller at one of its pins (a microcontroller will usually have a couple pins dedicated for external interrupts). These events could be things like a ‘button press’. 

Sleep modes

Last on the list of notable features of a microcontroller are Sleep Modes.

You might be wondering, why the heck does a microcontroller have sleep modes? It’s a machine, it should be able to work overtime all of the time!

However, sleep modes are an essential to microcontrollers. 

The main purpose of them is to conserve energy. 

If you are designing a portable embedded system that runs off disposable or rechargeable batteries, every bit of battery power is going to be crucial to extending the life of the battery. Sleep modes allow you to power down modules of a microcontroller when not needed so they do not consume valuable power. 

Below are some common microcontroller sleep modes;

  • Doze
  • Idle
  • Sleep
  • Low voltage sleep
  • Deep sleep

How do you select the best microcontroller for an application?

So, you saw the many different applications that a microcontroller is used for. But, how do you select the best microcontroller for the job?

There isn’t one specific type of microcontroller that is going to suit all types of application. Every microcontroller will have its own set of pros and cons depending on the application. 

We just saw that microcontrollers come in a variety of features. Some might have more memory than others, some might have faster clock speeds, more ADCs, etc. 

Depending on the needs of the application, a certain microcontroller with a certain set of features might be a better option than another which has a different set. 

For example, if your system needs to do a lot of processing, it will need a bigger CPU and faster clock speeds. 

Or, you might be interfacing a lot of sensors, so your microcontroller will need to have multiple ADC channels.

It all comes down to the design criteria of the application and what features the microcontroller offers to meet those criteria. 

Other alternatives to using a microcontroller for an application

This article covers microcontroller applications. However, a Microprocessor is another device similar to the microcontroller that could be used for many of these applications.

But, what is the difference between a microcontroller and microprocessor? 

The main difference is that a microcontroller is a device that contains the CPU, Memory, Peripherals, all on one chip. 

Whereas, a microprocessor chip only contains the CPU. The memory, and peripherals come on separate chips that have to be interfaced with the microprocessor. 

Each has their own advantages and disadvantages which will make them appropriate for a certain application. 

Microcontrollers cost less, and consume less power, while  Microprocessors have faster processing speeds. 

Do you always need a microcontroller for an electronic application?

Again, this question comes down to the needs of the application.

Microcontrollers are used for applications where complex and complicated tasks need to be done. 

However, an application or project might require a task as simple as blinking an LED. In this instance using a microcontroller would be overkill.

You could just use a 555 Timer IC to blink an LED. 

It would be analogous to using a saw to cut a piece of paper (where scissors would do the job just fine).

So, before using a microcontroller for a project, see whether its features and abilities are really needed and  whether there is another easier way of achieving that particular task.

The post Application of a microcontroller - 10 most common appeared first on Electronic Guidebook.

]]>
1025
Do I need a multimeter for an Arduino? https://electronicguidebook.com/do-i-need-a-multimeter-for-an-arduino/?utm_source=rss&utm_medium=rss&utm_campaign=do-i-need-a-multimeter-for-an-arduino Wed, 13 Jan 2021 05:17:38 +0000 https://electronicguidebook.com/?p=620 Arduino boards are a great way to get started if you are a beginner.  They are development boards that include a microcontroller, power supply, inputs, outputs, Serial communication and much more. You might have just purchased an Arduino, or are thinking about buying one to get stuck into the world of microcontrollers, electronics and programming.  […]

The post Do I need a multimeter for an Arduino? appeared first on Electronic Guidebook.

]]>
Arduino boards are a great way to get started if you are a beginner. 

They are development boards that include a microcontroller, power supply, inputs, outputs, Serial communication and much more.

You might have just purchased an Arduino, or are thinking about buying one to get stuck into the world of microcontrollers, electronics and programming. 

But, you might also be wondering whether you need a multimeter for an Arduino? While it is not necessary to have a multimeter when you start out with an Arduino, it is recommended that you do have one. Multimeters are great for troubleshooting problems that you might come across with your Arduino projects.

Also, Arduino development boards are not perfect. They are going to have some onboard problems sooner or later. 

Again, a multimeter is your best option at identifying the problem. 

What is an Arduino

Let’s take a deeper look at the Arduino. 

This will help you understand why you might require a multimeter. 

Below is one for the most common Arduino development boards; Arduino Uno.

As you can see the Arduino Uno has many components and parts that make up the development board which include;

  • Power Input (barrel jack)
  • 3.3V power input pin
  • 5V power output pin
  • Analog Input pins
  • Digital Input/Output pins
  • Reset Switch
  • Microcontroller 
  • USB port 

It is great for the beginner as you do not need to set up a microcontroller on a breadboard with a power supply and capacitors or resistors. 

It’s already all done for you on the development board. 

Inputs and outputs like LED’s, sensors, motors, displays can be connected to the digital pins as required. 

The Arduino can also be programmed using the USB port. It does not require complicated interfacing with a computer. 

What are the main uses of a multimeter

The multimeter is an electronic measuring instrument used on a daily basis by Electricians, Engineers, Hobbyists, DIYers and many others.

It has many functionalities but the main three are measuring Voltage, Current, and Resistance.

The most basic of multimeters should include these three measurements.

More complex multimeters can have more than just these three measurements which can include;

  • AC (alternating current) voltage and amperage
  • DC (direct current) voltage and amperage
  • Resistance (ohms)
  • Capacity (farads)
  • Conductance (siemens)
  • Decibels
  • Duty cycle 
  • Frequency (Hz)
  • Inductance (henrys)
  • Temperature Celsius or Fahrenheit 

Multimeters come in Analog and Digital versions, but analog multimeters are less common today due to their inaccuracy. 

The main use of a multimeter is to be able to diagnose and troubleshoot electrical and electronic circuitry. 

Finding faults and rectifying them is where the multimeter will be your best friend. 

Reasons why you might need a multimeter for an Arduino

When starting out on your journey with an Arduino, the projects you will be undertaking will be simple and troubleshooting will not necessarily require a multimeter. 

However, as you advance and the Arduino projects you embark on get more complex, you will no doubt require a multimeter to aid you in finding inevitable problems. 

We now know that a basic multimeter can measure the three basic electrical values which are voltage, current, and resistance. 

So let’s look at some reasons why you might want to invest in a multimeter to help with your Arduino.

Reason #1 why you might need a multimeter for Arduino: Testing Digital and Analog Pins

Ardnuinos come with a varying number of digital pins that can be used either as inputs or as outputs. 

Where inputs can include;

  • Buttons
  • Switches
  • Sensors

And outputs can include;

  • Motors
  • Light Emitting Diodes (LED’s)
  • Displays

Smaller components that require less current and voltage, can be powered by the 5 volts outputted at the digital pins.

However, if for some reason the digital pin does not seem to be powering whatever you have connected, you can use the voltage function of the multimeter to check what voltages are present at the digital pins.

Also, an Arduino will have designated analog pins where sensors can be connected to. 

A sensor will output voltages in analog form. 

However, arduinos only deal with digital data. 

The analog pins have the ability to convert the analog data to a digital form. 

Sometimes, the wrong digital values will be generated by software. 

You can see where the problem is by double checking the voltage at the analog pins and cross checking them with the digital values. 

Reason #2 why you might need a multimeter for Arduino: Testing Voltages

Initially your circuits will be confined to onboard the Arduino itself. 

But, sooner or later your projects will extend to outside of the Arduino, and onto something like a breadboard.

The more wiring and connections that are required, the more chances of error. These errors tend to show themselves as wrong voltages. 

Therefore fault finding when something is not working without a multimeter is going to be very very hard, and annoying.

Using a multimeter, the circuit schematic and a little electronic knowledge you should be able to find solutions to your problem in no time.

Reason #3 why you might need a multimeter for Arduino: Current consumption

If the next project you are undertaking requires a means of mobile power (like a battery), the circuit will need to be as efficient as possible to extend the life of the batteries. 

If you don’t know how much Current the system you are designing is consuming how will you know whether it is efficient or not?

Utilising the ability of the multimeter to measure current, you will be able to deduct if any improvements need to be made. 

Reason #4 why you might need a multimeter for Arduino: Resistance and Continuity

No matter whether you are a beginner or an expert, you are going to encounter a resistor or two, or a hundred.

These little buggers have many uses in an electronic circuit and come in a variety of shapes, sizes and resistance values. 

Even though resistors have colour bands on them which indicates what resistance value they are, it can get quite annoying trying to squint and constantly check the colours.

A workaround to this problem is using a multimeter (no surprises there)!

You will easily be able to tell what the resistance is of a resistor in any part of the circuit. 

Also, multimeter’s have another neat function which allows you to test Continuity.

This test allows you to see if two points of a conducting material are connected and therefore ‘continuous’ allowing the flow of current.

This is great for wires with insulation, or testing parts of a circuit that should be connected together. 

Can you get away with not having a multimeter initially?

When you initially start out with the Arduino, your projects are not going to be very complex. 

This might include projects such as reading button presses, blinking an LED, reading sensor values etc. 

The circuits involved with these are not too intense and only require a few connections. 

Saying this, you will still encounter problems. However, finding the cause of the problem and then the solution will be a bit easier. 

So, when starting out you do not need a multimeter.

But, it does not hurt to have one as part of your troubleshooting arsenal. 

Do you need an expensive multimeter for an Arduino?

No, you do not require an expensive multimeter.

When you are working with an Arduino, there are only a few measurements you want your multimeter to be capable of measuring; Voltage, Current, Resistance and Continuity. 

You can get multimeters that won’t break the bank which are still capable of performing these measurements so you can troubleshoot your Arduino and additional circuitry. 

The one thing you need to be aware of when selecting a multimeter is the ranges of voltages, and currents it can handle. 

It should be able to handle the voltage and currents of the Arduino and other circuitry. 

Final thoughts

So, you can see there are many reasons why you would want to invest in a multimeter when using an arduino.

It is a great tool for diagnosing and troubleshooting problems which are inevitable.

While you might not need a multimeter initially when starting out with an Arduino, it will prove useful as you progress in skill level and your projects get a bit more complex.

However, you do not need an expensive multimeter. A decent cheap one with the three basic measurement capabilities (voltage,current and resistance) should be just fine.

The post Do I need a multimeter for an Arduino? appeared first on Electronic Guidebook.

]]>
620
11 advantages of an AVR microcontroller https://electronicguidebook.com/11-advantages-of-an-avr-microcontroller/?utm_source=rss&utm_medium=rss&utm_campaign=11-advantages-of-an-avr-microcontroller Sat, 05 Dec 2020 00:31:50 +0000 https://electronicguidebook.com/?p=572 You might already know about AVR microcontrollers, or you might have just stumbled upon them. If you are wanting to make the switch to an AVR microcontroller but are not convinced yet of what the big deal about is with them, below are some of the many advantages of an AVR microcontroller Price Easy to […]

The post 11 advantages of an AVR microcontroller appeared first on Electronic Guidebook.

]]>
You might already know about AVR microcontrollers, or you might have just stumbled upon them.

If you are wanting to make the switch to an AVR microcontroller but are not convinced yet of what the big deal about is with them, below are some of the many advantages of an AVR microcontroller

  • Price
  • Easy to use
  • Readily Available
  • Community (Tutorials, resources, forums etc)
  • Fast
  • Different types of boards depending on your needs
  • Many different Peripherals
  • Easy to program
  • Extensive detailed datasheets
  • Easy to set up
  • Onboard memory 

I will give a more detailed explanation of each advantage further in this article.

 While there are many more advantages, these are the most notable ones. 

What is an AVR microcontroller 

Let’s take a brief look at the AVR microcontroller.

The AVR microcontroller was first developed in the late 90’s by a company known as Atmel. However, in 2016 they were acquired by Microchip

They were the first set of microcontrollers to use on chip flash memory for program memory. 

AVR microcontrollers are most commonly used for embedded applications, and have been popularised by the Arduino Development Boards,(most predominantly the AT Mega 8).

They are the go to microcontroller for beginners to experts, being used in DIY and Industrial applications.

The AVR family is comprised with a series of microcontrollers listed below;

  • tinyAVR
  • megaAVR
  • XMEGA

Of the many options, these three are the most popular of the series of AVR micrcontrollers used. 

11 advantages of an AVR microcontroller

Ok, let’s take a look at the many advantages of AVR microcontrollers. Whether you have never used them before or you are just curious to know, it will benefit you to know the advantages. 

Advantage #1 of an AVR microcontroller: Price

No matter what you are buying, you want the best price to quality ratio (or as I like to call it, the Golden ratio)

What I mean by this is that you don’t want to spend a lot of money on something which isn’t of great quality. 

Also, it would be nice to pay the least amount of money for something of great quality. 

In life you might seldom stumble upon gems which meet the Golden Ratio. Things that don’t break the bank but still provide great value for a long time. 

The AVR microcontroller is one of those gems that has the perfect cost to quality ratio. It is decently priced while still delivering on functionality. 

Advantage #2 of an AVR microcontroller: Easy to use

I will approach this advantage from two vantage points. 

One as a beginner, and the second as the expert.

For the beginner who is just starting to get into the world of microcontrollers, you want a microcontroller that is easy to use. The last thing you want is to spend years learning how to use it.

From the eyes of the expert (say an engineer), who is prototyping a project that involves a microcontroller. 

However, this engineer only has a little knowledge using microcontrollers, he or she will want to be able to use a microcontroller with a little small learning curve as they do want to spend all their time learning how to use the microcontroller, but rather get stuck into finishing their project.

The AVR microcontroller is perfect for both parties as it is easy to use. It has a small learning curve allowing you to get stuck right into the fun stuff.   

Advantage #3 of an AVR microcontroller: Availability

The third advantage of the AVR microcontroller is Availability.

So we know the AVR microcontroller is reasonably priced and easy to use, but imagine if it was impossible to get your hands on, that would be utterly pointless.

In this day and age we are lucky to live with the Internet where you can buy things online with a click of a button. 

However, even then it can be hard  getting certain products, especially if you live in far away countries.

I live in New Zealand! The far corner of the world! 

Trust me trying to get some items shipped to New Zealand can be near damn impossible. 

Fortunately for me, the AVR microcontroller is not one of those items! 

I have access to it online as well as physical stores not too far from where I live. 

Advantage #4 of an AVR microcontroller: Community

No matter what hobby we might start, we all start as amateurs. 

Back in the earlier days of microcontrollers when the internet was at its infancy, the path to learning how to use microcontrollers would have been a bit harder.

You would either have to go to university to learn how to use them, read thick books about microcontrollers, or spend many hours using trial and error. 

If you are starting out learning how to use AVR micrcontrollers now, you have hit the jackpot!

The AVR microcontroller community that has grown online to this date is massive. There are people with years of experience who are willing to help you with any problem you might be having.

Also, there are a plethora of resources available ranging from video tutorials, projects, example codes, theory and many more to help you get started.

So, if you ever get stuck, look to the AVR community who are there to help you solve any problem. 

Advantage #5 of an AVR microcontroller: Range of Speeds

Now we come to the technical advantages of an AVR microcontroller. 

The first of them being speed.

Every microcontroller has a clock which is needed for timing control. The rate at which instructions are carried out is determined by the speed of the clock.

The higher the speed the faster that instructions are carried out and vice versa. 

The initial assumption is that the faster the clock speed the better. But, it all depends on the application’s needs. 

For example, if you have a weather station, where data is only processed every 24 hours, you do not need high clock speeds.

So it is all application dependent.  

The great thing about AVR microcontrollers is that they come in a range of clock speeds

Advantage #6 of an AVR microcontroller: Range of Microcontroller options

As I mentioned earlier, there are many different groups of microcontrollers within the AVR family. 

You are not restricted to one specific AVR microcontroller of one specific size, set of peripherals, speed, number of input/outputs etc.

AVR micrcontrollers come in a range of options that vary in size and functionality. 

Also, depending on the specifications of your project/application, each microcontroller comes with a unique set of peripherals.

Your project might only involve blinking an Light Emitting Diode (LED). In this instance you do not require a 40 pin microcontroller of high speeds to perform the job. 

That would be overkill!

Lucky for us, there are many AVR microcontrollers to choose from. 

Advantage #7 of an AVR microcontroller: Broad set of peripherals

One of the main purposes of a microcontroller is to be able to interact with the physical world.

Whether you are receiving sensor information, controlling the speed of a motor, reading button presses, displaying information on an LCD and much more. 

Peripherals are parts of the microcontroller that interfaces with the world outside of the microcontroller and help you perform functions mentioned above.  

Below is a set of common AVR microcontroller peripherals.

  • GPIO (General Purpose Input/Outputs)
  • ADC (Analog to Digital Converter)
  • DAC (Digital to Analog Converter)
  • Serial Communication
    • I2C (Two wire interface)
    • SPI (Serial Peripheral Interface)
    • USART (Universal Serial Asynchronous Receiver Transmitter)
  • Timers
  • PWM (Pulse Width Modulation) 

AVR microcontrollers have a broad set of peripherals to choose from. 

Advantage #8 of an AVR microcontroller: Easy to program

Programming a microcontroller involves a number of steps which include;

  • Writing the code in an IDE (Integrated Development software)
  • Compiling the code to a file which gets burned onto the microcontroller (typically a .HEX file)
  • Then finally sending that file to the microcontroller using an AVR programmer and an IDE capable of programming the microcontroller. 

Sometimes the process of writing code, compiling it, and then burning it onto a microcontroller can be more complicated than it should be.

However, AVR has made it easy for you, me and everyone else to write a program and then program the microcontroller. 

It has its own dedicated IDE (Atmel Studio), where you can write, debug and program your microcontroller. 

AVR also has its own programmer which does not require an engineering degree to set it up. 

Advantage #9 of an AVR microcontroller: Little needed for microcontroller setup

While we are on the topic of setting up, you might be wondering what it takes to set an AVR microcontroller.

Not much is the answer.

The last thing you want to spend your time on is setting up the microcontroller. You want to be able to get to the fun stuff as soon as possible.

Setting up a microcontroller only requires a breadboard, a couple of capacitors, hookup wire, and a supply voltage (which can be a couple of AA batteries).

Note, this setup is only applicable for temporary purposes. If you need a more permanent setup you will require a printed circuit board and will have to solder.

Advantage #10 of an AVR microcontroller: Onboard memory

Memory is a very important aspect of any microcontroller. 

It’s the place where you store the program code, as well as temporary and permanent variables. 

Some microcontrollers do not have on board memory, which means they come as separate modules that you have to interface with. 

This is a waste of time and money. 

So, having onboard memory is a great advantage as you do not have to go through the whole process of setting up external memory. 

Advantage #11 of an AVR microcontroller: Extensive Datasheets

The last and final advantage of an AVR microcontroller is it’s datasheet. 

Most (if not all) electronic devices and components come with some sort of datasheet, or manual that has instructions on how to use it.

But, who enjoys reading manuals! 

In this instance it is important as it not only has information on how to use it, but also what are the ideal practices when using a microcontroller to ensure a long lifespan.

AVR microcontroller datasheets are very detailed containing everything you need when starting out, or when you get stuck. 

So, before seeking the help of the AVR community, check the AVR microcontroller datasheet first.

Different types of AVR microcontrollers

There are three major subsets of families when it comes to AVR microcontrollers;

  • tinyAVR
  • megaAVR
  • XMEGA

Within each family group are many more versions of microcontrollers.

For example, the tinyAVR family has microcontrollers that include the AT Tiny 25, AT Tiny 45, AT Tiny 85, just to name a few. 

Each family of these families of AVR range in size, memory, peripheral set etc. 

So, depending on your needs, there is an AVR microcontroller to solve your problems. 

Which is the best AVR microcontroller

You now know that there are many different AVR microcontrollers available that can meet many of your needs. 

But, with most things there are the ones that stand out amongst the rest. 

AVR has a few microcontrollers that are better than their peers (this is according to my own experience as well as research done online).

These include:

  • AT TINY 25
  • AT MEGA 8
  • AT MEGA 32

For a more detailed explanation on why I chose these three microcontrollers click here.

The post 11 advantages of an AVR microcontroller appeared first on Electronic Guidebook.

]]>
572
3 best AVR microcontrollers https://electronicguidebook.com/3-best-avr-microcontrollers/?utm_source=rss&utm_medium=rss&utm_campaign=3-best-avr-microcontrollers Sat, 21 Nov 2020 01:19:24 +0000 https://electronicguidebook.com/?p=561 Whether you are buying a new car, or a new house, trying to find the best one that meets your needs can be a daunting task. Trying to find the best AVR microcontroller is no different.  But, every AVR microcontroller has its own advantages in different applications, so there isn’t one that is the best […]

The post 3 best AVR microcontrollers appeared first on Electronic Guidebook.

]]>
Whether you are buying a new car, or a new house, trying to find the best one that meets your needs can be a daunting task.

Trying to find the best AVR microcontroller is no different. 

But, every AVR microcontroller has its own advantages in different applications, so there isn’t one that is the best compared to the others. 

However, there are a handful of AVR microcontrollers that stand out amongst the rest. 

They have been chosen as the ‘best’ because they meet many factors that make them stand out above the rest. Factors like price, ease of use, amount of memory, availability etc.

The three best AVR microcontrollers are:

  • AT TINY 25
  • AT MEGA 8
  • AT MEGA 32

While there are plenty of AVR microcontrollers, these three give you the most bang for your buck. 

If you want to know why these three microcontrollers have made the cut and got the title of ‘Best AVR microcontroller’ read on for more explanation.

What is an AVR microcontroller

Like there are many manufacturers of cars, in the world of microcontrollers, you have a range of microcontroller manufacturers to choose from as well. 

The major players in the field of microcontrollers include:

  • Microchip
  • Atmel
  • NXP
  • Texas instruments
  • STMicroelectronics

The AVR microcontroller is a family of microcontrollers developed by ATMEL who started manufacturing them in 1996.

However, Atmel has since been acquired by Microchip in 2016. But, the AVR family of microcontrollers are still being manufactured by Microchip.

They are built on a modified Havard architecture. It is modified in the sense that the conventional Harvard architecture doesn’t allow the contents of the instruction memory to be accessed as data. 

AVR microcontrollers were one of the first to utilise on-chip flash memory for program storage. 

Due to their ease of use, and price they are commonly used by many hobbyists and makers. They are also used for educational embedded purposes. 

What features does an AVR microcontroller have

Going back to my analogy of buying a car, knowing the features of the car will give you an indication of which car is best for you.

Features like power steering, cruise control, rear or front wheel drive, bluetooth audio system, cup holders etc.

The same holds true for features of AVR microcontrollers. Knowing what the different features are available will help you choose the best one to meet your needs. 

Below are some of the many features available for AVR microcontrollers which are beneficial in many different ways.

Note, if you already know the features of AVR microcontrollers and are only concerned with which is the best, you can skip this section. 

Memory

Imagine not remembering what you did yesterday, or the date of your partner and your wedding anniversary (this is not going to make them happy).. 

Our memory serves us in more ways than one. From remembering what we have learnt, to important dates, peoples names, where we kept the house keys etc.

The memory of an AVR microcontroller serves it in more ways than one as well.

It helps it remember (store) things like variables, program code, sensor data etc.

An AVR microcontroller has three types of memory; FLASH, RAM, and EEPROM.

FLASH – This type of memory is known as ‘non-volatile’. What this means is that what data is stored in this section of memory is not lost when power is removed from the microcontroller. Therefore, this type of memory is used for storing program code (set of instructions) written by the programmer.

RAM (Random Access Memory) – Memory in RAM is ‘volatile’. Unlike FLASH memory, when power is removed from the microcontroller, data stored in RAM is lost. This type of memory is used to store variables that are generated during program runtime. 

EEPROM (Electrically Erasable Programmable Read Only Memory) – This type of memory is ‘non-volatile’. However, reading and writing to the EEPROM is much slower compared to FLASH memory. Things that are more permanent, like sensor data, and device parameters are stored in EEPROM where they can be accessed later. 

General Purpose Input / Output (GPIO) pins

The main premise of a microcontroller is to be able to interface with inputs and outputs external to it while having the ability to control them. 

There are a huge range of input/outputs that are available which include things like, motors, buttons, Light Emitting Diodes, Sensors to name a few.

The AVR microcontroller has a set of GPIO pins that allow you to connect these input/outputs and control them.

The number of input/output pins largely depends on the physical size of the microcontroller.

The great thing is that any single pin has the ability to be either an input, or an output which can be changed during runtime by the user. 

Analog to Digital Converter (ADC)

The GPIO pins control outputs or receive digital input values that are either HIGH (+5V) or LOW (0V). 

Some inputs like sensors, provide an analog value at the input which range in value from 0 – 5V. 

For example, a temperature sensor might output a voltage at 2.42 volts.

But, a microcontroller is a digital device that deals with digital values.So, how does it interpret these analog values?

Lucky for us, an AVR microcontroller has something known as the Analog to Digital converter. 

As the name suggests, it takes these analog voltage values from the sensor and converts it to a digital value which the microcontroller can then interpret. 

Timers

Another important aspect of an AVR microcontroller are its Timers. 

It is a clock that has the main purpose of measuring time intervals. However, it can either be used as a Timer or a Counter. 

When it functions as a Timer, you can think of it as a stopwatch which is used to measure time intervals between two specific events. 

When used as a Counter, the Timer can store how many times a certain event occurs (mostly events external to the microcontroller).

The Timer can also be used to generate delays and PWM signals.

Pulse Width Modulation 

Imagine driving a car that only had one speed without the ability to slow down or speed up. 

This would be quite frustrating and pointless!

Pulse Width Modulation (PWM), is a way that lets you control the speed of a motor by varying the power that the motor receives using PWM.

Your next project might be something like a remote control car, or fan which requires speed control.

AVR microcontrollers have PWM channels on designated pins which you can connect a motor to (in conjunction with a motor controller) and vary its speed. 

PWM can also be used to control the brightness of Lights such as Light Emitting Diodes by again varying the power that the light receives. 

Interrupts

AVR microcontrollers are fast devices that are capable of fast execution speeds. 

But, even they get overwhelmed with tasks! (this is all relative of course).

Due to this, AVR microcontrollers have a feature known as Interrupts

An interrupt allows the microcontroller to carry on with its normal program tasks, but alerts the microcontroller when certain events/statements occur.

These events can be generated internally (via software) or externally (through special designated External Interrupt pins). 

An example of an internal interrupt could be a Timer reaching its maximum value which would trigger a routine specific to that event. 

External interrupts routines are generated externally at the microcontroller’s pin when it goes High, Low, or has any change in logic state. 

For example, a button could be connected to one of these designated pins and when pressed (either causing state levels to go High or Low) trigger an external interrupt service routine. 

Sleep Modes

Many embedded microcontroller applications are remote/mobile and require the use of battery power. 

This causes many problems, with the main one being battery power is limited. So, the main issue is to be able to design a system that can last as long as possible avoiding always having to replace batteries.

AVR microcontrollers have Sleep Modes, which give them the ability to enter a state where they consume less power, but can still perform their main operations.

It can have up to five sleep modes!

Idle mode – In this mode, the CPU is halted and stops functioning. However, peripherals such as Serial Interface, Timer/Counter, Watchdog and Interrupts, continue to operate as normal.

ADC Noise reduction Mode – Stops the function of the CPU, but ADC, external interrupts, Timers and watchdog continue to operate.

Power Down mode – External Interrupts, watchdog and two-wire interface are the only things that function power down mode. 

Power Save mode – This mode is used when the Timers are set up to run asynchronously. 

Stand by mode – The oscillator is allowed to run while all other operations are stopped.

Serial Interface

The last major feature of AVR micrcontrollers is the Serial interface.

Humans communicate with each for many different reasons. Whether it be about new ideas we have, how we are feeling, instructions that need to be taught, passing on knowledge and so on.

Animals, from all areas of life communicate as well. 

We can communicate a number of different ways which include verbal or non-verbal. 

But, communication is not just limited to just humans and animals. AVR microcontrollers have the ability to communicate with other microcontrollers, and peripheral devices too. 

Data can be sent or received.

There are three common communication protocols used by AVR protocols; Serial Peripheral Interface (SPI), Two wire interface (TWI) and Universal Synchronous and Asynchronous Receiver Transmitter (USART).

Choosing the best AVR microcontroller depends on your needs

You might be wondering why I listed all the different features of an AVR microcontroller. 

The thing is that AVR microcontrollers come in a range of sizes, and specifications. So, choosing the best AVR microcontroller comes down to your needs/ wants, as well the needs of the application you will be using if for. 

Types of AVR microcontrollers

Let’s take a closer look at the AVR family of microcontrollers.

The  three most common sets of the AVR family include the tinyAVR, and megaAVR.

Below is a table highlighting things like program memory, peripherals, and number of pins for the three families. 

tinyAVRmegaAVR
Program Memory0.5 – 32 (KB)4 – 256 (KB)
Pin package6 – 3228 – 100
Peripheral setLimited peripheral setExtensive peripheral set

Within each of these three sets of AVR microcontrollers exist even more variations. 

 For a list of tinyAVR microcontrollers click here.

For a list of megaAVR microcontrollers click here.

7 Factors that determine which is the best AVR microcontroller 00 

Now that we know the two main types of AVR families, as well as the different types of features that they can have, let’s take a look at factors that determine which is the best (remembering to take into account the application the AVR microcontroller will be used in).

Factor #1: Memory

The first factor we will take a look at when considering which is the best AVR microcontroller is Memory. 

The main thing we are concerned with is how much memory the microcontroller has. 

If you are writing a program that just blinks an LED every 2 seconds you are not going to require much memory. However, if you are writing a program that collects and stores temperature data, you will no doubt require more memory.

So, before buying a microcontroller always consider how much memory you will require. 

Factor # 2: Price

The next factor that should be considered is the Price.

We shop for things everyday, whether it be new clothes, airline tickets for travel, food, etc. 

When paying for something we look for the ‘best’ option that will not drain our bank account. So, there is a sweet spot where what you buy is good quality while still being affordable.

This applies for AVR microcontrollers as well.

It should be affordable enough while still having all the features and functionalities you require. 

Factor #3: Ease of use

You might be a beginner who just wants to start your first project, or you might be an experienced engineer who is doing some prototyping on a new product and needs to meet his/her deadline. 

Either way, you do not want to spend all your time setting up, or learning how to use the AVR microcontroller. 

So, you want a microcontroller that is easy to use and understand while still being functional. 

Factor #4: Community

In life, we rarely do things by ourselves. 

People assume many  breakthroughs in science, engineering, medicine, were found by one single person. 

The truth is, that the person who eventually found the breakthrough relied on past studies, experiments, and knowledge of other great people. 

I have learned so much about microcontrollers from the community of engineers, makers, DIYers that exist online and offline.  

The great thing about the age we live in is, the Internet and all the resources available at our fingertips. 

There are many communities whose knowledge and past experiences you can learn from and help inspire you for your next great AVR microcontroller project. 

So, having resources and a community for the microcontroller you are using is really helpful.

Factor #5: Peripherals

This factor really depends on what your project/application requires. 

If you are controlling the speed of a motor you will require PWM channels.

Do you need to interface with the real world via sensors? Then you are going to need ADC inputs. 

Have to measure time between events? Then you will require Timers. 

You get the point.

How many PWM channels, ADC inputs, Timers, GPIO pins etc will determine whether you get a bigger or smaller AVR microcontroller. 

Factor #6: Clock Speed

The speed of the internal clock determines how fast the AVR microcontroller executes instructions.

Again, this comes down to the needs of your project. 

Clock speed aspect should never be overlooked when trying to find a suitable AVR microcontroller for your application.

Factor #7: Availability 

Finally on the list of factors that determine the best AVR microcontroller is Availability. 

The AVR microcontroller should be readily available in the place where you are living, or be able to be ordered online and shipped to your residence without you having to sell your left arm.

What’s the use of knowing the best AVR microcontroller if you cannot get your hands on it. 

3 best AVR microcontrollers 

There isn’t a one size fits all kind of AVR microcontroller for every application, however, there are a handful of AVR microcontrollers that stand out amongst the rest. 

The AVR microcontrollers that I have chosen below are due to the fact that they meet many (if not all) of the 7 factors that determine which is the best. 

This list of the best AVR micrcontrollers is compiled based on my experiences with them, as well as research I have done online which is again based on the 7 factors. 

Let’s take a look at the 3 best AVR microcontrollers.

AT TINY 25

First on the list is the AT Tiny 25 which comes from the tinyAVR family set of AVR micrcontrollers.

Of the three microcontrollers, this is the smallest coming in a 8 DIP (Dual inline package, 8 pins in total).

But, do not be fooled by its size!

This little microcontroller is very powerful and capable of meeting many of your needs. 

Below is a table summarizing some of its features

AT TINY 25
Flash Memory2K
EEPROM 128 bytes
RAM 128 bytes
TimersTwo 8-bit timers
PWM2 channels
ADC Four 10-bit ADC inputs
Serial CommunicationSPI, TWI, USART
GPIO6
Clock SpeedMax: 20 MHz | Min: 10 MHz
Sleep modes2

The AT TINY 25 is great if you do not require a big microcontroller, but still need it to have the ability to perform many of the functions of larger microcontrollers. 

AT MEGA 8

Next on the list is the AT Mega 8, which comes from the megaAVR family of AVR micrcontrollers. 

This microcontroller is bigger than the AT Tiny 25 microcontroller, and comes in a 28 DIP package. 

The AT Mega 8 is a popular microcontroller in the Arduino world being used a lot with many of their boards. 

Below is a table highlighting many of its features.  

AT MEGA 8
Flash Memory8K
EEPROM 512 bytes
RAM 1K bytes
TimersTwo 8-bit timers + One 16-bit timer
PWM3 channels
ADC Six 10-bit ADC inputs
Serial CommunicationSPI, TWI, USART
GPIO23
Clock Speed16MHz
Sleep modes3

AT MEGA 32

Finally, to top off the list is the AT Mega 32 which comes from the megaAVR family as well.

The AT Mega 32 is a slightly bigger board compared to the AT Mega 8 coming with 40 pins.

It is like the AT Mega 8’s bigger brother that has more memory, PWM outputs, ADC channels etc.

Below is the table summarizing the AT Mega 32’s features. 

AT MEGA 32
Flash Memory32K
EEPROM 1024 bytes
RAM 2K bytes
TimersTwo 8-bit timers + One 16-bit timer
PWM4 channels
ADC Eight 10-bit ADC inputs
Serial CommunicationSPI, TWI, USART
GPIO32
Clock Speed16MHz
Sleep modes3

There you have it, the top 3 AVR microcontrollers! 

However, I should note again, that these AVR microcontrollers have been selected from my personal experience using them, as well as research done online as they meet many if not all the factors that contribute to a microcontroller being the best. 

The AT Tiny 25, AT Mega 8, and AT Mega 32 are AVR microcontrollers that are reasonably priced, easy to use, have a great community/resources, packed with many features and memory.

The post 3 best AVR microcontrollers appeared first on Electronic Guidebook.

]]>
561
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 is the 8051 called an 8-bit microcontroller? https://electronicguidebook.com/why-is-the-8051-called-an-8-bit-microcontroller/?utm_source=rss&utm_medium=rss&utm_campaign=why-is-the-8051-called-an-8-bit-microcontroller Tue, 21 Jul 2020 23:35:55 +0000 https://electronicguidebook.com/?p=327 You might have been using the 8051 microcontroller for a long time now, or you might be new to it. These microcontrollers are versatile integrated circuits with many capabilities. But, why is the 8051 called an 8-bit microcontroller? The 8051 is called an 8-bit microcontroller because it processes 8 bits of data every machine cycle. […]

The post Why is the 8051 called an 8-bit microcontroller? appeared first on Electronic Guidebook.

]]>
You might have been using the 8051 microcontroller for a long time now, or you might be new to it. These microcontrollers are versatile integrated circuits with many capabilities.

But, why is the 8051 called an 8-bit microcontroller? The 8051 is called an 8-bit microcontroller because it processes 8 bits of data every machine cycle. All assembly instructions happen 8-bits at a time. Also, all internal registers are 8-bit in size and all read and write operations happen 8-bits at a time. 

What does 8-bit mean? 

Understanding the basics of what 8-bit means, will give you a better understanding of the question of why the 8051 is called an 8-bit microcontroller.

Before the digital age, all electronics were analog. It dealt with a continuous range of voltages. 

In the world of microcontrollers, all data, memory, program code is digital (0’s and 1’s).

A single bit is either a 0 or 1. 

A collection of eight 0’s and/or 1’s is known as 8-bits (or a byte).

A deeper look at why the 8051 is called an 8-bit microcontroller

A 8051 microcontroller has registers, address buses and data buses.

A register is one of the main components of a microcontroller whose  primary use is to store data. 

Registers have read/ write operations which means that you can either just read the contents of the register, or write new data to it.

To move information to these registers, microcontrollers require data or address buses. They provide a means of moving information from one place to another. 

Think of them as highways. 

As we saw above, all data is either a 0 or 1. 

The registers in an 8051 microcontroller store data that is 8-bits in length. 

Also, the address and data buses move data that is 8-bits in length which is the main reason why the 8051 is called an 8-bit microcontroller.

Different types of 8-bit registers in the 8051 

The 8051 has different types of 8-bit registers, each used for certain applications.

The registers are General Purpose and Special Function. It has a total of 256 bytes of RAM in total of which 128 bytes are used for the General Purpose Registers, and 128 bytes for the Special Function Register.

Were the earlier versions of the 8051 microcontroller 8-bit?

Intel Corporation are the developers of the 8051 microcontroller. 

However, they weren’t the first microcontrollers they developed. 

The first microcontrollers developed by Intel was the 4004. A 4-bit microcontroller. 

This meant that it had registers, data buses and address busses that were 4-bit in size.

Therefore it was considered a 4-bit microcontroller.

Are the 8051 microcontroller peripherals 8-bit?

Peripherals are certain parts of a microcontroller that have specific functionalities that help a microcontroller achieve a certain task.

Microcontroller peripherals include things like Timers, Analog to Digital Converters, Pulse Width Modulation, General Purpose Input/Outputs and Serial Communication. 

A 8051 microcontroller has two dedicated 16-bit timers, Serial communication (UART) and General Purpose Input/Outputs.

But, isn’t the 8051 microcontroller 8-bit? How can it have 16-bit timers?

Yes it still is an 8-bit microcontroller, the timer values are just stored in two 8-bit registers, and their total value of the timer is a combination of these two registers. 

The lower byte is stored in register ‘TL’, and the higher byte is stored in register ‘TH’.

Are all 8051 microcontrollers 8-bit?

The 8051 microcontroller has  different versions available that vary in things like ROM, RAM, number of timers, and interrupt sources. 

The two versions are the 8052, and the 8031. 

Below is a table of their comparisons:

Feature805180528031
ROM(bytes)4K8K0K
RAM(bytes)128256128
Timers232
I/O pins323232
Serial port111
Interrupt sources686

Both these versions, just like the 8051, are 8-bit microcontrollers.

At this moment in time, all three versions of the microcontroller are only available as 8-bit microcontrollers. 

How do you know if a microcontroller is 8-bit?

Many if not most electronic devices come with a user manual.

This user manual helps us learn how to use the device. It tells us what each button does, and what functions the device has. 

Lucky enough for you and me, manufacturers of microcontrollers have written up a user manual for each device.

This user manual is commonly known as a datasheet.

It lets us know all the features of a microcontroller, what each pin does, how to use it etc.

The datasheet also contains information of whether a microcontroller is an 8-bit, 16-bit or 32-bit microcontroller. 

So, if you need to find information about your microcontroller, just consult its datasheet which is available online. 

Is the 8-bit 8051 microcontroller a good for you?

Microcontrollers have come a long way from their humble 4-bit days.

You now have the option of 8-bit, 16-bit and 32-bit microcontrollers.

The choice of which of these microcontrollers to choose all comes down to the needs of your application. If you require higher computation power, the 32-bit microcontroller is your best option. 

However, if lower power consumption is a necessity, the 8-bit microcontroller is your best bet.

Below are some of the advantages of using an 8-bit microcontroller like the 8051. 

Cheap and easy to use

An 8-bit microcontroller is a great choice for the beginner, or when money is an issue.

8-bit microcontrollers are cheaper and easier to use compared to their counterparts. 

If you are a beginner just getting started 8-bit microcontrollers are your best friend, as its architecture is simpler and has a programming model that is easier to understand. 

Also, most of the time it requires a single supply which lowers costs, and if funds are an issue, is again your best friend.

Lower power

Power is a precious commodity in many areas in life. 

It helps run our homes, workplaces and is needed by every electronic device.

But, power is not an abundant source. 

So, when designing embedded systems, a lot of thought has to go into how much power microcontrollers consume. 

The less the better!

8-bit microcontrollers use less power, which is a great advantage when it comes to designing an embedded system. 

Package style of 8051 microcontroller 

The 8051 microcontroller is available in two package styles which provide different mounting styles.They include the TQFP and PDIP.

The TQFP package style is 44 pin surface mount integrated circuit and the PDIP is a 40 pin through hole integrated circuit. 

If you are just prototyping, or building a one off project, the PDIP package will suit your application.

If you are creating a final version of your product, or mass producing circuits, the TQFP style of package is a great choice. 

Other types of 8-bit microcontroller

Is the 8051 the only 8-bit microcontroller available?

No, there are a plethora of 8-bit microcontrollers available for you to pick and choose. The 8051 is just one of many. 

There are a number of different manufacturers that develop microcontrollers. The top companies that develop the bulk of microcontrollers used in the market today include:

  • ATMEL (now owned by microchip)
  • MICROCHIP
  • NXP
  • TEXAS INSTRUMENTS

These companies all develop different ranges of microcontrollers that vary in specifications. 

But, what is common is they all have a range of 8-bit microcontrollers. 

What is the difference between 8-bit, 16-bit, and 32-bit microcontrollers?

So, an 8051 is called an 8-bit microcontroller because it processes data 8-bits every machine cycle. It has registers, data and address buses all capable of storing and transferring this data 8-bits at a time.

While a 8-bit microcontroller processes 8 bits of data a time, a 16-bit microcontroller processes 16 bits and a 32-bit microcontroller processes 32 bits. 

The main difference between the three is how many bits are processed every machine cycle.

The 16-bit and 32-bit microcontrollers have the benefits of faster operation, and better precision. The downside however, is that they consume more power.

The post Why is the 8051 called an 8-bit microcontroller? appeared first on Electronic Guidebook.

]]>
327
Can a microcontroller work independently? https://electronicguidebook.com/can-a-microcontroller-work-independently/?utm_source=rss&utm_medium=rss&utm_campaign=can-a-microcontroller-work-independently Fri, 17 Jul 2020 07:12:22 +0000 https://electronicguidebook.com/?p=323 A microcontroller is an amazing piece of technology with many capabilities. But, can a microcontroller work independently? A microcontroller can work independently as part of a stand alone embedded system. It is a device that is capable of controlling, outputs, inputs, and external peripherals by itself without the assistance of another microcontroller or microprocessor.  Taking […]

The post Can a microcontroller work independently? appeared first on Electronic Guidebook.

]]>
A microcontroller is an amazing piece of technology with many capabilities.

But, can a microcontroller work independently? A microcontroller can work independently as part of a stand alone embedded system. It is a device that is capable of controlling, outputs, inputs, and external peripherals by itself without the assistance of another microcontroller or microprocessor. 

Taking a closer look and understanding how a microcontroller works will give us a better understanding of how it can work independently. 

Also defining what working independently means will help with our question which I will cover later.

A closer look at a Microcontroller

So what is a Micrcontroller?

A microcontroller is essentially a small computer embedded on a single metal-oxide-semiconductor integrated circuit chip.

Just like our brains are tasked with controlling everything we do, a microcontroller is the brain of an embedded system tasked with controlling everything it does.

But, a microcontroller can do more than just process information. 

Just like we have eyes to help us see, a nose to help smell, legs to help us move around etc, microcontrollers have features also known as peripherals, that help them perform different tasks.

These peripherals include:

  • Memory
  • Timers
  • Analog to Digital Converter
  • Digital to Analog Converter
  • Serial Communication
  • General Input/Output pins
  • Pulse Width Modulation 

All these features are built in the microcontroller chip. 

What does working independently for a microcontroller mean?

To understand the question of whether a microcontroller can work independently, we need to understand what an embedded system is.

A microcontroller is always part of an embedded system.

An embedded system is a combination of processors, communication and input/output peripherals.

The most common embedded system you will be familiar with is a computer.

It has inputs(mouse, keyboard), outputs (computer screen), and a processor (CPU).

Similarly, microcontrollers are part of  an embedded system with inputs (sensors, buttons, switches) and outputs (motors, LEDs).

In this instance a microcontroller is working independently. It is in charge of processing, running and controlling information and input and outputs. 

It is a stand alone embedded system.

Other instances you will have larger systems that are a collection of smaller embedded systems.

At the heart of these smaller systems are microcontrollers. 

However, these microcontrollers are working together to achieve a specific goal, and each microcontroller is given a task to help achieve the end goal.

In this instance the microcontrollers are not working independently, as they rely on each other (there is some form of communication between microcontrollers).

Microcontroller vs Microprocessor

The microcontroller and the microprocessor get confused a lot . However, the two are quite different. 

The main difference is that Microprocessors do not have in-built peripherals like memory, Analog to Digital Converter, Pulse Width Modulation etc.

Due to this a microprocessor relies on external peripherals to achieve specific tasks and cannot work independently. 

When can a microcontroller work independently?

There are many applications where a microcontroller is part of a stand alone embedded system and has to work independently.

The less complex a system the easier it is for a microcontroller to work by itself. It can process and control all information.

There is no master processor, the sole microcontroller is the master itself.

Examples of stand alone embedded systems include:

  • Toasters
  • Microwaves
  • Ovens
  • Mp3 Players
  • Digital Cameras
  • Video Game Consoles
  • Radio

These are just a few of the many examples of stand alone embedded systems where a microcontroller works independently.

When can a microcontroller not work independently?

There are embedded systems that consist of multiple subsystems and microcontrollers.

In these types of systems, operations are more complex and would be too much work for a single microcontroller to carry out independently.

So multiple microcontrollers are needed, each given a specific task. 

There might even be a master microcontroller that is in charge of overseeing all operations and the other microcontrollers.

Whatever the end goal, it requires the microcontrollers to work and communicate together efficiently. 

Common examples of embedded systems with multiple subsystems and microcontrollers are:

  • Automobiles
  • Weather Stations
  • Home Security systems 
  • Mobile Phones
  • Smart Home Systems

Why would a microcontroller work independently?

The reason a microcontroller might work independently is because the application it is used in is not very complex in nature and does not require a lot of processing.

It all depends on the application. 

But, do not underestimate the capabilities of microcontrollers. They can achieve a lot even when they are working by themselves.

Final thoughts

Depending on the complexity of the embedded system, a microcontroller can work independently. 

When there is a larger system consisting of multiple subsystems, microcontrollers do not work by themselves, but with a network of microcontrollers. 

They communicate with each other and work together to complete a task.

The post Can a microcontroller work independently? appeared first on Electronic Guidebook.

]]>
323
Can I replace an Atmega8 with an Atmega328? https://electronicguidebook.com/can-i-replace-an-atmega8-with-an-atmega328/?utm_source=rss&utm_medium=rss&utm_campaign=can-i-replace-an-atmega8-with-an-atmega328 Tue, 14 Jul 2020 22:40:44 +0000 https://electronicguidebook.com/?p=317 The Atmega8 is a great microcontroller that has many features and capabilities. It is also one of the most commonly used microcontrollers used by hobbyists and engineers and found in many electronic devices. But, can you replace an Atmega8 with an Atmega328? Yes you can replace an Atmega8 with an Atmega328 as both microcontrollers have […]

The post Can I replace an Atmega8 with an Atmega328? appeared first on Electronic Guidebook.

]]>
The Atmega8 is a great microcontroller that has many features and capabilities.

It is also one of the most commonly used microcontrollers used by hobbyists and engineers and found in many electronic devices.

But, can you replace an Atmega8 with an Atmega328? Yes you can replace an Atmega8 with an Atmega328 as both microcontrollers have the same number of pins (28) and have the same operating voltages (2.7 – 5.5 volts). The Atmega8 and Atmega328 also share an almost identical set of peripherals such as the Timers, Analog to Digital Converter, and Serial Communication.

There are some slight differences however, between these two microcontrollers that might see you choosing the Atmega328 over the Atmega8. 

I will highlight these differences later in this article. 

Your reason to want to replace your existing Atmega8 with an Atmega328 could be as simple as you only have an Atmega328 lying around.

No matter what rest assured you can replace them with no problems.

Are the Atmega8 and Atmega328 part of the same microcontroller family?

In the world of microcontrollers, you have many options at your disposal.

There are many manufacturers of microcontrollers which include Atmel, Intel, Texas Instruments, National Semiconductor and Microchip.

These companies are responsible for manufacturing the majority of microcontrollers used today.

These include :

  • AVR
  • MSP
  • PIC
  • ARM
  • 8051

Among these set of microcontrollers, the AVR family is the most widely used because of its low prices, availability, community and ease of use.

They were produced by Atmel who were acquired later by Microchip.

AVR is the type of architecture that these microcontrollers are built on.

The AVR family is further divided into a subset of families:

  • tinyAVR
  • megaAVR
  • XMEGA

The Atmega8 and Atmega328 are both produced by Microchip, and are part of the megaAVR family.

Reasons you would want to replace your Atmega8 with an Atmega328

You might have been using an Atmega8 for a long time now and want to make the switch to a new microcontroller or you only have a spare Atmega328 lying around.

No matter what your reason ,the Atmega328 is a great choice as it shares many similar attributes as the Atmega8 and can be used as a direct replacement. 

It shares the same number of pins, clock speed, operating voltage, and set of peripherals.

But, there are some very slight differences that might make you want to choose the Atmega328 over the Atmega8 depending on your needs.

Reason #1: Extra PWM channels 

Pulse width Modulation (PWM) is used for many control applications that include controlling DC motors, control valves, pumps, hydraulics and other mechanical parts.

It is also used in applications to control the brightness of lights like LED’s.

Both the Atmega8 and Atmega328 have PWM channels, however, the Atmega328 has three extra PWM channels.

But, do you really need 3 more PWM channels?

Yes!  

Having extra PWM channels is definitely an advantage. The more the better.

Say your next project is robot arm, where you need to control 4 or more servos.

If you opt for the Atmega8 you only have access to three PWM channels and are limited by how many servos you can control.

Instead if your choice is the Atmega328, you have access to six PWM channels which means you will be able to add more servos giving your robot arm more movement. 

Reason #2: Memory

All microcontrollers come with in-built memory. This is the one of the many things that differentiates them from Microprocessors

Just like us humans rely on memory for many aspects of life, a microcontroller relies on its memory for many different facets of its operations.

It uses memory to store things that include the program, runtime constants and variables, and other important data.

A microcontroller has three main types of memory:

  • Flash Memory
  • Static Random Access Memory (SRAM) 
  • Electrically Erasable Programmable Read Only Memory (EEPROM)
Flash Memory

This type of memory is ‘non-volatile’, which means when the power is removed from the microcontroller all data stored in Flash memory is saved and not lost.

The program that tells the microcontroller what to do is stored in Flash memory.

Static Random Access Memory (SRAM)

SRAM is a memory which is ‘volatile’.

So unlike Flash memory, when power is removed from the microcontroller, all data stored in SRAM is lost.

Variables and constants which are generated during program runtime are stored in SRAM.

Electrically Erasable Programmable Read Only Memory (EEPROM)

The last type of memory is EEPROM.

EEPROM is ‘non-volatile’ memory. 

It is used to store permanent data which can be called upon later.

Permanent data like device parameters and sensor data. 

Below is a table showing how much memory (Flash, EEPROM, SRAM) the Atmega328 has compared to the Atmega8:

Atmega328Atmega8
Flash memory32K bytes8K bytes
EEPROM1K bytes512 bytes
Internal SRAM2K bytes1K bytes

As you can see, the Atmega328 beats the Atmega8 when it comes to memory space for all three types of memory. 

Having more memory is a definite advantage for many different applications as it will allow you to write bigger programs, store more data, and have more runtime constants and variables.

Reason #3: Extra Sleep Mode

While this is not a major difference, it is a difference nonetheless.

Every microcontroller has the ability to enter modes to help save power.

These are known as ‘Sleep Modes’. 

Atmega8 Sleep Modes:

  • Idle
  • ADC Noise Reduction
  • Power-Save
  • Power-Down
  • Standby

Atmega328 Sleep Modes:

  • Idle
  • ADC Noise Reduction
  • Power-Save 
  • Power-Down
  • Standy
  • Extended Standby

The Atmega328 has one more sleep mode than the Atmega8. 

Having one more sleep might not seem like a big deal, but it gives you more options for conserving power which can be vital in prolonging battery life.

Reason #4: Price

The last difference between an Atmega328 and Atmega8 is their prices.

The prices shown below are as shown on Microchips website.

Atmega328Atmega8
Price$1.38$1.75

Again the Atmega328 comes away as the winner when it comes to price.

You might think that the price difference is negligible. You are only saving $0.37.

But, think about if you buy 100 Atmega328’s compared to 100 Atmega8’s.

You will be making a saving of $37 in the long run!

Can I use the same programmer and IDE to program an Atmega8 or Atmega328?

Now you know that you can replace the Atmega8 with the Atmega328, you will need a way to write code and program it. 

The great news is that, because both these microcontrollers are manufactured by the same company and are part of the same family, they can be programmed using the same programmer and Integrated Development Environment (IDE).

A list of IDE’s that you can use program the Atmega328 include

  • Codevision AVR
  • Atmel Studio
  • WinAVR
  • AVR-GCC

A list of AVR programmers you can use to burn the code onto the Atmega328 are:

  • AVRISP
  • AVR Dragon
  • STK500
  • JTAG Programmer/Debugger

Other microcontrollers that can replace an Atmega8?

When it comes to options for replacing the Atmega8, you have many choices available.

The Atmega328 isn’t the only microcontroller that is available at your disposal.

The table below is taken from the Microchip website and lists all the microcontrollers you can use to replace an Atmega8. 

The list of microcontrollers below are all capable of replacing the Atmega8. This list is taken from the Microchip website. 

  • Atmega168
  • Atmega168A
  • Atmega168P
  • Atmega168PA
  • Atmega168PB
  • Atmega328
  • Atmega328P
  • Atmega328PB
  • Atmega48
  • Atmega48A
  • Atmega48P
  • Atmega48PA
  • Atmega48PB
  • Atmega88
  • Atmega88A
  • Atmega88P
  • Atmega88PA
  • Atmega88PB
  • Atmega8A

Final thoughts

You might be currently using the Atmega8 and wanting to make a switch to a different microcontroller, or your Atmega8 has stopped working and the only other microcontroller you have is the Atmega328.

No matter what your purpose is to replace the Atmega8 with an Atmega328, rest assured you can do so with no hindrance.

Both are interchangeable as they come from the same family of microcontrollers.

They both have the same number of pins, operate at the same voltages, and can be programmed using the same programmer in the same Integrated Development Environment.

The post Can I replace an Atmega8 with an Atmega328? appeared first on Electronic Guidebook.

]]>
317
What are microcontroller peripherals? https://electronicguidebook.com/what-are-microcontroller-peripherals/?utm_source=rss&utm_medium=rss&utm_campaign=what-are-microcontroller-peripherals Mon, 06 Jul 2020 00:18:18 +0000 https://electronicguidebook.com/?p=298 A microcontroller is a versatile device capable of many things. It is essentially a mini computer on a single semiconductor integrated circuit chip. It can be found in many different applications that range from consumer electronics, medical, marine, automotive, aviation and many more. A microcontroller has many features that make it the choice for hobbyists […]

The post What are microcontroller peripherals? appeared first on Electronic Guidebook.

]]>
A microcontroller is a versatile device capable of many things.

It is essentially a mini computer on a single semiconductor integrated circuit chip.

It can be found in many different applications that range from consumer electronics, medical, marine, automotive, aviation and many more.

A microcontroller has many features that make it the choice for hobbyists working in their garage, and engineers working in the industry.

Microcontrollers have many features which include something known as peripherals.

But, what are microcontroller peripherals?

Microcontroller peripherals are parts of the device that serve a specific purpose which help the microcontroller achieve a certain task. Some common microcontroller peripherals are Timers, Analog to Digital converters (ADC), Serial Peripheral Interfaces (SPI), Pulse Width Modulation and 2 wire interfaces (I2C). 

These common peripherals are built into the microcontroller and is one distinguishing difference between it and the microprocessor.

Peripherals that come stock with the microcontroller are known as on-chip peripherals, and ones that you add and interface separately are known as off-chip peripherals. 

What is the main purpose of microcontroller peripherals?

As you briefly saw above, microcontroller peripherals serve a specific purpose that help the microcontroller with a given task.

Let’s take the Analog to Digital Converter (also better known as the ADC) peripheral as an example. 

The ADC has one specific task, which is to take analog data it receives from a sensor (or other any device that outputs analog data), and convert it to digital values that the microcontroller can then process. 

This opens up many possibilities for applications. 

Here is a simple example.

Say you want to turn on a fan when it gets too hot.

The temperature sensor reads the physical temperature of the environment in analog form. 

But, the microcontroller cannot process this information as it is in analog form. 

This is where the ADC lends its helping hand. 

It converts this analog data to digital which the microcontroller can then process accordingly. 

As you can see, the ADC helps the microcontroller with a specific task.

All the other microcontroller peripherals have different functions, but just like the ADC, help the microcontroller with a specific task.

Why use microcontroller peripherals?

The simple answer is to let you perform the task the peripheral was designed to do.

The ADC has the ability to convert analog data to digital.

From the example you saw above, without the ADC, the microcontroller would not be able to do anything with the data it receives from the temperature sensor.

The project specifications will determine what peripherals are needed or not needed. 

Different microcontroller peripherals examples

Microcontroller’s have many peripherals available for different applications.

Listing all of them might take some time, so I will list the peripherals that are most commonly used by a microcontroller.

These peripherals are always found embedded in the microcontroller.

The most common microcontroller peripherals are:

  • Timers
  • Analog to Digital Converter
  • Digital to Analog Converter
  • Serial Communication (SPI, I2C, and UART)
  • General Purpose Input/Output registers
  • Memory (FLASH, SRAM, EEPROM)
  • Pulse Width Modulation

Microcontroller Peripheral #1 : TIMER

The first peripheral that is always found in a microcontroller is the Timer.

Think of your daily life.

Everything you do is determined by a start time, duration and finish time.

You get up at 8am, get to work by 9am, work till 5pm, go to the gym at 6pm etc.

A microcontroller is very similar in the sense that it has operations which have starting times, durations and end times.

So, it needs some way of keeping track of all these events.

That is where the Timer comes in!

The Timer is an important part of a microcontroller as it maintains the timing of operations and keeps it in-sync with the system clock of the microcontroller.

A simple example of this is blinking an LED.

This might seem like not a great feat, but without the capabilities of the Timer you would not be able to do something as simple as turning an LED on and off.

Microcontroller Peripheral #2 : Analog to Digital Converter 

I mentioned the Analog to Digital Converter (ADC) earlier and its ability to convert analog data to a digital form.

This is one of the reasons the ADC is such a common peripheral in microcontrollers.

Sensors are devices that sense the physical world.

There are sensors available that can sense temperature, humidity, light, altitude, force and many more.

However, most if not all these sensors output values that are in an analog format.

As you saw earlier, the microcontroller can only process digital data (0’s and 1’s) and that is where the ADC bridges that gap. 

Microcontroller Peripheral #3 : Digital to Analog Converter

So, the microcontroller can convert analog data to digital using the ADC.

Can it reverse the process and covert digital data to analog?

Yes, absolutely!

Thanks to the Digital to Analog Converter (also known as DAC) peripheral.

The DAC peripheral gives the microcontroller the ability to reverse the process and convert digital to analog.

One of the many examples where this comes handy is playing audio from the micrcontroller’s memory.

You know now that the microcontroller only deals with digital values.

Say a piece of audio is recorded using a microphone and converted to digital data using the ADC and stored in the micrcontroller’s memory in a digital format.

To be able to recreate this audio and play it through a speaker, you will need the help of the DAC.

The DAC converts the digital values into an analog form that can then be played through a speaker.

Microcontroller Peripheral #4 : Serial Communication

Communication is an essential part in everyday life.

We communicate to each other visually, and orally to argue a point , to socialize, teach, learn etc.

Imagine a world where you weren’t able to communicate to your loved ones or anybody at all.

That world would suck!

In the world of microcontrollers, communication is also a crucial element. 

Microcontrollers have a range of serial communication peripherals which include:

  • Serial Peripheral Interface (SPI)
  • Two Wire Interface (I2C)
  • Universal Asynchronous Receiver /Transmitter (UART)

Serial communication allows a microcontroller to ‘talk’ to another microcontroller, computer or external peripheral devices.  

Communication allows the exchange of data which can be information like status updates, or sensor data.

Microcontroller Peripheral #5 : General Purpose Input/Output

Number 5 on the list of common microcontroller peripherals are input and output pins or GPIO’s.

Without the GPIO peripheral the microcontroller would not be able to interface with the other devices.

Devices such as:

  • Motors (Servos, stepper motors, DC brushless motors)
  • Sensors
  • LED’s
  • Buttons
  • Switches

Turning on a LED, reading a button press, connecting a sensor, etc, all requires input and output registers.

A microcontroller pin can be programmed either as an input or output.

Microcontroller Peripheral #6 : Memory

Remember what you did yesterday? (hopefully you do!)

That’s thanks to your memory! 

Our memory lets us remember important life events, things we have learnt, skills we have practiced, habits etc.

A microcontroller has memory for similar purposes.

It also has short term and long term memory just like we do.

A microcontroller memory peripheral typically has 3 types of data storage”

  • Static Random Access Memory (SRAM)
  • FLASH
  • Electrically Erasable Programmable Read Only Memory (EEPROM)

The short term memory (SRAM)  is used to store constants and variables that are used by the microcontroller during normal program execution. 

When the power is removed, all memory in RAM is lost.

Long term memory (FLASH) is where things like the program the software designer has written gets stored. 

Even when power is turned off, this memory remains. 

Microcontroller Peripheral #7 : Pulse Width Modulation

Last but not least of common microcontroller peripherals is Pulse Width Modulation (PWM).

The PWM peripheral works in conjunction with the timer peripherals of a microcontroller. 

What is PWM used for?

Say you have a motor connected to one of the output pins of the microcontroller. 

The speed of that motor can either be 0v or maximum voltage that the microcontroller is operating at (let’s say 5V).

But, you want to be able run that motor at a range of voltages from 0V to 5V that will alter its speed accordingly. 

That is where the PWM peripheral works its magic.

By connecting the motor to a PWM enabled pin you can vary the speed of the motor. 

Maybe you want to dim an LED, again PWM is what is needed. 

Do all microcontrollers have peripherals?

Microcontrollers come in a range of sizes, speeds, architectures, and manufacture families.

The most common microcontrollers available and used are Atmel AVR, 8051, and PIC.

While microcontrollers vary in specifications mentioned above, they all come with a set of peripherals.

However, a larger microcontroller might have more peripherals compared to a smaller microcontroller.

I covered the most common peripherals that are found in microcontrollers earlier. These peripherals can be found in most if not all microcontrollers regardless of size.

Other microcontroller peripherals (which are a bit more unique) might only be available to chips with higher specifications. 

Where are microcontroller peripherals located?

The standard peripherals like Memory, GPIO, ADC, DAC, Serial Communication and Timers are located internally in the microcontroller. 

However, there are peripherals that are available as separate modules and can be interfaced with the microcontroller externally. 

Maybe you want to add bluetooth capability to your next project. 

To do so, you will need to add an external bluetooth peripheral and interface it with the microcontroller. 

Can a microcontroller function without peripherals?

There is no specific answer for this question as it all depends on the specifications and complexity of the application.

While there are some peripherals that the microcontroller can function without, there are certain peripherals that it relies on.

These peripherals include Memory and Timers.

It requires memory to store the main program, as well as constants and variables during runtime. 

And it needs the Timer to ensure operations are run in sync with the system clock and on schedule. 

When is the best time to use microcontroller peripherals?

Knowing when to use a microcontroller peripheral all depends on the needs of the project.

When writing the program code, you as the designer will have to know when you will need to call on the functions of the ADC, or Serial Communication or Timers etc.

It might be right at the start of the program, or you might have to call on them depending on external factors.

By knowing the needs of your projects will determine when you use a particular microcontroller peripheral

Final Thoughts

A microcontroller is a great piece of engineering, that enables us to achieve many things and has been found in many applications.

Applications in Medical, Automotive, Aviation, Consumer Electronics and many more. 

But, sometimes a microcontroller by itself can be quite redundant.

That is where peripherals come to the rescue.

Microcontroller peripherals are parts modules of a microcontroller (internal or external) that serve a specific task.They help the microcontroller perform operations that it would not be able to do by itself. 

Much like a mouse and keyboard of a computer. 

The computer is capable of so many things, but remove simple peripherals like the mouse and keyboard and the computer is rendered useless. 

The mouse and keyboard serve specific tasks that help you and the computer.

The post What are microcontroller peripherals? appeared first on Electronic Guidebook.

]]>
298