The IoT requires sensors and actuators to form the link between the physical and digital worlds. A sensor converts a physical state into an analogue or digital signal, while an actuator turns a digital signal into some physical effect. The next step in the IoT architecture is the computing system which processes or generates the digital signals.
Both microcontrollers and microprocessors can perform these operations. Microcontrollers and microprocessors are not the same thing, although the boundary between them is somewhat blurred. The following is taken from Difference between Microprocessor and Microcontroller
The term microprocessor and microcontroller have always been confused with each other. Both of them have been designed for real time application. They share many common features and at the same time they have significant differences. Both the IC’s i.e., the microprocessor and microcontroller cannot be distinguished by looking at them. They are available in different version starting from 6 pin to as high as 80 to 100 pins or even higher depending on the features.
Microprocessor is an IC which has only the CPU inside them i.e. only the processing powers such as Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc. These microprocessors don’t have RAM, ROM, and other peripheral on the chip. A system designer has to add them externally to make them functional. Application of microprocessor includes Desktop PC’s, Laptops, notepads etc.
But this is not the case with Microcontrollers. Microcontroller has a CPU, in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a single chip. ...[elided confusing text]...
Microcontrollers are designed to perform specific tasks. Specific means applications where the relationship of input and output is defined. Depending on the input, some processing needs to be done and output is delivered. For example, keyboards, mouse, washing machine, digicam, pendrive, remote, microwave, cars, bikes, telephone, mobiles, watches, etc. Since the applications are very specific, they need small resources like RAM, ROM, I/O ports etc and hence can be embedded on a single chip.
In the Harvard architecture, program memory and data memory are separate and are on different data paths. This means that reads and writes can be made concurrently to each, which is potentially faster. More importantly for small devices, the memory systems can be chosen to be differerent technologies and different sizes. In the von Neumann architecture, a single data path is used for both.
Microcontrollers seem to be primarily Harvard, with specifications clearly stating the ROM and RAM. For microcontrollers, EEPROM (electrically erasable programmable read-only memory) is typically used to store whatever program the microcontroller will run. Typical is flash memory. This memory is persistent between power on and off, so the microcontroller will always start the same program. However, this program can be overwritten if necessary.
For a microprocessor with external storage of files and programs, the ROM memory is typically for firmware to boot the processor and load programs from secondary storage into RAM. This allows, for example, different operating systems to be stored and loaded from secondary storage, giving for example, multi-boot systems. Microprocessors appear to be more von Neumann based than Harvard based.
There are a huge number of microcontrollers. The Element14 site lists over 7,000 microcontrollers for sale, in 8-, 16- or 32-bit forms while Wikipedia has a long list of common microcontrollers, by vendor.
Texas instruments make a large range of microcontrollers.
is a "Ultra-Low-Power Microcontroller, 4KB Flash, 256B RAM, 1x SD24"
It represents the lower end of the microcontrollers, with only 4 kilobytes for program memory and 256 Bytes of RAM to play with.
At the other end of the microcontroller scale, the TI MSP432P401R is a 32-bit ARM Cortex M4F with 256KB Flash and 64KB RAM
Microcontrollers are a single chip. To use them, they have to be built into a system with clock, support ICs, I/O pins, etc. In a commercial system this would be part of the final design. However, for hobbyists and for prototyping, a pre-assembled board would be useful.
This is the domain of single-board microcontrollers. A current system is Wiring which is based on the AVR ATmega128 microcontroller with 128KB of programmable flash memory, 4KB SRAM, a 4KB EEPROM, and an 8-channel 10-bit A/D converter. The current favourite in this space is the Arduino, which is discussed extensively in a later chapter.
Sparkfun have a development board around the ESP8266 microcontroller: SparkFun ESP8266 Thing - Dev Board
Microprocessors form the heart of most computers that we currently use. They feature external RAM to allow expansion capabilities (upto addressability) which is not possible for microcontrollers. They include current Intel chips and current ARM chips. Typically they will be placed on a motherboard.
SoCs are the latest flavour of CPU + system design.
Basically, while a motherboard acts as a container
for CPU, GPU, video card, audio processor, RAM, etc,
in a SoC many of these functions are moved into the
CPU chip itself. A SoC will typically contain the CPU,
GPU, audio processor and signal processor. There is still
a sort of motherboard, but that isn't talked about so much,
The following diagram of the Texas TI OMAP5430 SoC shows
in red the SoC, the rest of the "motherboard" in grey and black:
The most notable SoC at present is the Raspberry Pi (RPi), but there are a host of alternatives. The RPi comes in several models, with the top-end having 1GB RAM
The possible programming languages that can be used depend heavily on the amount of RAM and secondary storage available. For example, the msp430afe221 with only 4KB of flash and 256B of RAM can only support an absolutely minimal system.
For really small systems, Assembly language is an obvious candidate. However, this is also the space in which C and C++ claim primacy: the stated aim for for both languages is that there should be 'no room' for any other language to get 'closer to the metal'. (Stroustrop: An Overview of the C++ Programming Language ).
The venerable language Basic (not Visual Basic, but the old original language) is surprisingly alive and well in the microcontroller space. For programming PIC microcontrollers, there is an entire book PIC Microcontrollers – Programming in Basic and compilers down to machine code exist for several processor families.
There is also a Turbo Pascal compiler Free Pascal compiler for 8051 for the 8051 microcontroller Embedded Systems/8051 Microcontroller an 8-bit microcontroller with 4kB program space and 256B RAM.
Once you get up to about 10kB of RAM, the possibility exists for more flexibility in programming. In particular, you enter the realm where small interpreted languages can be used. These include, for example, Forth, a rather wierd but fun stack-based language. This has been implemented for a number of microcontroller families, for example FlashForth "FlashForth is a Forth stamp system implemented on the Microchip 8-bit PIC18F and 16-bit PIC24, 30, 33 and the Atmel Atmega microcontroller families"
As the ROM and RAM get larger, the possibilities increase. For example, once you get upto 75kB ROM and 8kB RAM, MicroPython becomes a possibility.
Once you get upto 190kB RAM (we are now into vonNeumann microprocessor architectures rather than Harvard microcontrollers) you can run Java MicroEdition ( Java ME 8.1 in 190 KB RAM ).
But by then. of course, you are in the size where fully fledged operating systems such as Linux can run, supporting many of the standard languages.
Operating systems make sense for multi-tasking systems which may be running services, supporting different users, with file systems with security aspects. Do they make sense in the very small world of microcontrollers?
The boot process for microcontrollers and microprocessors is similar: after a hardware or software reset, the system has to be initialised. For the Atmel AT91, AT91 Assembler Code Startup Sequence for C Code Applications Software
The initialization code, located at address zero after reset, must:
After the environment has been initialized, the sequence continues with the application initialization and should enter the C code.
- Mark the entry point for the initialization code.
- Set up exception vectors.
- Initialize the memory system.
- Initialize the stack pointer registers.
- Initialize any critical I/O devices.
- Initialize any RAM variables required by the interrupt system.
- Enable interrupts (if handled by the initialization code).
- Change processor mode if necessary.
- Change processor state if necessary.
The document continues with an explanation of what is required and of their sample initialisation code.
In the case of systems which may be updated, the initial call may be to a bootloader which can download new code and then call into that.
So far this does not need the full power of an O/S. Behrad Mahboobi suggests
Actually when your system requires one of the following, then employing an operating system for your micro-controller would be useful
the application of operating systems contain the above item[s] but are not limited to them.
- running multiple process or function [at] the same time
- when [your] code and subroutines are getting large such that memory management is required.
- managing interrupts and event in efficient and standard way.
- implementing a standard protocol or service on your system like TCP/IP protocol, http service. [T]hese services are already available on [an] operating system and can be used efficiently.
- on chip debugging.
- remote managing and configuring your system
- file system management
- scheduling among parallel tasks in [an] automated or customized way.
For a list of operating systems see Internet of Things Software Some of these will run in as little as 14KB flash and 500B RAM. They presumably support applications using a limited API on top.
The IETF (Internet Engineering Task Force) is the principal standards organisation as regards anything related to the internet. Once a microcontroller or microprocessor has the potential to the connected to an internet, IETF standards may come into play.
The Terminology for Constrained-Node Networks discusses "a number of basic terms that have been useful in the standardization work for constrained-node networks". While this is primarily targeted at networking, they also consider the "nodes" themselves - microcontrollers and microprocessors. They proposed three classes as summarised in the following table
|Name||data size (e.g., RAM)||code size (e.g., Flash)|
|Class 0, C0||<< 10 KiB||<< 100 KiB|
|Class 1, C1||~ 10 KiB||~ 100 KiB|
|Class 2, C2||~ 50 KiB||~ 250 KiB|
The IETF fleshes this out with the potential of such nodes to connect to the internet:
Class 0 devices are very constrained sensor-like motes. They are so severely constrained in memory and processing capabilities that most likely they will not have the resources required to communicate directly with the Internet in a secure manner [...]
Class 1 devices are quite constrained in code space and processing capabilities, such that they cannot easily talk to other Internet nodes employing a full protocol stack such as using HTTP, Transport Layer Security (TLS), and related security protocols and XML-based data representations. [...]
Class 2 devices are less constrained and fundamentally capable of supporting most of the same protocol stacks as used on notebooks or servers. However, even these devices can benefit from lightweight and energy-efficient protocols and from consuming less bandwidth. [...]
This chapter has discussed microcontrollers and microprocesors and looked at the differences and commonalities between each of them. They can each support various levels of software, and programming languages and operating systems have been looked at. This is an overview chapter, and specific systems may have specific capabilities beyond what has been discussed here.
Copyright © Jan Newmarch, email@example.com
"The Internet of Things - a techie's viewpoint" by Jan Newmarch is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://jan.newmarch.name/IoT/.
If you like this book, please donate using PayPal