Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Prepared by: Mr. Enoch N [DTC] & Mr. Shiju G [NEC] Verified by: Mr. Surendhar Kumar K Approved by: Mr. Shankar G Rev No : 01 Released Date : 01/09/2021
CP15 SEMESTER 5 Embedded Systems & IOT
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 1
Contents 1.0 EMBEDDED SYSTEM ...................................................................................................................................... 2
1.1 Introduction, Categories, Applications, Specialities of Embedded system ........................................................... 2
1.2 Overview of Embedded System Architecture ....................................................................................................... 9
1.3 Special Features: Power on reset feature, Watch dog timer, SLEEP mode, Interrupt handling capability. ....... 12
2.0 PERIPHERAL INTERFACE CONTROLLER – PIC16F877A .................................................................................... 18
2.1 Introduction to PIC Microcontroller .................................................................................................................... 18
2.2 Features of PIC16F877 ......................................................................................................................................... 19
2.3 Architecture of PIC 16F877A ............................................................................................................................... 21
2.4 Memory organization .......................................................................................................................................... 26
2.5 Pin Diagram ......................................................................................................................................................... 34
2.6 Input/Output Ports ............................................................................................................................................. 38
2.7. Timers ................................................................................................................................................................. 41
3.0 NODE MCU - ESP8266 ................................................................................................................................. 54
3.1 Introduction to Node MCU and Its Features. ...................................................................................................... 54
3.2 Pin configuration of NODE MCU. ........................................................................................................................ 56
4.0 NODE MCU AND ARDUINO PROGRAMMING ................................................................................................ 59
4.1 Introduction to Arduino and Its Features ............................................................................................................ 59
4.2 Variables, Data Types & Constants...................................................................................................................... 63
4.3 Programming Structure ....................................................................................................................................... 68
4.4 Digital I/O Programming ...................................................................................................................................... 69
4.5 Analog I/O Programming ..................................................................................................................................... 73
4.6 Serial Data Monitoring ........................................................................................................................................ 77
5.0 IoT (Internet of Things)................................................................................................................................ 80
5.1 Internet of Things (IoT) ........................................................................................................................................ 80
5.2 Components of IoT .............................................................................................................................................. 84
5.3 Four Stages of IoT Architecture ........................................................................................................................... 89
5.4 Architecture of IoT............................................................................................................................................... 92
5.5 Industrial IoT – Process, Advantages & Applications ........................................................................................ 101
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 2
1.0 EMBEDDED SYSTEM
1.1 Introduction, Categories, Applications, Specialities of Embedded system
Introduction
An Embedded Systems are computing devices that do a specific focused job. An
embedded system is a microprocessor- or microcontroller-based system of hardware and
software designed to perform dedicated functions within a larger mechanical or
electrical system.
Embedded systems are computing systems with tightly coupled hardware and
software integration, that are
designed to perform a dedicated
function.
The word embedded reflects
the fact that these systems are
usually an integral part of a larger
system. Multiple embedded
systems can coexist in an large
functional system.
Appliances such as Air
conditioners, DVD players, fax
machines, printers, mobile phones
etc, are examples of Embedded
Systems.
Embedded systems are characterized by some special features as listed below
They are task specific. They do the same task repeatedly /continuously over their lifetime. An mp3 player will function only as an mp3 player.
Embedded systems have very limited resources.
They are created to perform the task within a certain time frame. It must therefore
perform fast enough. A car’s brake system, if exceeds the time limit, may cause
accidents.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 3
They have minimal or no user interface (UI). A fully automatic washing machine works on its own after the programme is set and stops once the task is over.
Embedded systems are built to achieve certain efficiency levels. They are small sized, can work with less power.
Embedded systems cannot be changed or upgraded by the users. Hence, they must very reliable and stable. They are expected to function for long durations without the user experiencing any difficulties. For example refrigerator.
Categories of Embedded Systems
Embedde systems are categorized
based on :
a. Performance and functional
requirements.
b. Performance of microcontroller.
We will limit our discussion to types of
embedded systems based on functional
requirements.
1. Stand-alone embedded systems: As the name implies, stand-alone systems
work in stand-alone mode. They take inputs, process them and produce the desired
output. The input can be electrical signals from transducers or command from a human
being such as the pressing of a button. The output can be electrical signals to drive
another system, an LED display or LCD display for displaying of information to the users.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 4
Embedded systems used in process control, automobiles, consumer electronic items etc.
fall into this category. In a process control system, the inputs are from sensors that convert
a physical entity such as temperature or pressure into its equivalent electrical signal. These
electrical signals are processed by the system and the appropriate electrical signals are
produced using which an action is taken such as opening a valve.
Some more examples: Microwave ovens, Digital cameras, Mp3 players, Video game consoles, Temperature measurement systems.
2. Real - time systems: Embedded systems in which some specific work has to be done
in a specific time period are called Real time systems. Real-time embedded systems have
to complete a specific task in a specified time period. Meeting the deadlines is the most
important requirement of real-time systems. To develop the real-time embedded system
we require timing analysis, multitasking design, debugging, cross-platform testing and
architecture design. In these systems, quick response is very important.
For example, consider a system that has to open a valve within 30 milliseconds
when the humidity crosses a particular threshold. If the valve is not opened within 30
milliseconds, the equipment may get damaged.
Examples : Controlling heat, elevators, lights, and doors in buildings Robots Traffic control system including railway tracks, airspace, shipping lines Radio, satellite and telephone communication Patient monitoring system Radiation therapy system in the hospital Computer games Multimedia systems consisting of video, audio, text and graphics interfaces Military usage that includes tracking, weapons, and command & control
Real-time systems are categorized as
a. Hard real-time systems.
b. Soft real-time systems.
a. Hard real-time systems: In hard real-time
systems, missing a deadline may lead to a
catastrophe.
A missile that has to track and intercept an
enemy aircraft. The missile contains an embedded system that tracks the aircraft and
generates a control signal that will launch the missile. If there is a delay in tracking the
aircraft and if the missile misses the deadline, the enemy aircraft may drop a bomb and
cause loss of many lives. Hence, this system is a hard real-time embedded system.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 5
b. Soft real-time systems: In soft real-time systems,
meeting the deadline is important but missing the
deadline will not lead to a catastrophe. In some
embedded systems, deadlines are imposed, bur not
adhering to them once in a while may not lead to
catastrophe.
For example, consider a DVD player. Suppose, you give a command to the DVD
player from a remote control, and there is a delay of a few milliseconds in executing that
command. But this delay won't lead to a serious implication. Such systems are called soft
real-time systems.
3. Networked information appliances: Embedded systems that are provided with
network interfaces and accessed through networks such as Local Area Network or the
Internet are called networked information appliances. Such embedded systems are
connected to a network, typically using TCP/IP (Transmission Control Protocol/ Internet
Protocol) protocol, such as the Internet or a Intranet. These systems have emerged in
recent years.
These systems communicate with other nodes in the network.
Example 1: A networked process control system consists of a number of embedded
systems connected as a Local Area Network. Each embedded system can send real-time
data to a central location from where the entire process control system can be monitored.
The monitoring can be done using a web browser such as the Internet Explorer
Example 2: A web camera can be connected to the Internet. The web camera send
pictures in real-time to any computer connected to the internet. In such a case, the web
camera has to run the HTTP server software in addition to the TCP/IP protocol stack.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 6
Example 3: The door-lock of your home can be a small embedded system with TCP/IP and
HTTP server software running on it. When your children stand in front of the door-lock
after they return from school, the web camera in the door-lock will send an alert to your
desktop over the Internet and then you can open the door-lock through a click of the
mouse.
4. Mobile Devices: Mobile devices such as mobile
phones, Personal Digital Assistants (PDAs), smart phones
etc. are special category of embedded systems. Though the
PDAs do many general-purpose tasks, they need to be
designed just like the 'conventional' embedded systems.
The limitations of the mobile devices are memory
constraints, small size, lack of good user interfaces. Hence,
mobile devices are considered as embedded systems. However, the PDAs are now capable
of supporting general-purpose application software such as word processors, games, etc.
Application Areas
Nearly 99% of the processors manufactured end up in embedded systems. The embedded
system market is one of the highest growth areas as these systems are used in very market
segments like consumer electronics, office automation, industrial automation, biomedical
engineering. wireless communication, data communication, telecommunications,
transportation, military and so on.
Consumer appliances: At home we use a number of
embedded systems which include digital camera,
digital diary, DVD player, electronic toys, microwave
oven, remote controls for TV and air-conditioner, VCD
player, video game consoles, video recorders etc.
Industrial automation: Today a lot of industries
use embedded systems for process control. These
include pharmaceutical, cement, sugar, oil
exploration, nuclear energy, electricity generation
and transmission. The embedded systems for
industrial use are designed to carry out specific
tasks such as monitoring the temperature,
pressure, humidity, voltage, current etc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 7
Wireless technologies: Advances in mobile
communications are paving way for many interesting
applications using embedded systems. The mobile phone is
one of the marvels of the last decade of the 20h century. lt
is a very powerful embedded system that provides voice
communication while we are on the move. The Personal
Digital Assistants and the palmtops can now be used to
access multimedia services over the Internet.
Office automation: The office automation products
using embedded systems are copying machine, fax
machine, key telephone, modem, printer, scanner etc.
Instrumentation: Testing and measurement are the
fundamental requirements in all scientific and engineering
activities. The measuring equipment we use in laboratories
to measure parameters such as weight, temperature,
pressure, humidity, voltage, current etc. are all embedded
systems.
Security: Security of persons and information has always
been a major issue. We need to protect our homes and
offices; and also, the information we transmit and store.
Developing embedded systems for security applications is
one of the most lucrative businesses nowadays. Security
devices at offices, airports etc. for authentication and
verification are embedded systems.
Finance: Financial dealing through cash and cheques are now
slowly paving way for transactions using smart cards and ATM
(Automatic Teller Machine) machines. Smart card, of the size
of a credit card, has a small micro-controller and memory; and
it interacts with the smart card reader/ATM machine and acts
as' an electronic wallet. Smart card technology has the
capability of ushering in a cashless society.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 8
Medical electronics: Almost every medical equipment in
the hospital is an embedded system. These equipment's
include diagnostic aids such as ECG, EEG, blood pressure
measuring devices, X-ray Scanners equipment used in
blood analysis, radiation, colonoscopy, endoscopy etc.
Telecommunications: In the field of telecommunications, the embedded systems can be
categorized as subscriber terminals and network equipment. The subscriber terminals such
as key telephones, ISDN phones, terminal adapters, web cameras are embedded systems
Computer networking: Computer networking products such as bridges, routers,
Integrated Services Digital Networks (ISDN), Asynchronous Transfer Mode (ATM), and
frame relay switches are embedded systems which implement the necessary data
communication protocols.
Specialities of Embedded Systems
Performance: Many embedded systems have time constraints.
For instance, in a process control system, a constraint can be: "if the temperature exceeds
40 degrees, open a valve within 10 milliseconds." The system must meet such deadlines.
If the deadlines are missed, it may result in a catastrophe.
You can imagine the damage that can be done if such deadlines are not met in a safety
system of a nuclear plant.
Power Consumption: Most of the embedded systems operate through a battery. To
reduce the battery drain and avoid frequent recharging of the battery, the power
consumption of the embedded system has to be very low.
Cost: For embedded systems used in safety applications of a nuclear plant or in a space
craft, cost may not be a very important factor. However, for embedded systems used in
consumer electronics or office automation, the cost is of utmost importance.
Size: Size is certainly a factor for many embedded systems. We do not like a mobile phone
that has to be carried on our backs. The size and the weight are important parameters in
embedded systems used in aircraft, spacecraft, missiles etc.
Limited User Interface: Unlike desktops, which have full-fledged input/output devices,
embedded systems do not have sophisticated interfaces for input and output. Some
embedded systems do not have any user interface at all. They take electrical signals as
input and produce electrical signals as output.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 9
Software Upgradation Capability: Embedded systems are meant for a very specific task.
So, once the software is transferred to the embedded system, the same software will run
throughout its life.) However, in some cases, it may be necessary to upgrade the software.
1.2 Overview of Embedded System Architecture
In a computer system, the operating system
runs above the hardware, and the application
software runs above the operating system. In case of
embedded systems, it is not compulsory to have an
operating system. For small appliances such as
remote-control units, air-conditioners, toys etc.,
there is no need for an operating system and you can
write only the software specific to that application.
A. Hardware architecture
Building Blocks of the Hardware in an Embedded
System
I/O Devices: Input and output devices allow the embedded system to interact with the
outside world by moving data into and out of the system. An input device is used to bring
data into the system.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 10
ADC & DAC: ADC conversion involves two steps Sampling and Quantization. The analog
signal sampled at regular interval and the sampled values are rounded off to fixed number
of levels called quantization levels. These quantization values are converted into bit
stream.
Power Supply Unit: The power supply unit is used to provide a stable DC voltage for the
embedded systems. Some embedded systems use batteries as power source.
Clock Circuitory: The processor has to be given the clock input to one of the pins. All
processor events are related to the clock .The higher the clock frequency the higher the
speed.
Chip Select: Many peripheral share a common bus .The process must be able to uniquely
identify a peripheral to communicate with it. The processor performs this identification
using a signal called chip select. The select signal is available to all the peripheral
connected to the bus.
Watch Dog Timer: Watch dog timer is used to reset the processor automatically. It does
not receive a signal periodically from the processor indicating its heating status. This
mechanism obviates the need for a rest button on the embedded system.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 11
Communication Interface: The communication channel which interconnects the various
components within an embedded product is referred as communication interface.
Examples – Serial interfaces like I2C,I-Wire, and parallel bus interface.
Timers: A timer is a specialized type of clock which is used to measure time intervals. A
counter is a device that stores (and sometimes displays) the number of times a particular
event or process occurred, with respect to a clock signal.
Memory: The memory is categorized as Random Access Memory(RAM) and ROM. The
contents of RAM will be erased it power is switched off to the chip. Where as Rom retains
the contents even if the power is switched off. So the firm ware is stored in the ROM.
When the power is switched On , the processor read, ROM, the program is transferred to
the RAM and the program is executed.
B. Software architecture
The software in an embedded system consists of an operating system and the
application software. The operating system is optional; if it is not present, you need to
write your own software routines to access the hardware.
Categories of Embedded Operating Systems
a. Non-real-time Embedded Operating Systems.
b. Real-time Operating Systems.
c. Mobile/Handheld Operating Systems.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 12
Kernel: Kernel manages the tasks to achieve the
desired performance of the embedded system. To
manage the tasks, the important requirements are
to schedule the tasks and to provide inter-task
communication facilities
Device Manager: The I/O devices are used to
send/receive data from the embedded system. The
OS manages the I/O devices through interrupts and device drivers. Device drivers provide
the necessary interface between the application and the hardware.
Communication Protocol Software: If the embedded system has communication
interfaces such as Ethernet, USB etc., the-upper layer protocols such as TCP/IP stack need
to be integrated with the OS. Then the embedded system can be network-enabled.
Libraries: The operating system may have some C/C++ library files in object code, which
can be used through the API calls.
File System: Most of the embedded systems do not have a secondary storage. In such
cases, the ROM is used to store the program. In case a file system is required, a small file
system can be developed on flash memory. Some embedded systems may use a secondary
storage just for booting
1.3 Special Features: Power on reset feature, Watch dog timer, SLEEP mode, Interrupt handling capability.
Power On Reset: A power-on reset (PoR) is a circuit that provides a predictable,
regulated voltage to a microprocessor or
microcontroller with the initial application
of power. The PoR system ensures that the
microprocessor or microcontroller will start
in the same condition every time it is
powered up. A power-on-reset circuit is
responsible for generating resetting signals
whenever power is supplied to a given
electrical device. In such manner, you can
determine a known state in which the device always powers up or starts operating.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 13
A power on reset circuit ensures the
system power supply stabilizes at the
correct levels, the clocks of the processors
settle accurately, and that the loading of
the internal registers is complete before
the device actually starts working or gets
powered up. The time period of the reset
state is determined and measured using
the charging of a capacitor which is placed
in series with a resistor. When power is
applied, the current goes via the capacitor
and the voltage of capacitor increases
slowly. At the beginning, the voltage is lower than the reset input pin threshold voltage
and all elements in the CPU are hold in reset mode. And then, the voltage is higher than
that threshold voltage, the reset pin gets a “1” and the system initializes. The values of the
resistor and capacitor determine the power on reset latency.
A power on reset circuit also has good noise immunity which means that in the case that a
power supply suffers a minor glitch that passes by quickly enough
Watch Dog Timer: Sometimes a system goes into an infinite loop (hangs). A watchdog
timer is a specialized timer module that helps a microprocessor to recover from such
situations. It is a counter running
on its own. If a watchdog timer
reaches the end of its counting
period, it resets the entire
processor system. In order to
prevent this, a processor must
perform some type of specific
action that resets the watchdog.
Thus, a watchdog timer can be
configured such that it will reach
the end of its counting period
only if a processor failure has occurred, and by forcing a system reset, the watchdog timer
helps the processor to escape from the failure mode and continue normal operation.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 14
Microcontrollers are often used in harsh
environments where power supply
transients, electromagnetic interference
(EMI), and electrostatic discharge (ESD)
are abundant. Program corruption
caused by bus corruption and
electromagnetic discharges can cause a
microprocessor to execute erroneous
instructions. In these environments, a
watchdog timer is a useful peripheral that
can help catch and reset a microcontroller
that has gone "out of control."
The primary application of a
watchdog timer is as a system monitor to
detect and reset an "out of control"
microcontroller. When program execution
goes awry it will not properly execute the
code that restarts the watchdog. In such a
case the watchdog timer will timeout and
cause a microcontroller reset.
SLEEP mode: The term “sleep mode” (sometimes called “power down mode”) refers to a
condition in which an embedded system enters a low-power mode. Typically, the
microcontroller (MCU) ceases to perform any computations, although it will retain any
current data, and peripheral functions
will stop working.
In reality, the processor or
microcontroller will still continue to
run in sleep mode insofar as
maintaining its ability to wake up to
handle interrupts and real time tasks.
A common example of sleep mode is
used in our computers or laptops.
When you lock out your PC, the
system will go into sleep and suspend any unwanted tasks to save power.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 15
A wide range of embedded systems, such as smart phones, washing machines, and
ATMs, have the ability to run in a power-down state to use the CPU resources efficiently.
Sleep mode is often employed
by microcontrollers that need
the ability to wake up and
respond to unexpected events.
Sleep mode maybe referred to
as standby mode in some cases.
The primary task to achieve
standby mode is to power off
the peripheral blocks in microcontrollers. For instance, you can switch off the I/O
(input/output peripherals) to reduce power consumption.
Interrupt Handling Capability: An interrupt is a signal to the processor emitted by
hardware or software indicating an event that needs immediate attention. Whenever an
interrupt occurs, the controller completes the execution of the current instruction and
starts the execution of an Interrupt Service Routine (ISR) or Interrupt Handler. ISR tells the
processor or controller what to do when the interrupt occurs. The interrupts can be either
hardware interrupts or software interrupts.
a. Hardware Interrupt: A hardware interrupt is an electronic alerting signal sent to the processor from an external device, like a disk controller or an external peripheral. For example, when we press a key on the keyboard or move the mouse, they trigger hardware interrupts which cause the processor to read the keystroke or mouse position.
b. Software Interrupt: A software interrupt is caused either by an exceptional condition or a special instruction in the instruction set which causes an interrupt when it is executed by the processor. For example, if the processor's arithmetic logic unit runs a command to divide a number by zero, to cause a divide-by-zero exception, thus causing the computer to abandon the calculation or display an error message. Software interrupt instructions work similar to subroutine calls.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 16
Interrupt Service Routine: For every interrupt, there must be an interrupt service routine (ISR), or interrupt handler. When an interrupt occurs, the microcontroller runs the interrupt service routine. For every interrupt, there is a fixed location in memory that holds the address of its interrupt service routine, ISR. The table of memory locations set aside to hold the addresses of ISRs is called as the Interrupt Vector Table.
Steps to Execute an Interrupt
When an interrupt gets active, the microcontroller goes through the following steps −
• The microcontroller closes the currently executing instruction and saves the address
of the next instruction (PC) on the stack.
• It also saves the current status of all the interrupts internally (i.e., not on the stack).
• It jumps to the memory location of the interrupt vector table that holds the address
of the interrupts service routine.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 17
• The microcontroller gets the address of the ISR from the interrupt vector table and
jumps to it. It starts to execute the interrupt service subroutine, which is RETI
(return from interrupt).
• Upon executing the RETI instruction, the microcontroller returns to the location
where it was interrupted. First, it gets the program counter (PC) address from the
stack by popping the top bytes of the stack into the PC. Then, it starts to execute
from that address.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 18
2.0 PERIPHERAL INTERFACE CONTROLLER – PIC16F877A
2.1 Introduction to PIC Microcontroller
The PIC microcontroller PIC16f877A is one of the most renowned microcontrollers in the industry. This microcontroller is very convenient to use, the coding or programming of this controller is also easier. One of the main advantages is that it can be write-erase as many times as possible because it uses FLASH memory technology. It has a total number of 40 pins and there are 33 pins for input and output. PIC16F877A is used in many PIC microcontroller projects. PIC16F877A also have much application in digital electronics circuits.
PIC stands for Peripheral Interface Controller. PIC micro-controller was developed by Microchip. This micro-controller is a very fast simple micro-controller in implementation and performance point of view. This micro-controller is easy to program and also it easy to interface with other peripherals. Every PIC microcontroller architecture consists of some registers and stack where registers function as Random Access Memory (RAM) and stack saves the return addresses. The main features of PIC microcontrollers are RAM, flash memory, Timers/Counters, EEPROM, I/O Ports, USART, CCP (Capture/Compare/PWM module), SSP, Comparator, ADC (Analog to digital converter), PSP (parallel slave port), LCD and ICSP (in circuit serial programming) The 8-bit PIC microcontroller is classified into four types on the basis of internal architecture such as Base Line PIC, Mid-Range PIC, Enhanced Mid-Range PIC and PIC18. Why PIC PIC16F877A Microcontroller?
Availability of resource: When you start your project, after framing the working logic when you look for controllers you end up with 8051 or PIC. Again if you try to constrain you will end up with PIC.
Money: It is cheaper. You can get it for less than Rs.100. You can get 8051 controller also for less than Rs.100. Both are easily available in most of the electronics stores.
Architecture/PIN configuration: You can configure the functions of PIN based on your requirement.
Tool: This is one the most important fact. When you have an IC and you don’t have resource to program it, then it is waste buying at low cost. Both 8051 and PIC tools are easily available on the internet and also easy to use for the beginners.
Dumper kits: After programming in the tool, it is very important that we should be able to dimp the program into the IC. The dumper kits are easily available in market for these two.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 19
Knowledge: The knowledge transfer can be easily done for this. Either your senior or any professor will able to help you in this regard very easily with their past experience and your project can be completed easily.
Programming: Both these IC can be programmed in C language. Hence easy to program for the beginners.
8051 vs PIC: Most of the college projects are so simple and it does not need to worry about clock frequency, oscillator frequency, Data port width, number of ports, features like serial ports, interrupts, timers, memory etc. will make you choose between 8051 and PIC.
PIC16f877A finds its applications in a large number of devices. It is used in remote sensors, security and safety devices, home automation and many industrial instruments. An EEPROM is also featured in it, which makes it possible to store some of the information permanently like transmitter codes and receiver frequencies and some other related data. The cost of this controller is low and its handling is also easy. It is flexible and can be used in areas where microcontrollers have never been used before as in microprocessor applications and timer functions etc. Various types of microcontrollers exist, even though the best are found in the GENIE range of programmable microcontrollers. These microcontrollers are programmed and simulated by circuit-wizard software.
It has a 35 instructions set. It can operate up to 20MHz frequency. The operating voltage is between 4.2 volts to 5.5 volts. If you provide it voltage more
than 5.5 volts, it may get damaged permanently. It does not have an internal oscillator like other PIC18F46K22, PIC18F4550 series. The maximum current each PORT can sink or source is around 100mA. Therefore, the
current limit for each GPIO pin of PIC16F877A is 10mA. It is available in four IC packaging such as 40-pin PDIP 44-pin PLCC, 44-pin TQFP, 44-pin
QFN.
The PIC microcontroller architecture comprises of CPU, I/O ports, memory organization, A/D converter, timers/counters, interrupts, serial communication, oscillator and CCP module etc.
2.2 Features of PIC16F877
The PIC16FXX series has more advanced and developed features when compared to
its previous series. The important features of PIC16F877 series is given below.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 20
General Features
• High performance RISC CPU.
• ONLY 35 simple word instructions.
• All single cycle instructions except program branches which are of two cycles.
• Operating speed: clock input (200MHz), instruction cycle (200nS).
• Up to 368×8bit of RAM (data memory), 256×8bit of EEPROM (data memory), 8k×14bit of flash memory.
• Pin out compatible to PIC 16C74B, PIC 16C76, PIC 16C77.
• Eight level deep hardware stack (Up to 8 nesting subroutines).
• Interrupt capability (up to 14 sources).
• Different types of addressing modes (direct, Indirect, relative addressing modes).
• Power on Reset (POR). Power-Up Timer (PWRT) and oscillator start-up timer.
• Low power- high speed CMOS flash/EEPROM.
• Wide operating voltage range (2.0 – 5.56) volts.
• High sink/source current (25mA).
• Low power consumption (<0.6mA typical @3v-4MHz, 20µA typical @3v-32MHz and <1 A typical standby).
Peripheral Features
• Timer 0: 8-bit timer/counter with pre-scalar.
• Timer 1: 16-bit timer/counter with pre-scalar.
• Timer 2: 8-bit timer/counter with 8-bit period registers with pre-scalar and post-scalar.
• Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit).
• 10bit multi-channel (8 channels) A/D converter
• Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave).
• Universal Synchronous Asynchronous Receiver Transmitter (USART) with 9-bit address detection.
• Parallel Slave Port communication port (PSP) 8 bit wide with external RD, WR and CS controls (40/46pin).
• Brown Out circuitry for Brown-Out Reset (BOR).
• 5 input/output ports.
• 2 CCP (Capture/Compare/PWM) modules.
Special Features
• 1000000 times erase/write cycle data EEPROM memory.
• Self-programmable under software control.
• In-circuit serial programming and in-circuit debugging capability.
• Single 5V, DC supply for circuit serial programming
• WDT with its own RC oscillator for reliable operation.
• Programmable code protection.
• Power saving sleep modes.
• Selectable oscillator options.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 21
2.3 Architecture of PIC 16F877A
The basic building block of PIC 16F877A is based on Harvard architecture. Here you can see the basic internal architecture and memory organisation of PIC16F877A.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 22
The simplied version of the architecture
CPU The function of CPU in PIC is same as a normal microcontroller CPU. A PIC CPU consists
of several sub units such as instruction decoder, ALU, accumulator, control unit, etc. The CPU in PIC normally supports Reduced Instruction Set Computer (RISC) architecture (Reduced Instruction Set Computer (RISC), a type of microprocessor that focuses on rapid and efficient processing of a relatively small set of instructions. RISC design is based on the premise that most of the instructions a computer decodes and executes are simple. As a result, RISC architecture limits the number of instructions that are built into the microcontroller but optimizes each so it can be carried out very rapidly (usually within a single clock cycle). These RISC structure gives the following advantages. The RISC structure less and
simple instructions as compared to CISC.
The execution time is same for most of the instructions (except for load and store).
The execution time required is very less (5 million instructions/second (approximately).
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 23
BUS BUS is used to transfer and receive the data from one peripheral to another. It is
classified into two types such as data bus and address.
Data Bus: It is used for only transfer or receive the data.
Address Bus: Address bus is used to transmit the memory address from the peripherals to the CPU. I/O pins are used to interface the external peripherals; UART and USART both are serial communication protocols which are used for interfacing serial devices like GSM, GPS, Bluetooth, IR, etc.
Serial Communication
The transfer of one bit of data at time consecutively over a communication channel
is called Serial Communication.
There are three protocols of serial communication
USART: It stands for Universal synchronous and Asynchronous Receiver and Transmitter which provides a serial communication in two devices. In this protocol data is transmitted and received bit by bit through a single wire according to the clock pulses. To send and receive data serially the PIC microcontroller has two pins TXD and RXD.
SPI Protocol: SPI stands for Serial Peripheral Interface. It is used to send data between PIC microcontrollers and other peripherals like sensors, shift registers and SD cards. Three wire SPI communications is supported in PIC microcontroller between two devices on a common clock source. SPI protocol has greater data handling capability than that of the USART.
I2C Protocol: I2C stands for Inter Integrated Circuit, and this protocol is used to connect low speed devices like microcontrollers, EEPROMS and A/D converters. PIC microcontroller support two wire Interface or I2C communication between two devices which can work as both Master and Slave device.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 24
Parallel slave Port (PSP) PIC microcontroller offers a mechanism by which an 8 bit parallel bi- directional data
transfer can be achieved between a PIC microcontroller and a PC. PIC microcontroller’s Port D and Port E are used in this data transfer. For this data transfer Port D of PIC microcontroller is configured as a Parallel slave Port (PSP) by setting bit 4 of TRISE register. The pins of Port E function as control pins (RD, WR, and CS) for data transfer.
Capture, Compare, PWM (CCP) Module A CCP module works in the following three modes:
Capture Mode: In this mode time is captured when a signal is arrived, or we can say that, when the CCP pin goes high it captures the value of the Timer1.
Compare Mode: It works same as an Analog comparator, which means that when timer 1’s value reaches some reference value it will give an output signal.
PWM Mode: This mode provides a 10 bit resolution pulse and duty cycle that is programmable.
A/D Converter It converts the Analog voltage levels to
digital voltage values. In PIC Microcontroller, ADC has 8-channels and has resolution of 10-bit, which means that if we have to convert an Analog voltage between 0V to 5V the converter will divide it in to 2^10 levels (1024 levels). The special function registers ADCON0 and ADCON1 control the operation of ADC. The converter stores the lower 8 bits in ADRESL register and the upper bits in the ADRESH register. Reference voltage of 5V is required for the operation of the converter.
The ADC in PIC16F877A with 10 bit resolution is of Successive Approximation Type.
This is multiplexed among 8 input pins. The A/D module has high and low-voltage reference input that is software selectable to some combination of VDD, VSS, RA2 or RA3. With 5V as the Vref the resolution of PIC16F877A ADC can be determined as below:
Resolution of ADC = Vref/(2^10-1) = 5/1023 =0.004887 = 4.887mv
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 25
For the A/D converter to meet its specified accuracy, the charge holding capacitor (CHOLD) of the PIC must be allowed to fully charge to the input channel voltage level. The source impedance (RS) and the internal sampling switch impedance (RSS) directly affect the time required to charge the capacitor CHOLD. The sampling switch (RSS) impedance varies over the device voltage (VDD); The maximum recommended impedance for analog sources is 2.5 kΩ.
After the analog input channel is selected (changed), the acquisition must be done before the conversion can be started. The minimum acquisition time, for 10 bit resolution is:
A/D conversion time = 1.6µs /bit x 10 bits = 19.72µs.
Interrupts PIC16F877a has 8 interrupt sources in it. An interrupt source is some event that
generates interrupt, this source could be a timer like interrupts are generated after every 1 sec, or it could also be pin state change event, like if pin state is changed then interrupt will be generated.
So, PIC16F877a Interrupts can be generated by following 8 ways:
a. External Interrupts. b. Timer Interrupts ( Timer0 / Timer1). c. Port B State Change. d. Parallel Slave Port Read/Write. e. A/D Converter. f. Serial Receive / Transmit. g. PWM (CCP1 / CCP2). h. EEPROM Write Operation.
PIC16F877a Interrupts are associated with below 5 registers:
INTCON PIE1 PIR1 PIE2 PIR2
Reset It resets the microcontroller and is active low, meaning that it
should constantly be given a voltage of 5V and if 0 V are given then the controller is reset. Resetting the controller will bring it back to the first line of the program that has been burned into the IC.
A push button and a resistor is connected to the pin. The pin is already being supplied by constant 5V. When we want to reset the IC we just have to push the button which will bring the MCLR pin to 0 potential thereby resetting the controller.
List of Interrupts • External • Timer 0 • Timer 1 • RB Port Change • Parallel Slave Port Read/Write • A/D Converter • USART Receive • USART Transmit • Synchronous Serial Port • CCP1 (Capture, Compare, PWM) • CCP2 (Capture, Compare, PWM) • TMR2 to PR2 Match • Comparator • EEPROM Write Operation • Bus Collision
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 26
Oscillator PIN 13: OSC1/CLKIN: This is the oscillator input or the external clock input pin. PIN 14: OSC2/CLKOUT: This is the oscillator output pin. A crystal resonator is connected between pin 13 and 14 to provide external clock to the microcontroller. ¼ of the frequency of OSC1 is outputted by OSC2 in case of RC mode. This indicates the instruction cycle rate.
Oscillator unit basically is an oscillation/clock generating circuit which is used for providing proper clock pulses to the PIC chip. This clock pulses also helps the timing and counting applications. A PIC chip normally uses various types of clock generators. According to the application and the type of PIC used, the oscillators and its frequencies may vary. RC (Resistor-Capacitor), LC (Inductor-Capacitor), RLC (Resistor-Inductor-capacitor), crystal oscillators, etc. are the normal oscillators used with A PIC chip. The PIC16f877a has four oscillator modes namely LP, XT, HS, and RC.
The remaining blocks are explained in detailed in the upcoming topics.
2.4 Memory organization
The basic building block of PIC 16F877A is based on Harvard architecture. The Harvard architecture is a computer architecture with separate storage and signal pathways for instructions and data. It contrasts with the von Neumann architecture, where program instructions and data share the same memory and pathways.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 27
Because the Harvard architecture has separate program memory and data memory, it can provide greater data-memory bandwidth, making it the ideal choice for digital signal processing. Most systems designed for digital signal processing (DSP) adopt the Harvard architecture.
The Harvard architecture offers separate storage and signal buses for instructions and data. This architecture has data storage entirely contained within the CPU, and there is no access to the instruction storage as data. Computers have separate memory areas for program instructions and data using internal data buses, allowing simultaneous access to both instructions and data.
Programs needed to be loaded by an operator; the processor could not boot itself. In a Harvard architecture, there is no need to make the two memories share properties.
The memory of a PIC 16F877 chip is divided into 3 sections as shown in the below figure
a. Program memory b. Data memory c. Data EEPROM
Flash memory – In the IC No.16F877A. (F – stands fro Flash memory). This is a special type of memory where READ, WRITE, and ERASE operations can be
done many times. This type of memory was invented by INTEL corporation in 1980. A PIC Chip normally contains a certain amount of flash memory.
Program Memory The Prgram memory of PIC I6F877A is ROM memory type and this memory contains
the program (which we had written), after we've burned it. As a reminder, Program Counter executes commands stored in the program memory, one after the other.
The PIC16F87XA devices have a 13-bit program counter capable of addressing an 8K word x 14 bit program memory space. This memory is used to store the program after we burn it to the microcontroller. The PIC16F876A/877A devices have 8K words x 14 bits of Flash program memory that can be electrically erased and reprogrammed. Each time we burn program into the micro, we erase an old program and write a new one.
Program counters (PC) is used to keep the track of the program execution by holding the address of
the current instruction. The counter is automatically incremented to the next instruction during the current instruction execution.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 28
Reset vector Each time the main program execution starts at address 0000.
Interrupt vector The address 0004 is “reserved” for the “interrupt service routine” (ISR) program.
Whenever it is called (ISR) program will run.
Stack When an interrupt occurs, first the PIC microcontroller has to execute the interrupt
and the existing process address. Then that is being executed is stored in the stack. After completing the execution of the interrupt, the microcontroller calls the process with the help of address, which is stored in the stack and get executes the process.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 29
Data EEPROM (Electrically Erasable Programmable Read-Only Memory) A memory that allows storing the variables as a result of burning the written
program. Each one of them has a different role. Program Memory and Data Memory two memories that are needed to build a program, and Data EEPROM is used to save data after the microcontroller is turn off.
The data EEPROM and Flash program memory is readable and writable during normal operation (over the full VDD range). This memory is not directly mapped in the register file space.
Instead, it is indirectly addressed through the Special Function Registers. There are six SFRs used to read and write this memory:
The EEPROM data memory allows single-byte read and writes. The Flash program memory allows single-word reads and four-word block writes. Program memory write operations automatically perform an erase-before write on blocks of four words. A byte write in data EEPROM memory automatically erases the location and writes the new data (erase-before-write). The write time is controlled by an on-chip timer. The write/erase voltages are generated by an on-chip charge pump, rated to operate over the voltage range of the device for byte or word operations.
Data Memory The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the Special Function Registers. Bits RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 30
The data memory is partitioned into multiple banks which contain the General Purpose Registers (GPR) and the Special Function Registers (SFR). The lower bytes of the each bank are reserved for the Special Function Registers and above the SFRs are general purpose registers implemented as static RAM. The variables that we store in the Data Memory during the program are deleted after we turn of the microcontroller. The Number of banks in the PIC16F877A is four bank. The bits RP1 and RP0 bits of the status register are used to select these banks. Each bank extends up to 128 Bytes
General Purpose Register File: The general purpose register file is another name for the microcontroller’s RAM. Data can be written to each 8-bit location updated and retrieved any number of times.
Special Purpose Register File: The special function register file consists of input, output ports and control registers used to configure each 8-bit port either as input or output. It contains registers that provide the data input and data output to a chip resources like Timers Semi Ports and Analog to Digital converter and also the registers that contains control bits for selecting the mode of operation and also enabling or disabling its operation.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 31
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 32
Status Register The STATUS register is a 8-bit register that stores the status of the processor. This
also stores carry, zero and digit carry bits.
bit 7: IRP: Register Bank Select bit (used for indirect addressing) 0 = Bank 0, 1 (00h - FFh) 1 = Bank 2, 3 (100h - 1FFh) The IRP bit is not used by the PIC16F8X. IRP should be maintained clear. bit 6-5: RP1:RP0: Register Bank Select bits (used for direct addressing) 00 = Bank 0 (00h - 7Fh) 01 = Bank 1 (80h - FFh) 10 = Bank 2 (100h - 17Fh) 11 = Bank 3 (180h - 1FFh) Each bank is 128 bytes. Only bit RP0 is used by the PIC16F8X. RP1 should be maintained clear. bit 4: TO: Time-out bit 1 = After power-up, CLRWDT instruction, or SLEEP instruction 0 = A WDT time-out occurred
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 33
bit 3: PD: Power-down bit 1 = After power-up or by the CLRWDT instruction 0 = By execution of the SLEEP instruction bit 2: Z: Zero bit 1 = The result of an arithmetic or logic operation is zero 0 = The result of an arithmetic or logic operation is not zero bit (for ADDWF and ADDLW instructions) (For borrow the polarity is reversed) bit 1: DC: Digit carry/borrow 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result bit (for ADDWF and ADDLW instructions) bit 0: C: Carry/borrow 1 = A carry-out from the most significant bit of the result occurred 0 = No carry-out from the most significant bit of the result occurred Note: For borrow the second operand the polarity is reversed. A subtraction is executed by adding the two’s complement of. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low order bit of the source register.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 34
2.5 Pin Diagram
The PIC 16F877A is a Dual inline package (DIP) IC there are 40 pins of this microcontroller IC. It consists of two 8 bit and one 16 bit timer. Capture and compare modules, serial ports, parallel ports and five input/output ports are also present in it. 33 pins for input and output. This picture shows the pinout diagram of PIC16F877A.
Following table shows the pin description of each pin. Some pins are capable to
perform more than one function.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 35
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 36
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 37
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 38
2.6 Input/Output Ports
PIC 16F877 series normally has five input/output ports. They are used for the input/output interfacing with other devices/circuits. Most of these port pins are multiplexed for handling alternate function for peripheral features on the devices. All ports in a PIC chip are bi-directional. When the peripheral action is enabled in a pin, it may not be used as its general input/output functions. The PIC 16F877 chip basically has 5 input/output ports.
PIC16F877A PORTS The five input/output ports and its functions are given below.
PORT A AND THE TRIS A REGISTERS
PORT A is a 6-bit wide bi-directional port, the direction of this port is controlled by TRIS A data direction register. Setting a TRIS A (=1) makes corresponding PORT A pin as an input, clearing the TRIS A (=0) making the corresponding PORT A pin as an output Pin RA4 is multiplexed with the “Timer0” module clock input to become the RA4/T0CKI pin and functioning either input/output operation or Timer0 clock functioning module. The RA4/T0CKI pin is a Schmitt Trigger input and an open-drain output. All other PORT A pins have TTL input levels and full CMOS output drivers.
Other PORT A pins in this microcontroller multiplexed with analog inputs and the analog VREF input for both the A/D converters and the comparators. The operation of each pin is selected by clearing/setting the appropriate control bits in the ADCON1 and/or CMCON registers. The TRIS A register controls the direction of the PORT pins even when they are being used as analog inputs. The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 39
PORT B AND THE TRIS B REGISTERS PORT B is also an 8 bit bi-directional PORT.
Its direction controlled and maintained by TRIS B data direction register. Setting the TRIS B into logic ‘1’ makes the corresponding “PORT B” pin as an input. Clearing the TRIS B bit make PORT B as an output. Three pins of PORT B are multiplexed with the In-Circuit Debugger and Low-Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD for performing its alternate functions.
PORT C AND THE TRIS C REGISTERS PORT C is an 8-bit wide, bidirectional PORT which controlled and maintained by TRIS
C data direction register. Setting a TRIS C bit (= 1) will make the corresponding PORT C pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRIS C bit (= 0) will make the corresponding PORT C pin an output PORT C is also multiplexed with several peripheral functions. PORT C pins have Schmitt Trigger input buffers.
When enabling peripheral functions, more care should be taken in defining TRIS bits for each PORT C pin as compared to other. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify write instructions (BSF, BCF, and XORWF) with TRISC as the destination, should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings.
PORT D AND TRIS D REGISTERS PORT D is an 8-bit PORT with
bi-directional nature. This port also with Schmitt Trigger input buffers, each pin in this PORT D individually configurable as either input or output. PORT D can be configured as an 8-bit wide microprocessor PORT (functioning as Parallel Slave PORT) by setting control bit, PSPMODE ((TRISE<4>). In this mode, the input buffers are TTL.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 40
PORT E AND TRIS E REGISTERS PORT E has only three pins (RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7) which are
individually configurable as inputs or outputs. These pins controllable by using its corresponding data direction register “TRIS E”. These pins also have Schmitt Trigger input buffers. The PORT E pins become the I/O control inputs for the microprocessor PORT when bit PSPMODE is set. In this mode, the user must make certain that the TRIS E bits are set and that the pins are configured as digital inputs. Also, ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL.
TRISE register which also controls the Parallel Slave PORT operation. PORT E pins are multiplexed with analog inputs. When selected for analog input, these pins will read as ‘0’s. TRIS E controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 41
2.7. Timers
As the name suggests these are used to measure the time or generate the accurate time delay. The microcontroller can also generate/measure the required time delays by running loops, but the timer relieves the CPU from that redundant and repetitive task, allowing it to allocate maximum processing time for other tasks.
The timer is nothing but a simple binary counter that can be configured to count clock pulses (Internal/External). Once it reaches the max value, it will roll back to zero setting up an OverFlow flag and generates the interrupt if enabled. PIC16F877a has three timers.
• Timer0 (8-bit timer).
• Timer1 (16-bit timer).
• Timer2 (8-bit timer).
All Timers can act as a timer or counter or PWM Generation.
To start using a timer we should understand some of the fancy terms like 8-bit/16-
bit timer, Prescaler, Timer interrupts and Fosc. Now, let us see what each one really
means. As said earlier there are both the 8-bit and 16-bit Timers in our PIC16F877A. The
main difference between them is that the 16-bit Timer has a much better Resolution than
the 8-bit Timer.
Prescaler is a name for the part of a microcontroller that divides oscillator clock
before it will reach logic that increases timer status. The range of the Prescaler id is from 1
to 256 and the value of the Prescaler can be set using the OPTION Register (we will see this
register later).
As the timer increments and when it reaches its maximum value of 255 (for 8-bit
timers) or 65536 (for 16-bit timers), it will trigger an interrupt and initialize itself to 0 back
again. This interrupt is called as the Timer Interrupt. This interrupt informs the MCU that
this particular time has lapped.
The Fosc stands for Frequency of the Oscillator, it is the frequency of the Crystal
used. The time taken for the Timer register depends on the value of Prescaler and the
value of the Fosc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 42
Timer0 The Timer0 module timer/counter has the following features:
8-bit timer/counter
Readable and writable
8-bit software programmable prescaler
Internal (4 Mhz) or external clock select
Interrupt on overflow from FFh to 00h
Edge select (rising or falling) for external clock
Timer0 has a register called TMR0 Register, which is 8 bits of size. We can write the desired value into the register which will increment as the program progresses. Frequency varies depending on the Prescaler. Maximum value that can be assigned to this register is 255.
Prescaler - Frequency divider. We can use Prescaler for further division of the system clock. The options are:
The structure of the OPTION_REG register We perform all the necessary settings with OPTION_REG Register. The size of the
register is 8 bits.
Initializing the OPTION_REG register
The following is an example how we can initialize the OPTION_REG:
1. PSA=0; // Prescaler is assigned to the Timer0 module 2. PS0=1; // Prescaler rate bits 3. PS1=1; // are set to “111” 4. PS2=1; // which means divide by 256 5. TOSE=0; // rising edge 6. TOCS=0; // Internal instruction cycle clock
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 43
Timer1 The Timer1 module, timer/counter, has the following features:
• 16-bit timer/counter consisting of two 8-bit registers (TMR1H and TMR1L)
• readable and writable
• 8-bit software programmable pre scaler
• Internal (4 Mhz) or external clock select
• Interrupt on overflow from FFFFh to 0000h
Timer1 has a register called TMR1 register, which is 16 bits of size. Actually, the TMR1 consists of two 8-bits registers: TMR1H
TMR1L
It increments from 0000h to the maximum value of 0xFFFFh (or 0 b1111 1111 1111
1111 or 65,535 decimal). The TMR1 interrupt, if enabled, is generated on overflow which
is latched in interrupt flag bit, TMR1IF (PIR1<0>). This interrupt can be enabled/disabled by
setting/clearing TMR1 interrupt enable bit, TMR1IE (PIE1<0>).
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 44
TMR1IF – TMR1 overflow Interrupt Flag bit.
This flag marks the end of ONE cycle count. The flag need to be reset in the software
if you want to do another cycle count. We can read the value of the register TMR1 and
write into. We can reset its value at any given moment (write) or we can check if there is a
certain numeric value that we need (read).
Prescaler – Frequency divider.
We can use Prescaler for further division of the system clock. The size of the register is
2-bit only, so you can make four different division. The options are:
• 1:1
• 1:2
• 1:4
• 1:8
Timer2
The Timer2 module, timer/counter, has the following features: • Two 8-bit registers (TMR2 and PR2)
• readable and writable
• a prescaler and a postscaler
• connected only to an internal clock - 4 MHz crystal
• Interrupt on overflow
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 45
Timer2 has 2 count registers:
TMR2 and PR2. The size of each registers is 8-bit in which we can write numbers from 0 to 255. The TMR2 register is readable and writable and is cleared on any device Reset. PR2 is a readable and writable register and initialized to FFh upon Reset. Register TMR2 is used to store the "initial" count value (the value from which it begins to count). Register PR2 is used to store the "ending" count value (the maximum value we need/want to reach). ie: using Timer2 we can determine the started count value, the final count value, and the count will be between these two values. The Timer2 increments from 00h until it matches PR2 and then resets to 00h on the next increment cycle.
Prescaler and Postscaler :
Timer2 is an 8-bit timer with a prescaler and a postscaler. Each allows to make additional division of the frequency clock source. Prescaler divides the frequency clock source BEFORE the counting take place at the register TMR2, thus the counting inside the TMR2 register is performed based on the divided frequency clock source by the Prescaler
The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2 interrupt (latched in flag bit, TMR2IF (PIR1<1>)). Postscaler divides the frequency that comes out of the Comparator again for the last time. TIMER2 Prescaler and Postscaler
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 46
2.8 Programming of PIC. Compiler for PIC16F877A microcontroller
Three popular compiler which are used to program pic microcontrollers are MPLAB XC8, Mikro C for pic, PIC CCS compiler and Hi-Tech compiler.
The official compiler is MPLAB XC8 compiler which is developed by manufactures of PIC16F877A.
We generally recommend Mikro C for pic compiler for beginners and MPLAB XC8 compiler for those who want to learn pic microcontrollers programming from register level bare metal concepts.
• Variables • Looping • Decisions.
Variables
The purpose of an embedded program is to read in data or control inputs, process them, and operate the outputs as required.
Input from parallel, serial, and analog ports are held in the file registers for temporary storage and processing; and the results are output later on, as data or a signal. The program for processing the data usually contains repetitive loops and conditional branching, which depends on an input or calculated value.
Variables most programs need to process data in some way, and named variables are needed to hold their values. A variable name is a label attached to the memory location where the variable value is stored.
When working in assembly language, a register label acts as the variable name and has to be assigned explicitly. In C, the variable label is automatically assigned to the next available location or locations (many variable types need more than 1 byte of memory). The variable name and type must be declared at the start of the program block, so that the compiler can allocate a corresponding set of locations. Variable values are assumed to be in decimal by default; so if a value is given in hexadecimal in the source code, it must be written with the prefix 0x, so that 0xFF represents 255, for example.
/****** Source code file: VARI.C *******/
#include "16F877A.h"
void main()
int x; // Declare variable and type
x=99; // Assign variable value
output_D(x); // Display the value in binary
A variable called x is used in the program in Listing 2.2, VARI.C. Longer labels are
sometimes preferable, such as “output value,” but spaces are not allowed. Only alphanumeric characters (a–z, A–Z, 0–9) and underscore, instead of space, can be used. By
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 47
default, the CCS compiler is not case sensitive, so ‘a’ is the same as ‘A’ (even though the ASCII code is different). A limited number of key words in C, such as main and include, must not be used as variable names.
The variable x is an 8-bit integer with whole number values 0–25510. The value in binary can be seen when it is output at an 8-bit port. Generally, C integers (int) are stored as 16- bit values, but C for 8-bit microcontrollers uses a default 8-bit integer format. In Program VARI.C, an initial value is assigned to the variable (99), which is then used in the output function. The point here is that the variable value can now be modified without having to change the output function call itself. In the program, an 8-bit variable x is declared and assigned a value 99 using the “equals” operator. It is then output to Port D using the standard output function.
Variable Types
Variables are needed to store the data values used in the program. Variable labels
are attached to specific locations when they are declared at the beginning of the program,
so the MCU can locate the data required by each operation in the file registers.
a. Integers
We have seen the integer (whole number) variable in use. In the 8-bit MCU, the default type is an unsigned 8-bit number, giving a range of values of 0–255. This obviously is inadequate for many purposes, so 16- and 32-bit integer types are also needed. The range of a number is determined by the number of different binary codes that can be represented. If n is the number of bits, 2n different codes are possible. As 0 must be included, the highest number is 2(n—1). Hence, the 16-bit unsigned integer has the range 0–65535 (216 — 1) and the 32 bit 0–4294967295 (232 — 1). There is also a 1-bit type for bit storage.
b. Signed Integers The signed integer uses the most significant bit (MSB) as the sign bit, so the range is
accordingly reduced by half. MSB = 0 represents a positive number, MSB = 1 indicates a negative number. Therefore, the range for a 16-bit signed integer is –32767 to +32767. The sign bit must be processed separately to get the right answer from a calculation.
Range of Integer Variables
Name Type Minimum Maximum Range
int1 1 bit 0 1 1 = 20
unsigned int8 8 bits 0 255 256 = 28
signed int8 8 bits —127 +127 256 = 28
unsigned int16 16 bits 0 65535 65536 = 216
signed int16 16 bits —32767 +32767 65536 = 216
unsigned int32 32 bits 0 4294967295 4294967296 = 232
signed int32 32 bits —2147483647 +2147483647 4294967296 = 232
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 48
c. Floating Point
Integers can represent only a limited range of numbers, with a precision of ±0.5.
Therefore, the floating point (FP) type should be used for many calculations, particularly
those with a fractional result. The 32-bit FP format can represent decimal numbers from
about 10—39 to 10+38, with a precision of about 10—7 (±0.0000001). The number is stored in
exponential format, as used in a standard calculator. Twenty-three bits are used for the
significant digits, called the mantissa. Eight bits are used for the exponent part and one for
the sign. The IEEE standard form has the sign bit as the MSB, but Microchip and CCS use a
slightly more logical form, where the sign bit is the MSB of the third byte, leaving the
exponent to be represented by the complete high byte.
d. Character Variable
Text characters are generally represented by ASCII codes. The basic set of 7- bit
characters includes the upper and lower case letters and the numerals and punctuation
marks found on the standard computer keyboard. For example, capital (upper case) A is
1000001 (6510). The numeric characters run from 0x30 (0) to 0x39 (9), so to convert to the
actual number from ASCII, simply subtract 0x30. The character variable is indicated in C
source code in single quotes. For example the statement answer ='Y'; will assign the value
0x59 to the variable ‘answer’.
Looping
Most real-time applications need to execute continuously until the processor is
turned off or reset. Therefore, the program generally jumps back at the end to repeat the
main control loop.
The condition for continuing to repeat the block between the while braces is
contained in the parentheses following the while keyword. The block is executed if the
value, or result of the expression, in the parentheses is not zero. In this case, it is 1, which
means the condition is always true; and the loop repeats endlessly.
This program represents in simple form the general structure of embedded
applications, where an initialization phase is followed by an endless control loop. Within
the loop, the value of x is incremented (x++). The output therefore appears to count up in
binary when executing. When it reaches the maximum for an 8-bit count (11111111 =
255), it rolls over to 0 and starts again.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 49
Endless Loop #include "16F877A.h"
void main()
int x; // Declare variable
while(1) // Loop endlessly
output D(x); // Display value
x++; // Increment value
IF Statement // IFIN.C Tests an input
#include "16F877A.h"
void main()
int x; // Declare variable
output_D(0); // Clear all outputs
while(1) // Loop always
x=input(PIN_C0); // Get input state
if(x==1)output_high(PIN_D0); // Change output
Decision Making
The simplest way to illustrate basic decision making is to change an output depending on the state of an input. The switch generates an input at RC0 and RD0 provides the test output.
The common keyword for selection in many high level languages is IF. Program IFIN.C has the usual endless “while” loop but contains a statement to switch off Port D initially. The input state is read within the loop using the bit read function input (PIN_C0). This assigns the input value 1 or 0 to the variable x. The value is then tested in the if statement and the output set accordingly. Note that the test uses a double equals to differentiate it from the assignment operator used in the previous statement. The effect of the program is to switch on the output if the input is high. The switch needs to be closed before running to see this effect. The LED cannot be switched off again until the program is restarted.
Loop Control The program can be simplified by combining the input function with the condition
statement as follows:
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 50
Conditional Loop #include "16F877A.h"
#use delay (clock=1000000) //MUC clock = 1 MHz
void main()
while(1)
while(input(PIN_C0)) // Repeat while switch is open
output_high(PIN_D0); //switch on LED
delay_ms(300); //Delay 0.3s
output_low(PIN_D0); //Switch off LED
delay_ms(500); //Delay 0.5s
output_low(PIN_D0); //Switch off LED
The conditional sequence can also be selected by a while condition. In above
program, the input is tested in the loop condition statement and the output flashed on
and off while the switch is open (input high). If the switch is closed, the flash loop is not
executed and the LED is switched off.
The program also demonstrates the delay function. If this were absent, the loop
would execute in just a few microseconds, since each machine code instruction takes 4 μs
at a clock rate of 1 MHz. The flashing of the output would be invisible. The delay required
(in milliseconds) is given as the function parameter, and a reference to the function library
is provided at the start of the program with the #use directive. This allows the compiler to
find the library routine delay_ms(). The clock speed of the target processor must be given
in the use directive, so that the correct delay is calculated within the function.
Compare the syntax of the I/O statements. The function output high (PIN_nn) is an
output operation to set the port pin high. The function input (PIN_nn) is an input function
that returns a 1 or 0 from the input pin, which can be tested by an IF or WHILE statement.
The ports are initialized automatically within these functions.
FOR Loop
The WHILE loop repeats until some external event or internally modified value
satisfies the test condition. In other cases, we need a loop to repeat a fixed number of
times. The FOR loop uses a loop control variable, which is set to an initial value and
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 51
FOR Loop // FORLOOP.C Repeat loop a set number of times #include "16F877A.h" #use delay (clock=1000000) void main()
int x; while(input(PIN_C0)); //Wait until switch is closed for (x=0; x<5; x++) //FOR loop condition
output_high(PIN_D0); //Flash sequence delay_ms(500); output_low(PIN_D0); delay_ms(500);
while(!input(PIN_C0)); //Wait for Reset
modified for each iteration while a defined condition is true. In the demo program
FORLOOP.C, the loop control parameters are given within the parentheses that follow the
for keyword. The loop control variable x is initially set to 0, and the loop continues while it
is less than 6. Value x is incremented each time round the loop. The effect is to flash the
output five times.
The FORLOOP program also includes the use of the while loop to wait for the switch
to close before the flash sequence begins. In addition, an unconditional while loop
terminates the program, preventing the program execution from running into undefined
locations after the end of the sequence. This is advisable whenever the program does not
run in a continuous loop. Note that the use of the empty braces, which contain no code, is
optional.
Siren Program A program combining some of these basic features is shown in SIREN.C. This
program outputs to a sounder rather than an LED, operating at a higher frequency. The delay is therefore in microseconds. The output is generated when the switch is closed (input C0 low). The delay picks up the incrementing value of “step,” giving a longer pulse each time the for loop is executed. This causes a burst of 255 pulses of increasing length (reducing frequency), repeating while the input is on. Note that 255 is the maximum value allowed for “step,” as it is an 8-bit variable. When run in VSM, the output can be heard via the simulation host PC sound card. Note the inversion of the input test condition using ! = not true.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 52
SIREN Program
#include "16F877A.h"
#use delay (clock=1000000)
void main()
int step;
while(1)
while(!input(PIN_C0))
for(step=0;step<255;step++)
output_high(PIN_D0);
delay_us(step);
output_low(PIN_D0);
delay_us(step);
The header information is now more extensive, as would be the case in a real application. Generally, the more complex a program, the more information is needed in the header. Information about the author and program version and/or date, the compiler version, and the intended target system are all useful. The program description is important, as this summarizes the specification for the program.
PIC16 C Data Operations
A main function of any computer program is to carry out calculations and other forms of data processing. Data structures are made up of different types of numerical and character variables, and a range of arithmetical and logical operations are needed. Microcontroller programs do not generally need to process large volumes of data, but processing speed is often important.
Arithmetic and Logical Operations
Operation Operator Description Source Code Example Result
Single operand
Increment ++ Add 1 to integer
result = num1++; 0000 0000 0000 0001
Decrement -- Subtract 1 from integer
result = num1--; 1111 1111 1111 1110
Complement ~ Invert all bits of integer
result = num1; 0101 0010 1010 1101
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 53
Arithmetic operation
Add + Integer or result = num1+num2; 0000 1010 0001
float +0000 0111 0001
Subtract — Integer or result = num1-num2; 0000 1010 0000
float –0000 0011 0111
Multiply * Integer or result = num1*num2; 0000 1010 0001
float *0000 0011 1110
Divide / Integer or result = num1 /num2; 0000 1100 0000
float /0000 0011 0100
Logical operation
Logical AND & Integer result = num1&num2; 1001 0011 0001
bitwise &0111 0001 0001
Logical OR | Integer result = num1|num2; 1001 0011 1111
bitwise |0111 0001 0011
Exclusive OR ^ Integer result = num1^num2; 1001 0011 1110
bitwise ^0111 0001 0010
Conditional Operators Operation Symbol Example
Equal to == if(a == 0) b = b+5;
Not equal to != if(a != 1) b = b+4;
Greater than > if(a > 2) b = b+3;
Less than < if(a < 3) b = b+2;
Greater than or equal to >= if(a >= 4) b = b+1;
Less than or equal to <= if(a <= 5) b = b+0;
Program structure The structure of a C program is created using functions. This is a block of code
written and executed as a self-contained process, receiving the required parameters (data to be processed) from the calling function and returning results to it. Main () is the primary function in all C programs, within which the rest of the program is constructed.
When running on a PC, main() is called by the operating system, and control is returned to the OS when the C program is terminated. In the microcontroller, main() is simply used to indicate the start of the main control sequence, and more care needs to be taken in terminating the program. Normally, the program runs in a continuous loop, but if not, the final statement should be while(1);, which causes the program to wait and prevents the program running into undefined locations following the application code.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 54
3.0 NODE MCU - ESP8266
3.1 Introduction to Node MCU and Its Features.
Node MCU (Microcontroller Unit)
Today, IOT (Internet of Things) applications are on
the rise, and connecting objects are getting more and
more important. There are several ways to connect
objects using Wi-Fi protocol.
NodeMCU is an open-source platform based on
ESP8266 which can connect objects and let data transfer
using the Wi-Fi protocol. In addition, by providing some of the most important features of
microcontrollers such as GPIO, PWM, ADC etc, we can design more user friendly, remote
controlled or self actuating products.
The ESP8266 is a microcontroller with Wi-Fi capability. There are different modules and development boards with this system. Some development boards use basic ESP8266 modules and some integrate the chip flash memory and the antenna on the PCB.
NODEMCU is a development board with ESP8266 and a firmware with the same name.
NodeMCU ESP8266 Specifications & Features
Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106
Operating Voltage: 3.3V
Input Voltage: 7-12V
Digital I/O Pins (DIO): 16
Analog Input Pins (ADC): 1
UARTs: 1
SPIs: 1
I2Cs: 1
Flash Memory: 4 MB
SRAM: 64 KB
Clock Speed: 80 MHz
USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
PCB Antenna
Small Sized module to fit smartly inside your IoT projects
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 55
Attributes ESP8266 NODEMCU V2 NODEMCU V3
Microcontroller ESP8266 ESP8266
Operating Voltage 3.3V 3.3V
Power supply 7V – 12V 7V – 12V
Current consumption 15 µA – 400 mA 15 µA – 400 mA
Current consumption Deep Sleep 0.5 µA 0.5 µA
Digital I/O Pins 11 or 13 16
Digital I/O Pins with PWM 11 or 13 16
Analog Input Pins 1 1
SPI/I2C/I2S/UART 2/1/2/2 2/1/2/2
DC Current per I/O Pin 12 mA 12 mA
DC Current for 3.3V Pin
Flash Memory 4 MB 4 MB
SRAM n.A 64 KB
EEPROM 512 bytes 512 bytes
Clock Speed 52 MHz 80 MHz
Length 48 mm 58 mm
Width 26 mm 31 mm
WIFI yes yes
Bluetooth no no
Touch sensor no no
CAN no no
Ethernet MAC Interface no no
Temperature Sensor no no
Hall effect sensor no no
Power jack no no
USB connection yes yes
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 56
The NodeMCU ESP8266 development board comes with the ESP-12E module containing
the ESP8266 micrcontroller having Tensilica Xtensa 32-bit LX106 RISC microprocessor. This
microprocessor supports
RTOS and operates at
80MHz to 160 MHz
adjustable clock
frequency. NodeMCU has
128 KB RAM and 4MB of
Flash memory to store
data and programs. Its
high processing power
with in-built Wi-Fi /
Bluetooth and Deep Sleep Operating features make it ideal for IoT projects.
NodeMCU can be powered using a Micro USB jack and VIN pin (External Supply Pin). It
supports UART, SPI, and I2C interface.
3.2 Pin configuration of NODE MCU.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 57
NodeMCU Development Board Pinout Configuration
Pin Category Name Description
Power Micro-USB, 3.3V,
GND, Vin
Micro-USB: NodeMCU can be powered through the
USB port
3.3V: Regulated 3.3V can be supplied to this pin to
power the board
GND: Ground pins
Vin: External Power Supply
Control Pins EN, RST The pin and the button reset the microcontroller
Analog Pin A0 Used to measure analog voltage in the range of 0-3.3V
GPIO Pins GPIO1 to
GPIO16
Node MCU has 16 general purpose input-output pins
on its board
SPI Pins SD1, CMD, SD0,
CLK
NodeMCU has four pins available for SPI
communication.
UART Pins TXD0, RXD0,
TXD2, RXD2
NodeMCU has two UART interfaces, UART0 (RXD0 &
TXD0) and UART1 (RXD1 & TXD1). UART1 is used to
upload the firmware/program.
I2C Pins SCL, SDA
NodeMCU has I2C functionality support but due to the
internal functionality of these pins, you have to find
which pin is I2C.
GPIO (General Purpose Input Output) Pins: NodeMCU has general purpose input output pins on its board as shown in above pinout diagram. We can make it digital high/low and control things like LED or switch on it. Also, we can generate PWM signal on these GPIO pins. ADC (Analog to Digital Converter) channel (A0): NodeMCU has one ADC channel/pin on its board.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 58
SPI (Serial Peripheral Interface) Pins: NodeMCU based ESP8266 has Hardware SPI (HSPI) with four pins available for SPI communication. It also has SPI pins for Quad-SPI communication. With this SPI interface, we can connect any SPI enabled device with NodeMCU and make communication possible with it. I2C (Inter-Integrated Circuit) Pins: NodeMCU has I2C functionality support on ESP8266 GPIO pins. Due to internal functionality on ESP-12E we cannot use all its GPIOs for I2C functionality. So, do tests before using any GPIO for I2C applications. UART (Universal Asynchronous Receiver Transmitter) Pins: NodeMCU based ESP8266 has two UART interfaces, UART0 and UART1. Since UART0 (RXD0 & TXD0) is used to upload firmware/codes to board, we can’t use them in. Specification Details: https://ecksteinimg.de/Datasheet/CP06031/Datasheet.pdf
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 59
4.0 NODE MCU AND ARDUINO PROGRAMMING
4.1 Introduction to Arduino and Its Features
A decade ago, working around electronics involved
knowledge in physics and math, expensive lab
equipment, a laboratory type setup and important of all,
love for electronics. But the picture has changed over the
decade or so where the above-mentioned factors
became irrelevant to work around electronics except for
the last part: love for electronics.
There are many reasons which made this possible like
rapid growth in the field of information technology,
lower cost of electronic components and equipment and
widespread availability of the internet.
One such product which made use of the above specified and many other reasons and
made electronics be able reach anyone regardless of their background is “Arduino”. Since
its introduction in 2005, the term “Arduino” has become very popular in the field of
electronics.
Introduction Arduino is an open-source prototyping platform in electronics based on easy-to-use
hardware and software. Subtly speaking,
Arduino is a microcontroller based
prototyping board which can be used in
developing digital devices that can read
inputs like finger on a button, touch on a
screen, light on a sensor etc. and turning it
in to output like switching on an LED,
rotating a motor, playing songs through a
speaker etc.
The Arduino board can be programmed to do anything by simply programming the
microcontroller on board using a set of instructions for which, the Arduino board consists
of a USB plug to communicate with your computer and a bunch of connection sockets that
can be wired to external devices like motors, LEDs etc.
The aim of Arduino is to introduce the world of electronics to people who have less to no
experience in electronics like hobbyists, designers, artists etc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 60
Arduino is based on open-source electronics project i.e., all the design specifications,
schematics, software are available openly to all the
users. Hence, you can buy Arduino boards from vendors
as they are commercially available or else you can make
your own board by if you wish i.e., you can download the
schematic from Arduino’s official website, buy all the
components as per the design specification, assemble all
the components, and make your own board.
Key Features
Arduino boards are able to read analog or digital input signals from different sensors
and turn it into an output such as activating a motor, turning LED on/off, connect to
the cloud and many other actions.
You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading software).
Unlike most programmable circuit boards, Arduino does not need an extra piece of
hardware (called a programmer) in order to load a new code onto the board. You can
simply use a USB cable.
Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn
to program.
Finally, Arduino provides a standard form factor that breaks the functions of the
micro-controller into a more accessible package.
Some of the features of the Arduino UNO are as given below: • Microcontroller: ATmega328 • Operating Voltage: 5V • Input Voltage (recommended): 7-12V • Input Voltage (limits): 6-20V • Digital I/O Pins: 14 (of which 6 provide PWM output) • Analog Input Pins: 6 • DC Current per I/O Pin: 40 mA • DC Current for 3.3V Pin: 50 mA • Flash Memory: 32 KB of which 0.5 KB used by bootloader • SRAM: 2 KB (ATmega328) • EEPROM: 1 KB (ATmega328) • Clock Speed: 16 MHz
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 61
Hardware and Software Arduino boards are generally based on
microcontrollers from Atmel Corporation like 8,
16 or 32-bit AVR architecture based
microcontrollers.
The important feature of the Arduino
boards is the standard connectors. Using these
connectors, we can connect the Arduino board
to other devices like LEDs or add-on modules
called Shields.
The Arduino boards also consists of on-board voltage regulator and crystal
oscillator. They also consist of USB to serial adapter using which the Arduino board can be
programmed using USB connection.
In order to program the Arduino board, we need to use IDE provided by Arduino.
The Arduino IDE is based on Processing programming language and supports C and C++.
Types of Arduino Boards There are many types of Arduino
boards available in the market but all the boards have one thing in common: they can be programmed using the Arduino IDE. The reasons for different types of boards are different power supply requirements, connectivity options, their applications etc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 62
Arduino boards are available in different sizes, form factors, different no. of I/O pins etc.
Some of the commonly known and frequently used Arduino boards are Arduino UNO,
Arduino Mega, Arduino Nano, Arduino Micro and Arduino Lilypad.
Form factor is a hardware design aspect that defines and prescribes the size, shape, and other physical specifications of components, particularly in electronics. A form factor may represent a broad class of similarly sized components, or it may prescribe a specific standard. It may also define an entire system, as in a computer form factor.
Arduino boards based on ATMEGA328 microcontroller
Board Name Operating Volt
Clock Speed
Digital i/o
Analog Inputs
PWM UART Programming Interface
Arduino Uno R3 5V 16MHz 14 6 6 1 USB via ATMega16U2
Arduino Uno R3 SMD
5V 16MHz 14 6 6 1 USB via ATMega16U2
Red Board 5V 16MHz 14 6 6 1 USB via FTDI
Arduino Pro 3.3v/8 MHz
3.3V 8MHz 14 6 6 1 FTDI-Compatible Header
Arduino Pro 5V/16MHz
5V 16MHz 14 6 6 1 FTDI-Compatible Header
Arduino mini 05 5V 16MHz 14 8 6 1 FTDI-Compatible Header
Arduino Pro mini 3.3v/8mhz
3.3V 8MHz 14 8 6 1 FTDI-Compatible Header
Arduino Pro mini 5v/16mhz
5V 16MHz 14 8 6 1 FTDI-Compatible Header
Arduino Ethernet 5V 16MHz 14 6 6 1 FTDI-Compatible Header
Arduino Fio 3.3V 8MHz 14 8 6 1 FTDI-Compatible Header
LilyPad Arduino 328 main board
3.3V 8MHz 14 6 6 1 FTDI-Compatible Header
LilyPad Arduino simple board
3.3V 8MHz 9 4 5 0 FTDI-Compatible Header
Arduino boards based on ATMEGA32u4 microcontroller
Board Name Operating Volt
Clock Speed
Digital i/o
Analog Inputs
PWM UART Programming Interface
Arduino Leonardo 5V 16MHz 20 12 7 1 Native USB
Pro micro 5V/16MHz 5V 16MHz 14 6 6 1 Native USB
Pro micro 3.3V/8MHz 5V 16MHz 14 6 6 1 Native USB
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 63
LilyPad Arduino USB 3.3V 8MHz 14 6 6 1 Native USB
Arduino boards based on ATMEGA2560 microcontroller
Board Name Operating Volt
Clock Speed
Digital i/o
Analog Inputs
PWM UART Programming Interface
Arduino Mega 2560
R3 5V 16MHz 54 16 14 4
USB via ATMega16U2B
Mega Pro 3.3V
3.3V 8MHz 54 16 14 4 FTDI-Compatible Header
Mega Pro 5V 5V 16MHz 54 16 14 4 FTDI-Compatible Header
Mega Pro Mini 3.3V
3.3V 8MHz 54 16 14 4 FTDI-Compatible Header
Arduino boards based on AT91SAM3X8E microcontroller
Board Name Operating Volt
Clock Speed
Digital i/o
Analog Inputs
PWM UART Programming Interface
Arduino Mega 2560 R3 3.3V 84MHz 54 12 12 4
USB native
There are add-on modules called Arduino Shields which can be used to extend the functionalities of the Arduino boards. Some of the commonly used shields are Arduino Proto shield, Arduino Wi-Fi Shield and Arduino Yun Shield.
4.2 Variables, Data Types & Constants
Variables
What is Variable Scope? Variables in C programming language,
which Arduino uses, have a property
called scope. A scope is a section of the
program and there are three places
where variables can be declared. They are
−
Inside a function or a block, which is called local variables.
In the definition of function parameters, which is called formal parameters.
Outside of all functions, which is called global variables.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 64
void setup () int age; age = 0; void loop ()
int x, y; //local variable declaration x = 0; y = 0; //actual initialization
int age, marks; ; //Global variable declaration
float avg= 0; //Global variable declaration
void loop ()
int z; //Local variable declaration
z = 10;
Local Variables Variables that are declared inside a function or block are local variables. They can
be used only by the statements that are inside that function or block of code. Local variables are not known to function outside their own.
Global Variables
Global variables are defined outside of all the functions, usually at the top of the program. The global variables will hold their value throughout the life-time of your program.
A global variable can be accessed by any function. That is, a global variable is
available for use throughout your entire program after its declaration.
Data types
Data types in C refers to an extensive system used
for declaring variables or functions of different types. The
type of a variable determines how much space it occupies
in the storage and how the bit pattern stored is
interpreted.
The following table provides all the data types that
you will use during Arduino programming.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 65
void loop ( )
// rest of the code
boolean val = false; // declaration of variable with type boolean and initialize it with false
boolean state = true; // declaration of variable with type boolean and initialize it with true
char chr_a = ‘a’; //declaration of variable with type char and initialize it with character a
char chr_c = 97; //declaration of variable with type char and initialize it with character 97
unsigned char chr_y = 121; // declaration of variable with type Unsigned char and initialize it with character y. ASCII value of ‘y’ = 121
void
The void keyword is used only in function declarations. It indicates that the function
does not return any information to the function from which it was called.
Boolean
A Boolean holds one of two values, true or false. Each Boolean variable occupies
one byte of memory.
Char
A data type that takes up one byte of memory that stores a character value. Character literals are written in single quotes like this: 'A' and for multiple characters, strings use double quotes: "ABC".
However, characters are stored as numbers. You can see the specific encoding in the ASCII chart. This means that it is possible to do arithmetic operations on characters, in which the ASCII value of the character is used. For example, 'A' + 1 has the value 66, since the ASCII value of the capital letter A is 65.
unsigned char
Unsigned char is an unsigned data type that occupies one byte of memory. The unsigned char data type encodes numbers from 0 to 255.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 66
byte m = 25; //declaration of variable with type byte and initialize it with 25
int counter = 32; // declaration of variable with type int and initialize it with 32
unsigned int counter = 60; // declaration of variable with type unsigned int and initialize
with 60
word w = 1000; //declaration of variable with type word and initialize it with 1000
long velocity = 102346; //declaration of variable with type Long and initialize it with
102346
byte
A byte stores an 8-bit unsigned number, from 0 to 255.
int
Integers are the primary data-type for number storage. int stores a 16-bit (2-byte)
value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum
value of (2^15) - 1).
The int size varies from board to board. On the Arduino Due, for example, an int
stores a 32-bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647
(minimum value of -2^31 and a maximum value of (2^31) - 1).
Unsigned int
Unsigned ints (unsigned integers) are the same as int in the way that they store a 2-
bytes value. Instead of storing negative numbers, however, they only store positive values,
yielding a useful range of 0 to 65,535 (2^16) - 1). The Due stores a 4-byte (32-bit) value,
ranging from 0 to 4,294,967,295 (2^32 - 1).
Word
On the Uno and other ATMEGA based boards, a word stores a 16-bit unsigned
number. On the Due and Zero, it stores a 32-bit unsigned number.
Long Long variables are extended size variables for number storage, and store 32 bits (4
bytes), from -2,147,483,648 to 2,147,483,647.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 67
unsigned long velocity = 101006; // declaration of variable with type Unsigned Long
and initialize it with 101006
short val = 13; //declaration of variable with type short and initialize it with 13
float num = 1.352; //declaration of variable with type float and initialize it with 1.352
double num = 45.352 ;// declaration of variable with type double and initialize it with
45.352
Unsigned long Unsigned long variables are extended size variables for number storage and store 32
bits (4 bytes). Unlike standard longs, unsigned longs will not store negative numbers,
making their range from 0 to 4,294,967,295 (2^32 - 1).
Short A short is a 16-bit data-type. On all Arduinos (ATMega and ARM based), a short
store a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).
float
Data type for floating-point number is a number that has a decimal point. Floating-point numbers are often used to approximate the analog and continuous values because they have greater resolution than integers.
Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information.
double On the Uno and other ATMEGA based boards, Double precision floating-point number occupies four bytes. That is, the double implementation is exactly the same as the float, with no gain in precision. On the Arduino Due, doubles have 8-byte (64 bit) precision.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 68
4.3 Programming Structure
Sketch − The first new terminology is the Arduino
program called “sketch”. A sketch is the name that
Arduino uses for a program. It is the unit of code that is
uploaded to and run on an Arduino board.
Structure
Arduino programs can be divided in
three main parts: Structure, Values
(variables and constants), and Functions. In
this tutorial, we will learn about the Arduino
software program, step by step, and how we
can write the program without any syntax or
compilation error.
Let us start with the Structure. Software
structure consist of two main functions −
a. Setup( ) function
b. Loop( ) function
a. Void setup ( )
Purpose − The setup() function is called when a sketch starts. Use it to initialize the
variables, pin modes, start using libraries, etc. The setup function will only run once, after
each power up or reset of the Arduino board.
INPUT – no input
OUTPUT – no output
RETURN – returns void
b. void Loop ( )
Purpose − After creating a setup() function, which
initializes and sets the initial values, the loop()
function does precisely what its name suggests, and
loops consecutively, allowing your program to change
and respond. Use it to actively control the Arduino
board.
INPUT – no input
OUTPUT – no output
RETURN – returns void
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 69
pinMode(3,INPUT) ; // set pin to input without using built in pull up resistor pinMode(5,INPUT_PULLUP) ; // set pin to input using built in pull up resistor
4.4 Digital I/O Programming The pins on the Arduino board can be configured as either inputs or outputs. It is
important to note that a majority of Arduino analog pins, may be configured, and used, in
exactly the same manner as digital pins.
Pins Configured as INPUT
Arduino pins are by default configured as
inputs, so they do not need to be explicitly
declared as inputs with pinMode() when you are
using them as inputs. Pins configured this way are
said to be in a high-impedance state. Input pins
make extremely small demand on the circuit that
they are sampling, equivalent to a series resistor
of 100 megaohm at the pin.
This means that it takes very little current
to switch the input pin from one state to another. This makes the pins useful for such tasks
as implementing a capacitive touch sensor or reading an LED as a photodiode.
Pins configured as pinMode(pin, INPUT) with nothing connected to them, or with
wires connected to them that are not connected to other circuits, report seemingly
random changes in pin state, picking up electrical noise from the environment, or
capacitively coupling the state of a nearby pin.
Pull-up Resistors
Pull-up resistors are often useful to steer an input pin to a known state if no input is present. This can be done by adding a pull-up resistor (to +5V), or a pull-down resistor (resistor to ground) on the input. A 10K resistor is a good value for a pull-up or pull-down resistor.
Using Built-in Pull-up Resistor with Pins
Configured as Input
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 70
There are 20,000 pull-up resistors built into the Atmega chip that can be accessed
from software. These built-in pull-up resistors are accessed by setting the pinMode() as
INPUT_PULLUP. This effectively inverts the behavior of the INPUT mode, where HIGH
means the sensor is OFF and LOW means the sensor is ON. The value of this pull-up
depends on the microcontroller used. On most AVR-based boards, the value is guaranteed
to be between 20kΩ and 50kΩ. On the Arduino Due, it is between 50kΩ and 150kΩ. For
the exact value, consult the datasheet of the microcontroller on your board.
When connecting a sensor to a pin configured with INPUT_PULLUP, the other end
should be connected to the ground. In case of a simple switch, this causes the pin to read
HIGH when the switch is open and LOW when the switch is pressed. The pull-up resistors
provide enough current to light an LED dimly connected to a pin configured as an input. If
LEDs in a project seem to be working, but very dimly, this is likely what is going on.
Same registers (internal chip memory locations) that control whether a pin is HIGH
or LOW control the pull-up resistors. Consequently, a pin that is configured to have pull-up
resistors turned on when the pin is in INPUTmode, will have the pin configured as HIGH if
the pin is then switched to an OUTPUT mode with pinMode(). This works in the other
direction as well, and an output pin that is left in a HIGH state will have the pull-up resistor
set if switched to an input with pinMode().
Pins Configured as OUTPUT
Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state.
This means that they can provide a substantial amount of current to other circuits. Atmega
pins can source (provide positive current) or sink (provide negative current) up to 40 mA
(milliamps) of current to other devices/circuits. This is enough current to brightly light up
an LED (do not forget the series resistor), or run many sensors but not enough current to
run relays, solenoids, or motors.
Attempting to run high current devices from the output pins, can damage or destroy
the output transistors in the pin, or damage the entire Atmega chip. Often, this results in a
"dead" pin in the microcontroller but the remaining chips still function adequately. For this
reason, it is a good idea to connect the OUTPUT pins to other devices through 470Ω or 1k
resistors, unless maximum current drawn from the pins is required for a particular
application.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 71
pinMode() Function Syntax
void setup ()
pinMode (pin , mode);
• pin − the number of the pin whose mode you wish to set
• mode − INPUT, OUTPUT, or INPUT_PULLUP.
digitalWrite() Function Syntax void loop() digitalWrite (pin ,value);
• pin − the number of the pin whose mode you wish to set • value − HIGH, or LOW.
pinMode() Function
The pinMode() function is used to configure a specific pin to behave either as an
input or an output. It is possible to enable the internal pull-up resistors with the mode
INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pull-ups.
digitalWrite() Function
The digitalWrite() function is used to write a HIGH or a LOW value to a digital pin. If
the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the
corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. If the pin
is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal
pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to
enable the internal pull-up resistor.
If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when
calling digitalWrite(HIGH), the LED may appear dim. Without explicitly setting pinMode(),
digitalWrite() will have enabled the internal pull-up resistor, which acts like a large
current-limiting resistor.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 72
digitalRead() Function Syntax
void loop()
digitalRead(pin)
• pin − the Arduino pin number you want to read
• value − HIGH, or LOW.
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
void loop()
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
int LED = 6; // LED connected to pin 6
void setup ()
pinMode(LED, OUTPUT); // set the digital pin as output
void loop ()
digitalWrite(LED, HIGH); // turn on led
delay(500); // delay for 500 ms
digitalWrite(LED, LOW); // turn off led
delay(500); // delay for 500 ms
digitalRead() Function
Reads the value from a specified digital pin, either HIGH or LOW.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 73
int button = 5 ; // button connected to pin 5
int LED = 6; // LED connected to pin 6
void setup () pinMode(button , INPUT_PULLUP);
// set the digital pin as input with pull-up resistor
pinMode(button , OUTPUT); // set the digital pin as output
void loop ()
If (digitalRead(button ) == LOW) // if button pressed
digitalWrite(LED,HIGH); // turn on led
delay(500); // delay for 500 ms
digitalWrite(LED,LOW); // turn off led
delay(500); // delay for 500 ms
4.5 Analog I/O Programming
analogRead( ) function
Arduino is able to detect whether there
is a voltage applied to one of its pins and
report it through the digitalRead() function.
There is a difference between an on/off sensor
(which detects the presence of an object) and
an analog sensor, whose value continuously
changes. In order to read this type of sensor,
we need a different type of pin.
In the lower-right part of the Arduino
board, you will see six pins marked “Analog
In”. These special pins not only tell whether there is a voltage applied to them, but also its
value. By using the analogRead() function, we can read the voltage applied to one of the
pins.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 74
analogRead() function Syntax
Void loop()
analogRead(pin);
• pin − the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)
int analogPin = 3;//potentiometer wiper (middle terminal)
// connected to analog pin 3
int val = 0; // variable to store the value read
void setup()
Serial.begin(9600); // setup serial
void loop()
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
This function returns a number between 0 and 1023, which represents voltages between 0
and 5 volts. For example, if there is a voltage of 2.5 V applied to pin number 0,
analogRead(0) returns 512.
analogWrite( ) function
Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightness’s or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady rectangular wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin.
You do not need to call pinMode() to set the pin as an output before calling
analogWrite(). The analogWrite() function has nothing to do with the analog pins or the analogRead function.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 75
analogWrite() function Syntax
void loop()
analogWrite(pin, value)
• pin: the Arduino pin to write to. Allowed data types: int.
• value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int.
Example
int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value
void setup()
pinMode(ledPin, OUTPUT); // sets the pin as output
void loop()
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite
values from 0 to 255
Notes and Warnings: The PWM outputs generated on pins 5 and 6 will have higher-than-
expected duty cycles. This is because of interactions with the millis() and delay() functions,
which share the same internal timer used to generate those PWM outputs. This will be
noticed mostly on low duty-cycle settings (e.g. 0 - 10) and may result in a value of 0 not
fully turning off the output on pins 5 and 6.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 76
analogReference () function Syntax
analogReference (type);
analogReference() Function
Configures the reference voltage used for analog input (i.e. the value used as the
top of the input range). The options are –
DEFAULT − The default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts
(on 3.3V Arduino boards)
INTERNAL − A built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328
and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
INTERNAL1V1 − A built-in 1.1V reference (Arduino Mega only)
INTERNAL2V56 − A built-in 2.56V reference (Arduino Mega only)
EXTERNAL − The voltage applied to the AREF pin (0 to 5V only) is used as the reference
type − can use any type of the follow (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56,
EXTERNAL)
Do not use anything less than 0V or more than 5V for external reference voltage on the
AREF pin. If you are using an external reference on the AREF pin, you must set the analog
reference to EXTERNAL before calling the analogRead() function. Otherwise, you will short
the active reference voltage (internally generated) and the AREF pin, possibly damaging
the microcontroller on your Arduino board.
Alternatively, you can connect the external reference voltage to the AREF pin
through a 5K resistor, allowing you to switch between external and internal reference
voltages.
Note that the resistor will alter the voltage that is used as the reference because
there is an internal 32K resistor on the AREF pin. The two acts as a voltage divider. For
example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF
pin.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 77
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
int val = 0; // variable to store the read value
void setup()
Serial.begin(9600); // setup serial
analogReference(EXTERNAL); // the voltage applied to the AREF pin (0 to 5V only)
// is used as the reference.
void loop()
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
4.6 Serial Data Monitoring Serial Communication Modules: Today, most Arduino boards are built with several
different systems for serial communication as standard equipment.
Which of these systems are used depends on the following factors –
• How many devices the microcontroller has to exchange data with? • How fast the data exchange has to be? • What is the distance between these devices? • Is it necessary to send and receive data simultaneously?
One of the most important things concerning serial communication is the Protocol,
which should be strictly observed. It is a set of rules, which must be applied such that the
devices can correctly interpret data they mutually exchange. Fortunately, Arduino
automatically takes care of this, so that the work of the programmer/user is reduced to
simple write (data to be sent) and read (received data).
Types of Serial Communications
Serial communication can be further classified as −
a. Synchronous − Devices that are synchronized use the same clock and their timing is
in synchronization with each other.
b. Asynchronous − Devices that are asynchronous have their own clocks and are
triggered by the output of the previous state.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 78
It is easy to find out if a device is synchronous or not. If the same clock is given to all the
connected devices, then they are synchronous. If there is no clock line, it is asynchronous.
For example, UART (Universal Asynchronous Receiver Transmitter) module is
asynchronous.
The asynchronous serial protocol has a number of built-in rules. These rules are nothing
but mechanisms that help ensure robust and error-free data transfers. These mechanisms,
which we get for eschewing the external clock signal, are –
Synchronization bits Data bits Parity bits Baud rate Synchronization Bits
The synchronization bits are two or three special bits transferred with each packet of
data. They are the start bit and the stop bit(s). True to their name, these bits mark the
beginning and the end of a packet respectively.
There is always only one start bit, but the number of stop bits is configurable to either
one or two (though it is normally left at one).
The start bit is always indicated by an idle data line going from 1 to 0, while the stop
bit(s) will transition back to the idle state by holding the line at 1.
Data Bits
The amount of data in each packet can be set to any size from 5 to 9 bits. Certainly,
the standard data size is your basic 8-bit byte, but other sizes have their uses. A 7-bit data
packet can be more efficient than 8, especially if you are just transferring 7-bit ASCII
characters.
Parity Bits
The user can select whether there should be a parity bit or not, and if yes, whether
the parity should be odd or even. The parity bit is 0 if the number of 1’s among the data
bits is even. Odd parity is just the opposite.
Baud Rate
The term baud rate is used to denote the number of bits transferred per second
[bps]. Note that it refers to bits, not bytes. It is usually required by the protocol that each
byte is transferred along with several control bits. It means that one byte in serial data
stream may consist of 11 bits. For example, if the baud rate is 300 bps then maximum 37
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 79
void setup()
Serial.begin(9600); //set up serial library baud rate to 9600
Serial.println("hello world"); //print hello world
void loop()
void setup()
Serial.begin(9600); //set up serial library baud rate to 9600
void loop()
if(Serial.available()) //if number of bytes (characters) available for
reading from
serial port
Serial.print("I received:"); //print I received
Serial.write(Serial.read()); //send what you read
and minimum 27 bytes may be transferred per second.
Arduino UART
The following code will make Arduino send hello world when it starts up.
After the Arduino sketch has been uploaded to Arduino, open the Serial monitor at the top right section of Arduino IDE.
Type anything into the top box of the Serial Monitor and press send or enter on your keyboard. This will send a series of bytes to the Arduino.
The following code returns whatever it receives as an input.
The following code will make Arduino deliver output depending on the input
provided.
Notice that Serial.print and Serial.println will send back the actual ASCII code, whereas
Serial.write will send back the actual text. See ASCII codes for more information.
Reference: https://www.tutorialspoint.com/arduino/
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 80
5.0 IoT (Internet of Things)
Introduction: IoT stands for
Internet of Things, which
means accessing and
controlling daily usable
equipment’s and devices using
Internet. This Chapter includes
all topics of IoT such as
introduction, features,
advantage and disadvantage,
ecosystem, decision
framework, architecture and
domains, biometric, security camera and door unlock system, devices, etc. The term "the
Internet of things" was coined by Kevin Ashton of Procter & Gamble, later MIT's Auto-ID
Center, in 1999.
An IOT can:
• Can connect to the Internet
• Talk with other devices
• Collect and send data to the servers
• Do physical changes as per given commands
5.1 Internet of Things (IoT)
Let's us look closely at the mobile device which contains GPS Tracking, Mobile
Gyroscope, Adaptive brightness, Voice detection, Face detection etc. These components
have their own individual features, but what about if these all communicate with each
other to provide a better environment? For example, the phone brightness is adjusted
based on my GPS location or my direction.
Connecting everyday things embedded with electronics, software, and sensors to
internet enabling to collect and exchange data without human interaction is called as the
Internet of Things (IoT). The term "Things" in the Internet of Things refers to anything and
everything in day to day life which is accessed or connected through the internet.
IoT is an advanced automation and analytics system which deals with artificial
intelligence, sensor, networking, electronic, cloud messaging etc. to deliver complete
systems for the product or services. The system created by IoT has greater transparency,
control, and performance.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 81
As we have a platform such as cloud that contains all the data through which we
connect all the things around us. For example, a house, where we can connect our home
appliances such as air conditioner, light, etc. through each other and all these things are
managed at the same platform. Since we have a platform, we can connect our car, track its
fuel meter, speed level, and also track the location of the car.
"The cloud" refers to servers accessed over the Internet, and the software and databases that
run on those servers. Cloud servers are located in data centers all over the world. By using cloud
computing, users and companies do not have to manage physical servers themselves or run
software applications on their own machines.
The cloud enables users to access the same files and applications from almost any device,
because the computing and storage takes place on servers in a data center, instead of locally on the
user device. This is why a user can log in to their Instagram account on a new phone after their old
phone breaks and still find their old account in place, with all their photos, videos, and conversation
history. It works the same way with cloud email providers like Gmail or Microsoft Office 365, and
with cloud storage providers like Dropbox or Google Drive.
If there is a common platform where all these things can connect to each other it
would be great because based on my preference, I can set the room temperature. For
example, if I love the room temperature to to be set at 25 or 26-degree Celsius when I
reach back home from my office, then according to my car location, my AC would start
before 10 minutes I arrive at home. This can be done through the Internet of Things (IoT).
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 82
Definition of IoT
Internet of Things (IoT) is a
network of physical objects or
people called "things" that are
embedded with software,
electronics, network, and sensors
that allows these objects to collect
and exchange data.
The Internet of Things (IoT) is the
ability to have devices
communicate with one another
via the internet or other networks,
remotely tracking information to
provide feedback to assist with
decision making for commercial, industrial and residential purposes. This is commonly
done using sensors connecting to a back-to-base system.
How does Internet of Thing (IoT) Work?
The working of IoT is different for different IoT echo
system (architecture). However, the key concept of
there working are similar. The entire working process
of IoT starts with the device themselves, such as
smartphones, digital watches, electronic appliances,
which securely communicate with the IoT platform.
The platforms collect and analyze the data from all
multiple devices and platforms and transfer the most
valuable data with applications to devices.
The Internet of Things (IoT), also sometimes referred to as the Internet of Everything
(IoE), consists of all the web-enabled devices that collect, send and act on data they
acquire from their surrounding environments using embedded sensors, processors and
communication hardware. These devices, often called "connected" or "smart" devices, can
sometimes talk to other related devices, a process called Machine to-Machine (M2M)
communication, and act on the information they get from one another, Humans can
interact with the gadgets to set them up, give them instructions or access the data, but the
devices do most of the work on their own without human intervention. Their existence has
been made possible by all the tiny mobile components that are available these days, as
well as the always-online nature of our home and business networks.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 83
Connected devices also generate massive amounts of Internet traffic, including loads of data that can be used to make the devices useful, but can also be mined for other purposes. All this new data, and the Internet-accessible nature of the devices, raises both privacy and security concerns.
WHY IoT?
IoT technology allows for a level of real-time information that
we've never had before. We can monitor our homes and
families remotely to keep them safe. Businesses can improve
processes to increase productivity and reduce material waste
and unforeseen downtime. Sensors in city infrastructure can
help reduce road congestion and warn us when infrastructure is
in danger of crumbling. Gadgets out in the open can monitor for
changing environmental conditions and warn us of impending disasters.
Features of IoT
`The most important features of IoT on which it works are connectivity, analyzing,
integrating, active engagement, and many more. Some of them are listed below:
Connectivity: Connectivity refers to establish a proper
connection between all the things of IoT-to-IoT platform it may
be server or cloud. After connecting the IoT devices, it needs a
high-speed messaging between the devices and cloud to enable
reliable, secure and bi-directional communication.
Analyzing: After connecting all the relevant things, it comes to
real-time analyzing the data collected and use them to build
effective business intelligence. If we have a good insight into data gathered from all these
things, then we call our system has a smart system.
Integrating: IoT integrating the various models to improve the user experience as well.
Artificial Intelligence: IoT makes things smart and enhances life through the use of data.
For example, if we have a coffee machine whose beans are going to end, then the coffee
machine itself orders the coffee beans of your choice from the retailer.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 84
Sensing: The sensor devices used in IoT technologies detect and measure any change in
the environment and report on their status. IoT technology brings passive networks to
active networks. Without sensors, there could not hold an effective or true IoT
environment.
Active Engagement: IoT makes the connected technology, product, or services to active
engagement between each other.
Endpoint Management: It is important to do the endpoint management of all the IoT
system, otherwise it causes the complete failure of the system. For example, if a coffee
machine itself orders the coffee beans when it goes to the end but what happens when it
orders the beans from a retailer and we are not present at home for a few days, it leads to
the failure of the IoT system. So, there must be a need for endpoint management.
5.2 Components of IoT
There are 4 fundamental components of IoT system, which tells us how IoT works.
a. Sensors/Devices: Sensors or devices are a key
component that helps us collect live data from the
surrounding environment. All this data may have
various levels of complexities. It could be a simple
temperature monitoring sensor, or it may be in the
form of the video feed.
IoT Components – Sensors/Devices
A device may have various types of sensors which performs multiple tasks apart
from sensing. Example, A mobile phone is a device which has multiple sensors like GPS,
camera but your smartphone is not able to sense these things.
b. Connectivity: All the collected data is sent to a
cloud infrastructure. The sensors should be
connected to the cloud using various mediums of
communications. These communication mediums
include mobile or satellite networks, Bluetooth,
WI-FI, WAN, etc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 85
c. Data Processing: Once that data is collected, and it gets to the cloud,
the software performs processing on the gathered
data. This process can be just checking the
temperature, reading on devices like AC or heaters.
However, it can sometimes also be very complex
like identifying objects, using computer vision on
video.
d. User Interface: The information needs to be
available to the end-user in some way which can be
achieved by triggering alarms on their phones or
sending them notification through email or text
message. The user sometimes might need an
interface which actively checks their IoT system. For
example, the user has a camera installed in his
home. He wants to access video recording and all the feeds with the help of a web server.
Requirements for a Reference Architecture
There are some specific requirements for IoT that are unique to IoT devices and the
environments that support them, e.g., many requirements emerge from the limited form
factors and power available to IoT devices. Other requirements come from the way in
which IoT devices are manufactured and used. The approaches are much more like
traditional consumer product designs than existing Internet approaches. It can summarize
the overall requirements into some key categories.
a. Connectivity and communications
b. Device management
c. Data collection, analysis, and
actuation
d. Scalability
e. Security
f. High Availability (HA)
g. Predictive analysis
h. Integration
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 86
Form factor for computers refers to the size, shape, and physical specifications of hardware or hardware components. Computer form factor is used to describe any physical aspect of a computer system. One example of a computer form factor is the difference between a desktop and a laptop computer. Although the same parts are present in each, they are shaped and attached differently. For example, the keyboard from a desktop computer cannot fit into the keyboard space of a laptop computer.
a. Connectivity and Communications: Existing protocols, such as HTTP, have a very
important place for many devices. Even an 8-
bit controller can create simple GET and
POST requests and HTTP provides an
important unified and uniform connectivity.
However, the overhead of HTTP and some
other traditional Internet protocols can be
an issue for two main reasons. Firstly, the
memory size of the program can be an issue
on small devices. However, the bigger issue
is the power requirements. In order to meet
these requirements, we need a simple, small and binary protocol. We will look at this in
more detail below. We also require the ability to cross firewalls.
In addition, there are devices that connect directly and those that connect via
gateways. The devices that connect via a gateway potentially require two protocols: one
to connect to the gateway, and then another from the gateway to the cloud.
b. Device Management: While many IoT devices are not actively managed, this is not
necessarily ideal. We have seen active management of PCs, mobile phones, and other
devices become increasingly important, and the same trajectory is both likely and
desirable for IoT devices.
The following list covers some widely desirable requirements:
The ability to disconnect a rogue or stolen
device
The ability to update the software on a device
Updating security credentials
Remotely enabling or disabling certain
hardware capabilities
Locating a lost device
Wiping secure data from a stolen device
Remotely re-configuring Wi-Fi, GPRS, or network parameters
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 87
c. Data Collection, Analysis, and Actuation: A few IoT devices have some form of UI (User
Interface), but in general IoT devices are focused on offering one or more sensors, one or
more actuators, or a combination
of both. The requirements of the
system are that we can collect
data from very large numbers of
devices, store it, analyze it, and
then act upon it. The reference
architecture is designed to
manage very large numbers of
devices. If these devices are
creating constant streams of data, then this creates a significant amount of data. The
requirement is for a highly scalable storage system, which can handle diverse data and
high volumes.
The action may happen in near real time, so there is a strong requirement for real-
time analytics. In addition, the device needs to be able to analyze and act on data. In some
cases, this will be simple, embedded logic. On more
powerful devices we can also utilize more powerful
engines for event processing and action.
d. Scalability: Any server-side architecture would
ideally be highly scalable, and be able to support
millions of devices all constantly sending, receiving,
and acting on data. However, many “high-scalability
architectures” have come with an equally high price
– both in hardware, software, and in complexity. An important requirement for this
architecture is to support scaling from a small deployment to a very large number of
devices. Elastic scalability and the ability to deploy in a cloud infrastructure are essential.
The ability to scale the server side out on small cheap servers is an important requirement
to make this an affordable architecture for small deployments as well as large ones.
e. Security: Security is one of the most important aspects for
IoT. IoT devices are often collecting highly personal data, and
by their nature are bringing the real world onto the Internet
(and vice versa). This brings three categories of risks:
Risks that are inherent in any Internet system, but that
product/IoT designers may not be aware of.
Specific risks that are unique to IoT devices.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 88
Safety to ensure no harm is caused by, for instance, misusing actuators.
The first category includes simple things such as locking down open ports on devices
(like the Internet-attached fridge that had an unsecured SMTP server and was being used
to send spam). The second category includes issues specifically related to IoT hardware,
e.g., the device may have its secure information read. For example, many IoT devices are
too small to support proper asymmetric encryption. Another specific example is the ability
for someone to attack the hardware to understand security. Two very important specific
issues for IoT security are the concerns about identity and access management. Identity is
an issue where there are often poor practices implemented.
This concludes the set of requirements that we have identified for the reference
architecture. Of course, any given architecture may add further requirements. Some of
those may already be met by the architecture, and some may require further components
to be added. However, our design is for a modular architecture that supports extensions,
which copes with this demand.
f. High Availability (HA): High availability (HA) is a deployment in which two firewalls are
placed in a group and their configuration is synchronized to prevent a single point of
failure on your network. A
heartbeat connection between the
firewall peers ensures seamless
failover in the event that a peer
goes down. Setting up two firewalls
in an HA pair provides redundancy
and allows you to ensure business
continuity.
g. Predictive analysis: The most widely advertised use of IoT data for business is regarding
maintenance and seeing when machines or
systems need to be worked on to prevent
problems. A commercial feature an elevator
technician showing up at the office building
to perform work on an elevator before it
breaks. This is predictive analytics over IoT
data. The straightforward logic is if a
particular part or sensor is out of its normal
operating range, then dispatch a technician.
People get that idea. Predictive analytics
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 89
takes it a step further by examining the trends of those same sensors to predict when it
will exceed normal ranges.
h. Integration: IoT and integration go hand in hand. With IoT, companies are moving more
towards cloud-based systems to bring about their digital transformation. This enables the
two to come together rapidly. Since technology is changing daily, integration needs to
move at an accelerated level and speed. Therefore, with integration and IoT, speedy fusion
comes together instantly. Integration helps capture data from smart devices and move it
into business applications to automate processes, support real-time monitoring and apply
analytics for insights.
5.3 Four Stages of IoT Architecture There are several layers of IoT built upon the capability and performance of IoT elements that provides the optimal solution to the business enterprises and end-users.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 90
The IoT architecture is a fundamental way to design the various elements of IoT, so that it can deliver services over the networks and serve the needs for the future. Following are the primary stages (layers) of IoT that provides the solution for IoT architecture.
a. Sensors/Actuators b. Gateways and Data Acquisition c. Edge IT d. Data canter/ Cloud
a. Sensors/Actuators
Sensors or Actuators are the devices that are able to emit, accept and process data
over the network. These sensors or actuators may be connected either through wired or
wireless. This contains GPS, Electrochemical, Gyroscope, RFID, etc. Most of the sensors
need connectivity through sensors gateways. The connection of sensors or actuators can
be through a Local Area Network (LAN) or Personal Area Network.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 91
b. Gateways and Data Acquisition: As the large numbers of data are produced by these
sensors and actuators need the high-speed Gateways and Networks to transfer the data.
This network can be of type Local Area Network (LAN such as Wi-Fi, Ethernet, etc.), Wide
Area Network (WAN such as GSM, 5G, etc.).
c. Edge IT: Edge in the IoT Architecture is the hardware and software gateways that
analyze and pre-process the data before transferring it to the cloud. If the data read from
the sensors and gateways are not changed from its previous reading value then it does not
transfer over the cloud, this saves the data used.
d. Data center/ Cloud: The Data Center or Cloud comes under the Management Services
which process the information through analytics, management of device and security
controls. Beside this security controls and device management the cloud transfers the data
to the end user’s application such as Retail, Healthcare, Emergency, Environment, and
Energy, etc.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 92
5.4 Architecture of IoT
Major IoT building blocks and layers Before we go any further, it’s worth pointing out that there is no single, agreed-
upon IoT architecture. It varies in complexity and number of architectural layers
depending on a particular business task.
But no matter the use case and number of layers, the key building blocks of any IoT
structure are always the same, namely:
Smart things;
Networks and gateways enabling low-power devices (which is often the case in IoT) to
enter the big Internet;
The middleware or IoT platforms providing data storage spaces and advanced
computing engines along with analytical capabilities; and
Applications, allowing end users to benefit from IoT and manipulate the physical world.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 93
These elements make up the backbone of any IoT system upon which effective, multi-
layered architecture can be developed. Most commonly, these layers are:
Layer 1 – Physical Devices
Layer 2 – Connectivity
Layer 3 – Edge Computing
Layer 4 – Data Accumulation
Layer 5 – Data Analysis
Layer 6 – Application
Layer 7 – Collaboration & Processes
1. Physical Devices and Controllers: The IoT Reference Model starts with Layer1. It
includes all physical devices and controllers that might control multiple devices. These are
the “things” in the IoT, and they include a wide range of endpoint devices that send and
receive information. Today, the list of devices is already extensive. It will become almost
unlimited as more equipment is added to the IoT over time.
Devices are diverse, and there are no rules about size, location, form factor, or
origin. Some devices will be the size of a silicon chip. Some will be as large as vehicles. The
IoT must support the entire range. Dozens or hundreds of equipment manufacturers will
produce IoT devices. To simplify compatibility and support manufacturability, the IoT
Reference Model generally describes the level of processing needed from Layer 1 devices.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 94
2. Connectivity: Communications and connectivity are concentrated in layer 2. The most
important function of Layer 2 is reliable, timely information transmission. This includes
transmissions:
Between devices (Layer 1) and the network
Across networks (east-west)
Between the network (Layer 2) and low-level information processing occurring at
Layer 3
Traditional data communication networks have multiple functions, as evidenced by
the International Organization for Standardization (ISO) 7-layer reference model. However,
a complete IoT system contains many levels in addition to the communications network.
One objective of the IoT Reference Model is for communications and processing to be
executed by existing networks. The IoT Reference Model does not require or indicate
creation of a different network—it relies on existing networks. However, some legacy
devices aren’t IP-enabled, which will require introducing communication gateways. Other
devices will require proprietary controllers to serve the communication function.
However, over time, standardization will increase. As Layer 1 devices proliferate, the ways
in which they interact with Layer 2 connectivity equipment may change. Regardless of the
details, Layer 1 devices communicate through the IoT system by interacting with Layer 2
connectivity.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 95
3. Edge (Fog) Computing: The functions of Layer 3 are driven by the need to convert
network data flows into information that is suitable for storage and higher-level processing
at Layer 4 (data accumulation). This means that Layer 3 activities focus on high-volume
data analysis and transformation. For example, a Layer 1 sensor device might generate
data samples multiple times per second, 24 hours a day, 365 days a year. A basic tenet of
the IoT Reference Model is that the most intelligent system initiates information
processing as early and as close to the edge of the network as possible. This is sometimes
referred to as fog computing. Layer 3 is where this occurs.
Given that data is usually submitted to the connectivity level (Layer 2) networking
equipment by devices in small units, Layer 3 processing is performed on a packet-by-
packet basis. This processing is limited, because there is only awareness of data units—not
“sessions” or “transactions.” Layer 3 processing can encompass many examples, such as:
Evaluation: Evaluating data for criteria as to whether it should be processed at a
higher level
Formatting: Reformatting data for consistent higher-level processing
Expanding/decoding: Handling cryptic data with additional context (such as the origin)
Distillation/reduction: Reducing and/or summarizing data to minimize the impact of
data and traffic on the network and higher-level processing systems
Assessment: Determining whether data represents a threshold or alert; this could
include redirecting data to additional destinations.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 96
4. Data Accumulation: Networking systems are built to reliably move data. The data is “in
motion.” Prior to Layer 4, data is moving through the network at the rate and organization
determined by the devices generating the data. The model is event driven. As defined
earlier, Layer 1 devices do not include computing capabilities themselves. However, some
computational activities could occur at Layer 2, such as protocol translation or application
of network security policy. Additional compute tasks can be performed at Layer 3, such as
packet inspection. Driving computational tasks as close to the edge of the IoT as possible,
with heterogeneous systems distributed across multiple management domains represents
an example of fog computing. Fog computing and fog services will be a distinguishing
characteristic of the IoT.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 97
Most applications cannot, or do not need to, process data at network wire speed. Applications typically assume that data is “at rest”—or unchanging—in memory or on disk. At Layer 4, Data Accumulation, data in motion is converted to data at rest. Layer 4 determines: If data is of interest to higher levels: If so, Layer 4 processing is the first level that is
configured to serve the specific needs of a higher layer. If data must be persisted: Should data be kept on disk in a non-volatile state or
accumulated in memory for short-term use? The type of storage needed: Does persistency require a file system, big data system,
or relational database? If data is organized properly: Is the data appropriately organized for the required
storage system? If data must be recombined or recomputed: Data might be combined, recomputed, or
aggregated with previously stored information, some of which may have come from non-IoT sources.
As Layer 4 captures data and puts it at rest, it is now usable by applications on a non-
real-time basis. Applications access the data when necessary. In short, Layer 4 converts event-based data to query-based processing. This is a crucial step in bridging the differences between the real-time networking world and the non-real-time application world. 5. Data Abstraction: IoT systems will need to scale to a corporate—or even global—level
and will require multiple storage systems to accommodate IoT device data and data from
traditional enterprise ERP, HRMS, CRM, and other systems. The data abstraction functions
of Layer 5 are focused on rendering data and its storage in ways that enable developing
simpler, performance-enhanced applications.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 98
With multiple devices generating data, there are many reasons why this data may not land
in the same data storage:
There might be too much data to put in one place.
Moving data into a database might consume too much processing power, so that
retrieving it must be separated from the data generation process. This is done today
with online transaction processing (OLTP) databases and data warehouses.
Devices might be geographically separated, and processing is optimized locally.
Layer 3 and 4 might separate “continuous streams of raw data” from “data that
represents an event.” Data storage for streaming data may be a big data system, such
as Hadoop. Storage for event data may be a relational database management system
(RDBMS) with faster query times.
Different kinds of data processing might be required. For example, in-store processing
will focus on different things than across-all-stores summary processing.
For these reasons, the data abstraction level must process many different things. These
include:
Reconciling multiple data formats from different sources
Assuring consistent semantics of data across sources
Confirming that data is complete to the higher-level application
Consolidating data into one place (with ETL, ELT, or data replication) or providing
access to multiple data stores through data virtualization
Protecting data with appropriate authentication and authorization
Normalizing or de-normalizing and indexing data to provide fast application access
6. Application: Layer 6 is the application level, where information interpretation occurs.
Software at this level interacts with Layer 5 and data at rest, so it does not have to operate
at network speeds.
The IoT Reference Model does not strictly define an application. Applications vary
based on vertical markets, the nature of device data, and business needs. For example,
some applications will focus on monitoring device data. Some will focus on controlling
devices. Some will combine device and non-device data. Monitoring and control
applications represent many different application models, programming patterns, and
software stacks, leading to discussions of operating systems, mobility, application servers,
hypervisors, multi-threading, multi-tenancy, etc. These topics are beyond the scope of the
IoT Reference Model discussion. Suffice it to say that application complexity will vary
widely.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 99
Examples include:
Mission-critical business applications, such as generalized ERP or specialized industry
solutions
Mobile applications that handle simple interactions
Business intelligence reports, where the application is the BI server
Analytic applications that interpret data for business decisions
System management/control center applications that control the IoT system itself and
don’t act on the data produced by it
If Layers 1-5 are architected properly, the amount of work required by Level 6 will be
reduced. If Layer 6 is designed properly, users will be able to do their jobs better.
7. Collaboration and Processes: One of the main distinctions between the Internet of
Things (IoT) and IoT is that IoT includes people and processes. This difference becomes
particularly clear at Layer 7: Collaboration and Processes. The IoT system, and the
information it creates, is of little value unless it yields action, which often requires people
and processes. Applications execute business logic to empower people. People use
applications and associated data for their specific needs. Often, multiple people use the
same application for a range of different purposes. So, the objective is not the
application—it is to empower people to do their work better. Applications (Layer 6) give
business people the right data, at the right time, so they can do the right thing.
But frequently, the action needed requires more than one person. People must be
able to communicate and collaborate, sometimes using the traditional Internet, to make
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 100
the IoT useful. Communication and collaboration often require multiple steps. And it
usually transcends multiple applications. This is why Layer 7, as shown in Figure,
represents a higher level than a single application.
Security in the IoT
Discussions of security for each level and for the movement of data between levels
could fill a multitude of papers. For the purpose of the IoT Reference Model, security
measures must:
Secure each device or system Provide security for all processes at each level
Secure movement and communication between each level, whether north- or south-
bound.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 101
5.5 Industrial IoT – Process, Advantages & Applications
Industrial IoT is a term used to describe machine-to-machine communications
where machines interact with other
machines, objects, and infrastructures
in order to produce data. The huge
volume of data gets generated and that
data gets processed and analyzed by
using technologies like data
analytics and artificial intelligence,
resulting in meaningful actions. It even
makes the use of smart sensors and actuators to enhance the manufacturing processes
and analyze the data in real-time.
Integration of IIoT can give industries a more accurate view of how their operations is
moving along and help them to make decisions fasters and more accurately. Some of the
top companies like IBM Corporation, Intel, Schneider Electric SE, General Electric
Company, and Emerson Electric etc. are implementing Industrial IoT to improve and
optimize their business operations.
Industrial IoT Solutions
Industrial IoT (IIoT) involves collecting and analyzing sensor-generated data to
support equipment monitoring and maintenance, production process analytics and
control, and more. In manufacturing IT since 1989, ScienceSoft offers IIoT consulting and
development to create secure IIoT solutions.
Industrial IoT (IIoT) uses interconnected smart sensors and edge technology in
industrial settings, such as manufacturing, energy, facilities-management, etc. to help
businesses run smoothly and utilize data to improve operations.
Industrial Internet of Things (IIoT)
Interconnected sensors, instruments, and other devices networked together with
computers’ industrial applications, including manufacturing and energy management. It is
important to note that IoT and IIoT have become very ‘buzzwordy’ because the goal is to
create a completely automated, smart factory, but for many manufacturers, that isn’t in
reach because of high costs in both dollars and time, at least for the next few years.
The industrial internet of things (IIoT) is the use of smart sensors and actuators to
enhance manufacturing and industrial processes. Also known as the industrial internet or
Industry 4.0, IIoT uses the power of smart machines and real-time analytics to take
advantage of the data that "dumb machines" have produced in industrial settings for
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 102
years. The driving philosophy behind IIoT is that smart machines are not only better than
humans at capturing and analyzing data in real time, but they're also better at
communicating important information that can be used to drive business decisions faster
and more accurately.
Connected sensors and actuators enable companies to pick up on inefficiencies and
problems sooner and save time and money, while supporting business intelligence efforts.
In manufacturing, specifically, IIoT holds great potential for quality control, sustainable and
green practices, supply chain traceability, and overall supply chain efficiency. In an
industrial setting, IIoT is key to processes such as predictive maintenance, enhanced field
service, energy management and asset tracking.
How does IIoT work?
IIoT is a network of intelligent devices connected to form systems that monitor,
collect, exchange and analyze data. Each industrial IoT ecosystem consists of
Connected devices that can sense, communicate and store information about
themselves
Public and/or private data communications infrastructure
Analytics and applications that generate business information from raw data
Storage for the data that is generated by the IIoT devices and
People.
These edge devices and intelligent assets transmit information directly to the data
communications infrastructure, where it's converted into actionable information on how a
certain piece of machinery is operating. This information can be used for predictive
maintenance, as well as to optimize business processes.
Uses, Applications & Benefits of Industrial IoT in Manufacturing
The introduction of IoT has opened gates for multitude of possibilities of performance upgrades through total control. IoT has moved out from our homes and offices to the industrial segment, and hence known to become IIoT (Industrial Internet of Things). Industrial IoT in manufacturing industry is a core element of the transformation, and by far it has seen the most investment, which makes for a promising future.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 103
Manufacturing is poised to keep
that first position across the globe
until at least 2020, even if, in some
geographies, this leading position
is more prominent. The
manufacturing industry is leading
in the Internet of Things for
various reasons, such as the
promising industrial revolution
(Industry 4.0) and then there are
the many cases of actual IoT
deployments that offer rapid
return and enable manufacturers to realize digital transformations from several
perspectives: efficiency, automation, customer-centricity, competitive benefits and the
advantages which are offered by using data across the manufacturing value chain and to
tap into new revenue sources, which is a key aspect of industry 4.0 in manufacturing.
1. Inventory Management: Monitoring of events across the supply chain is now possible
through IoT Application. Using these systems, the inventory is tracked across the globe on
a line-item level and the users are notified of any significant deviations from the plans, or
even updates. This provides cross-channel visibility into inventories and managers are
provided with realistic estimates of the available material, work in progress and the
estimated arrival time of new materials. Ultimately this optimizes supply and reduces
shared costs in the value chain.
2. Quality Control: IoT sensors collect aggregate product data and other third-party
syndicated data from various stages of a product cycle. This data relates to the complete
composition of raw materials used, temperature and working environment, wastes, the
impact of transportation and more on the final products. Moreover, if used in the final
product, the IoT device can provide data about the customer sentiments on using the
product. All of these inputs can later be analyzed to identify and correct quality issues,
which leads to significant improvement.
3. Enhanced Safety: Big Data analysis is effectively possible with Industrial Internet of
Things. Key performance indicators of health and safety, such as number of injuries, short-
and long-term absences, illness rates, near-misses, can thus be monitored constantly to
ensure better workplace conditions. Lagging indicators like the number of accidents can be
addressed immediately.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 104
4. Smart Metering: IIoT has seen to the introduction of various smart meters. These Smart
meters can monitor the consumption of resources like electricity, fuels, water etc. Through
the use of IoT sensors, manufacturers will know exactly how much is consumed and what
for. Through effective management, operational expenditure can be reduced significantly.
5. Predictive Maintenance: It is the era of preventive maintenance, with Industrial IoT in
Manufacturing we have not only seen a revolution in the machine maintenance system,
but also its delivery. For the first time, predictive maintenance is delivered through
hardware, which takes machine health monitoring beyond cloud computing, into edge
computing. This means faster processing and on spot analysis. Infinite Uptime, which is
ranked amongst the top 25 IoT solutions provider globally, is the only company providing it
through their patented technology. Predictive maintenance (PdM) techniques are
designed to help determine the condition of equipment’s in order to predict when
maintenance should be performed or possible breakdowns. This promises cost savings
over routine or time-based preventive maintenance, as the tasks are performed only when
warranted.
6. Smart Packaging: By using IoT sensors in products and packaging, manufacturers can
gain valuable insights into the usage patterns and handling of product from multiple
customers. Smart tracking mechanisms can be used to track product deterioration during
transit and impact of weather, road and other environment variables on the product. This
in turn offers insights that can be used to re-engineer products and packaging for better
performance in both customer experience and at times, even the cost of packaging.
7. Digital Industries: IoT enabled machinery can transmit operational information to the
partners like OEMs (original equipment manufacturers) and to field engineers. This will
enable operation managers and factory heads to remotely manage the factory units and
take advantage of process automation and optimization. This makes streamlining the day-
to-day work effortless.
Industrial IoT in Manufacturing is indeed empowering the industrial revolution
(industry 4.0). Top companies have been the beneficiaries of integrating IoT enabled
services, the list of the names include Amazon, Hitachi, John Deere, Komatsu, Maersk and
many more.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 105
Advantages of Using IIoT
IIoT increases productivity, efficiency, decision-making, reduce the cost and enable
an organization with real-time information and operational benefits. Some of the benefits
are:
1. Reduces the downtime of Machines: When thinking about the most benefit of IIOT,
improvising machine failure comes on the top of the list. Unplanned downtime/machine
breakdown is likely to occur in the manufacturing industry, which reduces their overall
productivity, customer service, and affecting the business as a whole. If manufacturing
industries invest in the Industrial Internet of Things (IIoT), they can gain real-time
information about assets and production processes.
The specialized sensors deployed at every point, track all the parameters of the
individual device and gains granular visibility across the operations. The availability of real-
time machine data enables manufacturers to react to machine failures.
2. Easy tracking and monitoring of Goods: Tracking is another perk of Industrial IoT.
Manufacturers can receive insights in a way customers handle products through the use of
IoT sensors in products and packaging. Suppliers, manufacturers, and customers can use
smart tracking tools to track the goods that may be damaged during transit, track the
location, status, and condition throughout the supply chain. The real-time insights can help
the managers to know if goods are damaged or at risk and can take immediate action to fix
it.
3. Provides condition-based Alerts: The sensors deployed inside the manufacturing
equipment triggers the alerts based on specific conditions like certain temperature or
min/max vibration range. Whenever the equipment deviates from its prescribed
parameters, IoT sensors that are actively monitoring the machines sends alerts. This alert
helps the manufacturers to conserve energy, increase operational efficiency and ensures
that machines are working in their specified parameters.
4. Minimizes Human Errors: Human error is likely to occur where manual operations are
involved. This not only leads to hassle but also leads to serious problems like lost profits or
any emergency situation. IIoT applications can reduce and prevent errors in inventory
management, operational management, and production flow. With IIoT applications, tasks
are automated and there is less human intervention; companies can improve the quality,
monitor events across the supply chain and track inventory across the globe.
`
Go to Table of Content NTTF_CP15 _DIPLOMA IN MECHATRONICS ENGINEERING & SMART FACTORY _SEM 5_EMBEDDED SYSTEMS & IOT_COURSE CONTENT 106
IIoT Applications
1. Facility Management
2. Production Flow Monitoring
3. Inventory Management
4. Logistics and Supply Chain Optimization
5. Industrial Automation
6. Smart Robotics
7. Autonomous Vehicles
8. Power Management
9. Smart City Applications
10. Smart Farming and Live Stock Monitoring
11. Energy Consumption Optimization
12. Automated and remote equipment management and monitoring
13. Predictive maintenance
14. Faster implementation of improvements
15. Quality control
16. Plant safety improvement