Recently searched
      • Published 5 Apr 2024
      • Last Modified 5 Apr 2024
    • 11 min

    A Complete Guide to Microcontrollers

    What is a Microcontroller?

    Microcontrollers (often shortened to MCUs or MCs) are extremely small microcomputers that are entirely self-contained on a single chip.

    You can define a microcontroller as a simplified computer - one that is generally designed to run a single basic programme repeatedly. By definition, microcontrollers are typically intended to perform a single automated task, as pre-programmed by the user, in a single device. They are designed to do this one job repeatedly (or, as is also common, on a timed loop).

    This is known as an embedded application, as opposed to the more versatile, general-purpose applications handled by full microprocessors and CPUs.

    Microcontrollers do contain a microprocessor of sorts as one of their key components, but it is typically a far less complex and dynamic form of CPU than most standalone MPs. This is because the microcontroller unit is generally limited to performing a single highly specific job. This means that it does not need the full range of functionality that a proper microprocessor offers.

    To achieve this, the basics of a microcontroller dictate that it generally works in conjunction with other types of components and electronic circuits, connected via printed circuit boards (PCBs). This combination of a microcontroller and PCB-based equipment can be used to play a key role in controlling, monitoring and affecting various sorts of systems and component behaviours.

    Types of Microcontrollers

    Although there are many recognised manufacturing brands and programming architectures used for microcontrollers, there are just three distinct types of MCUs in current use. These are:

    The main distinction between the three microcontroller types comes in terms of their respective bus widths - the width of their respective data pipes.

    This is ultimately the key specification that limits a microcontroller’s speed mathematical precision. In short, an 8-bit microcontroller will require an increased number of bus accesses and more instructions to perform 16-bit or 32-bit calculations. It will therefore arrive at the answer (i.e. output behaviour) much more slowly than a 16 or 32-bit MCU.

    In computing terms, it is effectively the same sort of limitation issue as you would find with a slow CPU rather than a faster, more powerful one. These important criteria will impact the choice and scope of programming languages you can comfortably use with a microcontroller unit. Whether it is C++, Python, R, or Arduino, microcontrollers are broadly compatible with a variety of programming languages although the specifics will depend on the device.

    8-bit MCUs have long been viewed as the most basic and cost-effective options, but with limited functionality in some applications. 16-bit and 32-bit microcontrollers are typically more expensive but offer performance gains to match.

    Microcontroller Applications

    Across an array of modern applications and industries, microcontrollers have quickly achieved widespread market penetration and can be found today in many technologies and gadgets. Any electronic device containing a sensor, a display, a user interface and a programmable output control or actuator is likely to feature an MCU.

    Some of the more common microcontroller projects, functions, applications and environments where they are used include:

    • Automation and robotics
    • Consumer electronics and domestic appliances
    • Medical and laboratory equipment (handheld diagnostic devices, scanners and X-ray machines, measuring, analysis and monitoring tools)
    • Automotive industries and vehicle control systems (powertrain adjustment, multimedia consoles and navigation software)
    • Industrial and production environment controls (heating and lighting, HVAC systems and safety locking mechanisms)
    • IoT devices and systems

    What Do Microcontrollers Do?

    When installed as part of a functioning circuit in a device or system, a microcontroller board can sense, monitor and respond to various events, behaviours or input signals that it detects from connected components and its environment.

    A microcontroller, for example, might be programmed to push a specific type of output signal or behavioural control in response to certain input criteria. This could include the execution of tasks such as:

    • Illuminating an LED or OLED display in response to touch-based user demand
    • Playing lights and sounds in temperature-sensing applications or other varieties of alarms and warning systems
    • Responding to the need for a motor to switch on or off in a pump or other mechanical device
    • Adjusting for tilt, balance, and velocity in gyroscope or accelerometer-based applications

    How to Use a Microcontroller: How Do They Work?

    Microcontroller

    A microcontroller unit (MCU) is a very small computer entirely embedded on a single integrated circuit, otherwise known as a chip.

    In this regard, using microcontrollers is somewhat similar to using a System-on-Chip (SoC), which is what you would typically find powering a home computer, perhaps manufactured by Intel or AMD. However, a microcontroller is significantly less sophisticated than the average SoC (the latter often include one or more microcontroller boards among their many core components).

    Microcontrollers operate much like a very simple SoC, in that they can detect and react to external stimuli or conditions via any number of different communications protocols. These might include USB, touch response, or environmental sensors.

    When properly programmed to react to certain inputs or signal detections, an MCU processor can be used to perform responsive behaviours across a diverse array of functions and applications. These can range from simple input-output (I/O) triggers and component-control algorithms, right through to influencing additional component behaviour in much more complex fully integrated systems.

    It is also important to understand the physical makeup of a microcontroller device. This will enable a better understanding of how to program a microcontroller as well as the differences between MCUs and similar components such as microprocessors (MPs).

    Since a microcontroller is effectively a simple mini-computer embedded on a single integrated chip, it requires many of the same fundamental components as a larger and more complex computer. Core microcontroller components include:

    • CPU (Central Processing Unit). Essentially the brain of the microcomputer, this component is a microprocessor that controls and monitors all the processes taking place inside the MCU. It is responsible for the reading and execution of all logical and mathematical functions being performed
    • RAM (Random Access Memory). This is temporary storage used only when powered on, for helping to run and calculate the programs the MCU is told to execute. It is continually overwritten while in use
    • ROM (Read-Only Memory). This is pre-written permanent memory that persists even without power. It essentially instructs the MCU on how to execute its programs when asked
    • Internal Oscillator (the main timer of the MCU). This component functions as the microcontroller’s core clock and controls the execution rhythms of its internal processes. Much like any other sort of timer, they keep track of time as it elapses during a given process, and help the MCU to begin and end specific functions at specified intervals
    • I/O (Input/Output) Ports. This consists of one or more communications ports, typically in the form of connective pins. They allow the MCU to be linked to other components and circuits for the flow of input/output data signals and power supply
    • Peripheral Controller Chips (other optional accessories and components). These are dependent on the task the MCU is required to perform. They can be anything from various additional timers and counters to pulse width modulation (PWM) nodes, Analogue-to-Digital Converters, Digital-to-Analogue Converters, numerous data capture modules, flash and program memory, further I/O options, and much more besides

    All these components, however, are much reduced in both scope and capacity on a microcontroller than a comparable SoC in a personal computer. An MCU would commonly be found controlling basic behaviours in products such as hairdryers or calculators but would offer pointlessly limited function in a more complex machine such as a full computer.

    Microcontroller Architecture

    Although there are only three core types of microcontroller, there is a diverse range of MCU manufacturer brands and architectures available.

    Some of the most common names users might frequently look out for include:

    • ARM core processors (many vendors supply ARM microcontrollers and related components including ARM Cortex-M cores)
    • Microchip Technology Atmel AVR microcontrollers (8-bit), AVR 32 (32-bit), and AT91SAM (32-bit)
    • Microchip Technology PIC microcontrollers (8-bit PIC16, PIC18, 16-bit dsPIC33, PIC24, 32-bit PIC32)
    • Freescale ColdFire (32-bit) and S08 (8-bit)
    • Intel 8051 microcontrollers
    • PowerPC ISE
    • Renesas Electronics (RL78 16-bit MCU, RX 32-bit MCU, SuperH, V850 32-bit MCU, H8, R8C 16-bit MCU)
    • Silicon Laboratories Pipelined 8-bit 8051 microcontrollers and mixed-signal ARM-based 32-bit microcontrollers
    • Texas Instruments TI MSP430 (16-bit), MSP432 (32-bit), C2000 (32-bit)
    • Toshiba TLCS-870 (8-bit and 16-bit)
    • CISC and RISC (also RISC-V)

    For more detailed information and advice on selecting or programming microcontrollers, processors, and microcontroller development boards and kits, please feel free to contact our expert customer support team.

    Microcontroller Block Diagram

    This block diagram portrays the internal architecture of an 8051 microcontroller.

    The CPU manages and synchronises processes, managing the registers and interpreting ROM data. The sub-routine Interrupts call is provided if another priority program requests system bus access. Interrupts enable current processes to be delayed for this additional access to happen. The oscillator (marked as OSC on the diagram) performs timer operation for the microcontroller's digital circuit.

    Microcontroller Block Diagram

    Microcontrollers vs Microprocessors

    Microprocessor

    There is often confusion with regards to precisely what defines a microcontroller vs a microprocessor (MP) or System on Chip (SoC).

    In a nutshell, a microcontroller is a simplified, single-task version of a SoC. Although an MCU technically contains a CPU or processor of sorts as part of its integrated circuit, it is a much more simplified version. This reduced-power microprocessor effectively functions as a simple CPU or brain for the microcontroller unit, giving the MCU the basic ability to perform its single programmed role.

    In terms of laying out the other key differences between a microprocessor and a microcontroller, the easiest definition is to talk in terms of components. A true microprocessor does not contain any memory (RAM or ROM) or I/O ports and can only operate as part of wider embedded systems. The instruction sets telling a standalone microprocessor how to execute a given function are generally stored externally. In a microcontroller, all these various components - including the simplified processor - are combined into a single self-contained unit.

    Performance-wise, microcontrollers and microprocessors break down something like this:

    Microcontrollers

    • Are an entirely self-contained unit that contains a very simple CPU or microprocessor
    • Are used for a single specific application, as pre-programmed by the user
    • Are not especially powerful in performance terms; typically, they only draw a small amount of power and contain little in terms of integrated data storage capacity
    • Need to be programmed by the operator to perform any meaningful role
    • Cannot operate outside of their specifically programmed remit (the code written for them - and the quality of it - will entirely define their performance)
    • Are generally meant for use in specific devices or appliances designed to perform one task repeatedly

    Microprocessors

    • Are much more complex and versatile in terms of function range, and intended for use in more general computing (as opposed to in specialised one-task devices)
    • Have much faster processor (clock) speeds than MCUs, often measured in gigahertz (GHz) rather than Hz
    • Are challenging and expensive to manufacture, unlike relatively simple and cheap microcontrollers
    • Require far more external components (RAM, I/O ports, data storage, EEPROM or flash memory) to operate, none of which are integrated into the MP and must be bought and connected separately
    • Have a considerably higher power draw and are subsequently much less cost-effective to run continually

    FAQs