Unit II IoT
Unit II IoT
1
ii. Microcontrollers have properties such as Datapath Bandwidth. Datapath Bandwidth
specifies the number of bits in the registers. More bits, more accurate results.
iii. Microcontrollers connect to all the components of the system and thus they must have
sufficient input/output pins. Microcontrollers must have performance depending on what
system you are developing.
iv. Microcontrollers use a communication protocol to communicate with one another. The
protocols are helpful when you are building bigger systems that require constant
communication with other devices.
b. Single-Board Computer(SBC)
i. Single Board Computers (SBC) that contain all the processing and computing properties of
a computer on a single board. SBCs have memory units to store code, data, input, output units
and microprocessors for computing. It also includes an in-built RAM.
ii. They are a preferred choice in IoT industrial applications as they improve the functionality
of a regular computer, they are easily available and reduce the cost of transportation.
iii. Based on the kind of project you are making, you choose a SBC that fits into all your
needs for that specific project. SBCs are ready made and available in the market at cheap
prices as compared to desktops and computers.
iv. The types of SBCs commonly available in the market are Raspberry Pis, Arduino,
Beagleboard and Qualcomm DragonBoard 410c.
IoT Software
A overview of IoT Softwares are-
1. C & C++: The C programming language has its roots in embedded systems—it even got
its start for programming telephone switches. It’s pretty universal, it can be used almost
everywhere and many programmers already know it. C++ is the object-oriented version of C,
which is a language popular for both the Linux OS and Arduino embedded IoT software
systems. These languages were basically written for the hardware systems, which makes
them so easy to use.
2. Java: While C and C++ are hardware specific, the code in JAVA is more portable. It is
more like a write once and read anywhere you want.
3. Python: There has been a recent surge in the number of python users and has now become
one of the “go-to” languages in Web development. It is slowly spreading to the embedded
control and IoT world—specially the Raspberry Pi processor. Python is an interpreted
language, which is, easy to read, quick to learn and quick to write. Also, it’s a powerhouse for
serving data-heavy applications.
4. B#: Unlike most of the languages mentioned so far, B# was specifically designed for
embedded systems having less memory size.
Arduino
i. Arduino is an open-source hardware and software company that designs and manufactures
single-board microcontrollers and microcontroller kits.
ii. In Arduino, each board has clear markings on the connection pins, sockets and in-circuit
connections. Thus, Arduino boards are easy to work for DIY (do-it-yourself) and simplify the
prototyping of embedded platforms for IoTs.
iii. The Arduino Integrated Development Environment or Arduino Software (IDE) are open
source for easy to program.
2
iv. Uno is most used and documented board of the whole Arduino family at present. The
board’s analog input pins and PWM pins can connect sensors, actuators and analog circuits.
The board’s digital I/O pins can connect On-Off states, set of On-Off states, digital inputs
from sensors, digital outputs to actuators and other digital circuits.
v. A board with a shield inserted into it makes a wireless connection to a ZigBee, Bluetooth
LE, WiFi, GSM, or RF module or a wired connection to Ethernet LAN for the Internet.
vi. Development boards for IoT devices are the Arduino Ethernet, Arduino Wi-Fi and
Arduino GSM shields. Development boards for the wearable devices are Arduino Gemma,
LilyPad, LilyPad Simple/SimpleSnap and LilyPad USB.
Figure 8.2 shows architecture of Arduino Fio board with Ethernet shield.
Arduino types
Arduino Uno (R3), Arduino Nano, Arduino Micro, Arduino Due, LilyPad Arduino Board,
Arduino Bluetooth, Arduino Fio, Arduino Diecimila, RedBoard Arduino Board, Arduino
Mega (R3) Board Arduino Leonardo Board, Arduino Robot, Arduino Esplora, Arduino Pro
Mic Arduino Ethernet, Arduino Zero, Fastest Arduino Board
https://www.elprocus.com/different-types-of-arduino-boards/
https://www.elprocus.com/different-types-of-arduino-boards/
Raspberry Pi
Raspberry Pi is a low-cost mini-computer with the physical size of a credit card. Raspberry Pi
runs various flavours of Linux and can perform almost all tasks that a normal desktop
computer can do, In addition, Raspberry Pi also allows interfacing sensors and actuators
through the general purpose I/O pins. Since Raspberry Pi runs Linux operating system, it
supports Python "out of the box".
The different types of raspberry pi models are following
Raspberry Pi 1 model B
Raspberry Pi 1 model A
Raspberry Pi 1 model B+
Raspberry Pi 1model A+
3
Raspberry Pi Zero
Raspberry Pi 2
Raspberry Pi 3 model B
Raspberry Pi Zero W
i. Raspberry Pi is based on an ARM processor. The latest version of Raspberry Pi (Model B, Revision 2)
comes with 700 MHz Low Power ARM 1176JZ-F processor and 512 MB SDRAM,
ii. USB Ports : Raspberry Pi comes with two USB 2.0 ports. The USB ports on Raspberry Pi can provide a
current upto 100mA. For connecting devices that draw current more than 100mA an external USB
powered hub is required.
iii. Ethernet Ports : Raspberry Pi comes with a standard RJ45 Ethernet port. You can connect an
Ethernet cable or a USB Wifi adapter to provide Internet connectivity.
iv. HDMI Output : The HDMI port on Raspberry Pi provides both video and audio output. You can
connect the Raspberry Pi to a monitor using an EIDMI cable.
v. Composite Video Output : Raspberry Pi comes with a composite video output.
vi. Audio Output : Raspberry Pi has a 3.5mm audio output jack. The audio quality from this jack is
inferior to the HDMI output.
vii. GPIO Pins : Raspberry N comes with a number of general purpose input output pins. There are four
types of pins on Raspberry Pi - true GPIO pins. I2C interface pins, SPI interface pins and serial Rx and Tx
pins.
4
a. Serial: The serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins for
communication with serial peripherals.
b. SPI: Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for communicating with
one or more peripheral devices. In an SPI connection, there is one master device and one or more
peripheral devices. There are five pins on Raspberry Pi for SPI interface:
MISO (Master In Slave Out) : Master line for sending data to the peripherals.
MOSI (Master Out Slave In) : Slave line for sending data to the master.
SCI (Serial Clock) : Clock generated by master to synchronize data transmission
CEO (Chip Enable 0) : To enable or disable devices.
CEO (Chip Enable 1) : To enable or disable devices,
c. I2C: The. 12C interface pins on Raspberry Pi allow you to connect hardware modules. 12C interface
allows synchronous data transfer with just two pins - SDA (data line) and SCL (clock line).
viii. Display Serial Interface (1351) The DSI interface can be used to connect an LCD panel to
Raspberry Pi.
ix. Camera Serial interface (CSI) : The CSI interface can be used to connect a camera module to
Raspberry Pi.
x. Status LEDs : Raspberry Pi has live status LEDs, Table 7.1 lists Raspberry Pi status LEDs and their
functions.
xi. SD Card Slot : Raspberry Pi does not have a built in operating system and storage. You can plug-in
an SD card loaded with a Linux image to the SD card slot. Appendix-A provides instructions on setting up
New Out-of-the-Box Software (NOOBS) on Raspberry Pi. You will require at least an 80H SD card
for setting up NOOBS,
xii. Power Input : Raspberry Pi has a micro-USB connector for power input.
Application Processors – High-end processors for mobile computing, smart phone, servers,
etc. These processors run at higher clock frequency (over 1GHz), and support Memory
Management Unit (MMU), which is required for full feature OS such as Linux, Android, MS
Windows and mobile OSs. If you are planning to develop a product that requires one of these
OSs, you need to use an application processor.
5
Microcontroller Processors – These processors are usually designed to have a much lower
silicon area, and much high-energy efficiency. Typically, they have shorter pipeline, and
usually lower maximum frequency (although you can find some of these processors running
at over 200MHz). At the same time, the newer Cortex-M processor family is designed to be
very easy to use; therefore, they are very popular in the microcontroller and deeply embedded
systems market.
Today, there are eight members in the ARM Cortex-M processor family. Different processors
can have different instruction set support, system features and performance.
Cortex-M0 A very small processor (starting from 12K gates) for low cost, ultra-low power
microcontrollers and deeply embedded applications.
Cortex-M0+ The most energy-efficient processor for small embedded system. Similar size
and programmer’s model to the Cortex-M0 processor, but with additional features like single
cycle I/O interface and vector table relocations.
6
Cortex-M1 A small processor design optimized for FPGA designs and provides Tightly
Coupled Memory (TCM) implementation using memory blocks on the FPGAs. Same
instruction set as the Cortex-M0.
Cortex-M3 A small but powerful embedded processor for low-power microcontrollers that
has a rich instruction set to enable it to handle complex tasks quicker. It has a hardware
divider and Multiply-Accumulate (MAC) instructions. In addition, it also has comprehensive
debug and trace features to enable software developers to develop their applications quicker.
Cortex-M4 It provides all the features on the Cortex-M3, with additional instructions target
at Digital Signal Processing (DSP) tasks, such as Single Instruction Multiple Data (SIMD)
and faster single cycle MAC operations. In addition, it also have an optional single precision
floating point unit that support IEEE 754 floating point standard.
Cortex-M7 High-performance processor for high-end microcontrollers and processing
intensive applications. It has all the ISA features available in Cortex-M4, with additional
support for double-precision floating point, as well as additional memory features like cache
and Tightly Coupled Memory (TCM).
Programmer’s Model
1. Operation Modes and States
i. The Cortex-M0 processor has two operation modes (Thread mode or the Handler mode)
and two states (Thumb and Deburg stated) as in the Figure 5.
ii. When the processor is running a program, it is in the Thumb state. In this state, it can be
either in the Thread mode or the Handler mode. Both modes are almost the same. The only
difference is Thread mode have a special register called CONTROL.
7
iii. The Debug state is used for debugging operation only. Halting the processor, stops the
instruction execution and enter debug state. This state allows the debugger to access or
change the processor register values.
iv. The debugger can access system memory locations in either the Thumb state or the Debug
state.
v. When the processor is powered up, it will be running in the Thumb state and Thread mode
by default.
2. Registers and Special Registers
i. To perform data processing and controls, a number of registers are required inside the
processor core. The data have to be loaded from the memory to a register in the register bank
then processed inside the processor, and then written back to the memory if needed. This is
commonly called as “load-store architecture.”
ii. By having a sufficient number of registers in the register bank, this mechanism is easy to
use. The register bank contains sixteen 32-bit registers. 13 are general-purpose registers,
remaining have special uses as shown in the Figure 6.
8
R15, Program Counter (PC): R15 is the Program Counter. It is readable and writeable. Call
the Program Counter, using either “R15” or “PC,” in either upper or lower case (e.g., “r15” or
“pc”).
xPSR, combined Program Status Register
The combined Program Status Register provides information about program execution and
the ALU flags. It is consists of the following three Program Status Registers (PSRs) as in
Figure 7:
• Application PSR (APSR): Contains the ALU flags: N (negative flag), Z (zero flag), C (carry
or borrow flag), and V (overflow flag). These bits are at the top 4 bits of the APSR.
• Interrupt PSR (IPSR): Contains the current executing interrupt service routine (ISR)
number.
• Execution PSR (EPSR): Contains the T-bit, which indicates that the processor is in the
Thumb state.
Figure 8: xPSR
Figure 9: PRIMASK
9
CONTROL: Special Register
i. Physically there are two stack pointers in the Cortex-M0 processor, but only one of them is
used at one time, depending on the current value of the CONTROL register as shown in the
Figure 10.
ii. After reset, the main stack pointer (MSP) is used, but can be switched to the process stack
pointer (PSP) in Thread mode by setting bit [1] in the CONTROL register as shown in the
Figure 11.
iii. During running of an exception handler (when the processor is in Handler mode), only the
MSP is used, and the CONTROL register reads as zero.
iv. Bit 0 of the CONTROL register is reserved to maintain compatibility with the Cortex-M3
processor.
10
Figure 12: Memory map
Stack Memory Operations
Stack memory is a memory usage mechanism that allows the system memory to be used as
temporary data storage. The main element of stack memory operation is a register called the
stack pointer. The stack pointer is adjusted automatically each time a stack operation is
carried out. In common terms, storing data to the stack is called pushing (using the PUSH
instruction) and restoring data from the stack is called popping (using the POP instruction) as
shown in the Figure 13.
11
program code called the exception handler. After the exception handler is completed, it will
then resume the normal program execution.
ii. There are various types of exceptions. Interrupts are a subset of exceptions. They are 32
external interrupts (commonly referred as interrupt request, IRQs) and an additional special
interrupt called the nonmaskable interrupt (NMI).
iii. The exception handlers for interrupt events are commonly known as interrupt service
routines (ISRs).
Interrupt Masking
The NVIC in the Cortex-M0 processor provides an interrupt masking feature via the
PRIMASK special register. This can disable all exceptions except hard fault and NMI (non-
maskable interrupt, hardware failure). This masking is useful for operations that should not
be interrupted such as time critical control tasks.
Block Diagram
i. A simplified block diagram of the Cortex-M0 is shown in Figure 14. The processor core
contains the register banks, ALU, data path, and control logic. It is a three stage pipeline
design with fetch stage, decode stage, and execution stage. The register bank has sixteen 32-
bit registers. A few registers have special usages.
ii. The Nested Vectored Interrupt Controller (NVIC) accepts up to 32 interrupt request signals
and a non-maskable interrupt (NMI) input.
iii. It contains the functionality required for comparing priority between interrupt requests
and the current priority level so that nested interrupts can be handled automatically.
12
iv. If an interrupt is accepted, it communicates with the processor so that the processor can
execute the correct interrupt handler. The Wakeup Interrupt Controller (WIC) is an optional
unit.
iv. In low-power applications, the microcontroller can enter standby state with most of the
processor powered down. In this situation, the WIC can perform the function of interrupt
masking.
v. When an interrupt request is detected, the WIC informs the power management to power
up the system so that the NVIC and the processor core can then handle the rest of the
interrupt processing. The debug subsystem contains various functional blocks to handle
debug control, program breakpoints, and data watch points.
vi. The serial wire protocol is a newer communication protocol that only requires two wires,
but it can handle the same debug functionalities as JTAG (Joint Test Action Group). The
internal bus system, the data path in the processor core, and the AHB LITE bus interface are
all 32 bits wide.
vii. AHB-Lite is an on-chip bus protocol used in many ARM processors. This bus protocol is
part of the Advanced Microcontroller Bus Architecture (AMBA) specification, a bus
architecture developed by ARM that is widely used in the IC design industry.
13
CHAPTER 5
Instruction Set
Instruction decode
format selection
.----------a
ARM
Incoming Execution
instruction
Instructions stage
decoder
Thumb remap
to ARM
T bit (0 = ARM,
1 = Thumb)
Figure 5.1:
ARM7TDMI design supports both ARM and the Thumb instruction set.
Thumb code provides a code size reduction of approximately 30% compared to the equivalent
ARM code. However, it has some impact on the performance and can reduce the performance
by 20%. On the other hand, in many applications, the reduction of program memory size and
The Definitive Guide to the ARM Cortex-MO. DOI: 10.1016/B978-0-12-385477-3.10005-9
Copyright © 2011 Man Cheung Joseph Yiu. Published by Elsevier Joe. All rights reserved.
73
Additional data
Embedded Systems
An Embedded System is a computer system that has computer hardware and software
embedded to perform specific tasks. In contrast to general purpose computers or personal
computers (PCs)' wbich can perform various types of tasks, embedded systems are designed
to perform a specific set of tasks. Key components of an embedded system include.
microprocessor or microcontroller, memory (RAM, ROM, cache), networking units
(Etllemet, WiFi adapters), input/output units (display, keyboard, etc.) and storage (such as
Hash memory). Some embedded systems have specialized processors such as digital signal
processors (DSPs), graphics processors and application specific processors. Embedded
systems run embedded operating systems such as real-time operating systems (RTOS).
Embedded systems range from low-cost miniaturized devices such as digital watches to
devices such as digital cameras, point of vending machines, appliances (such as washing
machines), etc.