You are on page 1of 72

Chapter 1

Introduction to Microcontrollers

1.1 Introduction

A Microcontroller is a tiny, low-cost and self-contained computer on a chip that can be


used as an embedded system. A Microcontroller is a programmable digital processor with
essential peripherals.

1.1.1 Microcontroller Vs Microprocessors

 A microprocessor is a single chip CPU (Central Processing Unit) in which the memory
and peripherals are connected externally. A microcontroller consists of processor,
peripherals include Memory (RAM and ROM), I/O ports, Timers/Counters,
Communication Interface, ADC etc.
 A microcontroller does not require additional interfacing ICs for operation and it
functions as a stand-alone system.
 Microcontrollers are used for specific applications whereas microprocessors are used for
general purpose applications.
 Microcontrollers consume less power as compared to microprocessors.
 Software protection is possible in microcontrollers because of on-chip code memory.
Software protection is not possible in microprocessors since it requires external code
memory.
 Microcontrollers are highly reliable than microprocessors.
 Microcontrollers operate on low speed as compared to microprocessors
 The clock speed of a microcontroller varies from a few MHz to 50 MHz whereas the
microprocessors can operate clock speed above 1 GHz.
 The design complexity is higher in microprocessor as compared to microcontroller.
 Microcontrollers are less expensive than the microprocessors.

1.1.2 List of Terms Used in a Microprocessor


The list of frequently used terms in a microprocessor is:
 Instruction Set − It is the set of instructions that the microprocessor can understand.
 Bandwidth − It is the number of bits processed in a single instruction.

`
 Clock Speed − It determines the number of operations per second the processor can
perform. It is expressed in megahertz (MHz) or gigahertz (GHz).It is also known as
Clock Rate.
 Word Length − It depends upon the width of internal data bus, registers, ALU, etc. An
8-bit microprocessor can process 8-bit data at a time. The word length ranges from 4 bits
to 64 bits depending upon the type of the microcomputer.
 Data Types − The microprocessor has multiple data type formats like binary, BCD,
ASCII, signed and unsigned numbers.
1.1.3 Features of a Microprocessor
The features of any microprocessor are:
 Cost-effective − The microprocessor chips are available at low prices and results its low
cost.
 Size − The microprocessor is of small size chip, hence is portable.
 Low Power Consumption − Microprocessors are manufactured by using metal oxide
semiconductor technology, which has low power consumption.
 Versatility − The microprocessors are versatile as we can use the same chip in a number
of applications by configuring the software program.
 Reliability − The failure rate of an IC in microprocessors is very low, hence it is reliable.

1.1.4 Types of Microprocessors


 Complex Instruction Set Microprocessors
This type of microprocessor is also known as CISM. CISM classify a micro-processor
in which each & every order can be executed together with several other low-level
functions. These Functions are intended to carry out actions such as- uploading data into
memory card, re-calling or downloading data from memory card or a complex
mathematics computation in a single command.
 Reduced Instruction Set Microprocessors
It is also known as RISC, this was intended to pace up computer microprocessors.
These chips are built up under the guideline that permits the microprocessor to do a
smaller amount of things within each command and this will permit it to complete more
commands more rapidly.
 Superscalar processors

`
This types of processor replica the hardware on the micro-processor so that it can
perform numerous instructions at the same time. These replica resources can be
committed arithmetic logic units or multipliers. Superscalar processor comprise of
several operational units. Superscalar micro-processors carry out more than one
command throughout a single clock cycle by concurrently transmitting numerous
instructions to superfluous operational units in the processor.
 The Application Specific Integrated Circuit
It is also known as ASIC microprocessor is intended for extremely precise purposes,
which possibly will comprise- automotive emissions control or Personal Digital
Assistants computers. ASICs at times is produced to specification, but can also be
manufactured by making use of off-the-shelf gears.
 Digital Signal Multiprocessors (DSPs)
DSPs are unique micro-processors employed to decode & encode video, or convert
digital or video to analog and vice-versa. These operations need a micro-processor
particularly excellent at carrying out mathematical calculations. DSP chips are generally
employed in SONAR, mobile telephones, RADAR, home theater audio gears and cable
set-top boxes.
1.1.5 Classification of Microprocessors
A microprocessor can be classified into three categories which are:
 RISC processors
 CISC processors
 Special processors

`
1.1.6 RISC Processor
RISC stands for Reduced Instruction Set Computer. It is designed to reduce the execution
time by simplifying the instruction set of the computer. Using RISC processors, each instruction
requires only one clock cycle to execute results in uniform execution time. This reduces the
efficiency as there are more lines of code, hence more RAM is needed to store the instructions.
The compiler also has to work more to convert high-level language instructions into machine
code.
Some of the RISC processors are:
 Power PC: 601, 604, 615, 620
 DEC Alpha: 210642, 211066, 21068, 21164
 MIPS: TS (R10000) RISC Processor
 PA-RISC: HP 7100LC
1.1.7 Characteristics of RISC
The major characteristics of a RISC processor are as follows.
 It consists of simple instructions.
 It supports various data-type formats.
 It utilizes simple addressing modes and fixed length instructions for pipelining.
 It supports register to use in any context.
 One cycle execution time.
 “LOAD” and “STORE” instructions are used to access the memory location.
 It consists of larger number of registers.
 It consists of less number of transistors.

`
1.1.8 CISC Processor
CISC stands for Complex Instruction Set Computer. It is designed to minimize the number of
instructions per program, ignoring the number of cycles per instruction. The emphasis is on
building complex instructions directly into the hardware.
The compiler has to do very little work to translate a high-level language into assembly level
language/machine code because the length of the code is relatively short, so very little RAM is
required to store the instructions.
Some of the CISC Processors are −
 IBM 370/168
 VAX 11/780
 Intel 80486
1.1.9 Characteristics of CISC
 Variety of addressing modes.
 Larger number of instructions.
 Variable length of instruction formats.
 Several cycles may be required to execute one instruction.
 Instruction-decoding logic is complex.
 One instruction is required to support multiple addressing modes.
1.1.10 Special Processors
These are the processors which are designed for some special purposes. Few of the special
processors are given below.
1.1.11 Coprocessor
A coprocessor is a specially designed microprocessor, which can handle its particular function
many times faster than the ordinary microprocessor.
Example:
Math Coprocessor.
Some Intel math-coprocessors are −
 8087-used with 8086
 80287-used with 80286
 80387-used with 80386

`
1.1.12 Input/Output Processor
It is a specially designed microprocessor having a local memory of its own, which is used to
control I/O devices with minimum CPU involvement.
Example:
 DMA (direct Memory Access) controller
 Keyboard/mouse controller
 Graphic display controller
 SCSI port controller
1.1.13 DSP (Digital Signal Processor)
This processor is specially designed to process the analog signals into a digital form. This is
done by sampling the voltage level at regular time intervals and converting the voltage at that
instant into a digital form. This process is performed by a circuit called an analogue to digital
converter, A to D converter or ADC.
A DSP contains the following components.
 Program Memory − It stores the programs that DSP will use to process data.
 Data Memory − It stores the information to be processed.
 Compute Engine − It performs the mathematical processing, accessing the program from
the program memory and the data from the data memory.
 Input/Output − It connects to the outside world.
The applications of DSP are
 Sound and music synthesis
 Audio and video compression
 Video signal processing
 2D and 3d graphics acceleration.
Example:
Texas Instrument’s TMS 320 series, e.g., TMS 320C40, TMS320C50.
1.2 Evolution of Microcontroller

In 1975, Intel fabricated a chip (Intel 8048) with inbuilt RAM and ROM which was widely
used in varieties of applications. The EPROM and PROM included later in the microcontrollers.
The EPROM can be erased and re-programmed but it is expensive, whereas the PROM could be
programmed only once. In the year 1993, EEPROM memory was introduced in the

`
microcontrollers which electrically erasable and at affordable price. Atmel used the Flash
memory and launched the first microcontroller.
The Intel Corporation released an 8-bit version in the year 1981 called the IC8051 which became
popular and widely used for industrial applications.
A microcontroller can be considered a self-contained system with a processor, memory and
peripherals and can be used as an embedded system.The majority of microcontrollers in use
today are embedded in other machinery, such as automobiles, telephones, appliances, and
peripherals for computer systems.
1.2.1 Types of Microcontrollers
 8-bit microcontroller
When in-house bus in a MCU is 8-bit bus then the ALU carries out the logic & arithmetic
operations on a byte at an order. The MCU is 8-bit micro-controller. The illustrations of 8-bit
MCU are- Intel 8031/8051, Motorola MC68HC11 & PIC1x families.
 16-bit microcontroller
The 16 bit Microcontroller consists of a 16 bit bus and the ALU performs arithmetic and
logic operations on the 16 bit operand. It provides greater precision and performance as
compared to 8 bit MCU.
 32-bit microcontroller
When in-house bus for the data transmitting function in an MCU is 32-bit bus then the ALU
carries out logic & arithmetic functions on operand words of 32 bits at the orders. The MCU
is 32-bit micro-controller. These supply better accuracy and performance in comparison to the
16-bit MCUs.
 Embedded microcontroller
When a fixed or embedded system includes an MCU that has each hardware and software
parts in a solo unit, the MCU is known as embedded micro-controller. Extremely few or no
extra peripheral unit or system exists for processing during the control or making use of the
peripheral devices. For illustration, a telephone receiver circuit employs an in-built or
embedded micro-controller.
 External memory micro-controller
When an in-built or embedded system adds an MCU that has each of the hardware and
software parts present not as a solo component and has all or a piece of the memory
component externally interfaced by bringing into play an interfacing circuit which is known

`
as the glue circuit, the MCU is known as a peripheral or external memory micro-controller.
For instance, 8031 comprise of a program memory which is interfaced outwardly to it. The
8051 has both in-house as well as peripheral program memory.

1.2.2 Different Families of Microcontroller:


Intel Family
Intel Corporation introduced the 8051 microcontroller. It is 8-bit, inbuilt RAM and ROM,
timers/Counters, Serial ports, 12 clocks per instruction etc. But the 8051 microcontroller does not
have an in built memory bus and Analog to Digital Converters (ADC). In 1980, Intel fabricated
the single chip microcontroller 8051 with Harvard architecture.

PIC Family

PIC (Programmable Interface Controller) microcontrollers are slightly older than 8051
microcontrollers and it offers high performance. The single chip PIC microcontroller was
introduced by Microchip technology fabricated with Harvard architecture. The programming part
is very complex and hence it is not suitable choice for beginners.

AVR Family

In the year 1996, Atmel fabricated the single chip AVR microcontroller with a modified
Harvard Architecture. This chip is loaded with C- compiler, Free IDE (Integrated Development
Environment) and it has lot of features. This microcontroller is little bit difficult for the beginners
to handle.

1.2.3 Selection Criteria of Microcontroller

The most important selection criteria of microcontroller are:

 Maximum speed
 On-chip RAM and ROM capacity
 Cost efficient
 On-chip peripherals
 Number of I/O pins

`
Microcontroller has an input device in order to get the input and an output device to display
the final process output. For example, Microcontroller is used in electronic applications such as
Television. The Television has a remote control which is input device and the TV screen is the
output device. The signal sent from the remote control is captured by the microcontroller. The
microcontroller controls the channel selection, the amplifier system and picture tube adjustments
such as hue, brightness, contrast etc.
1.2.4 Special Features of Microcontroller

 Power Management
Most of the microcontrollers usually operate on voltage between 3 - 5.5 V. The
microcontroller is equipped with the efficient metering systems and it helps the
microcontroller to save the power to a large extent.
 Touch Screen
The microcontrollers having the feature of touch screen facility. Hence it has an extensive
application in cell phones, media players and gaming sector.
 Automobile Sector
The 8051 microcontroller has an extensive application in the automobile sectors and
specifically in hybrid vehicle management.
 LED Lighting
Microcontrollers are used for led lighting in residential and industrial applications in
order to enable greater control and power savings.
 Personal Medical Devices
The microcontrollers are widely used in portable medical devices such as blood
pressure and glucose level monitoring. It is highly reliable in providing medical results.

1.2.5 Instruction Set


Based on the instruction set configuration, the microcontroller is further divided into two
categories.

 CISC − CISC stands for Complex Instruction Set Computer. It allows the user to insert a
single instruction as an alternative to many simple instructions.

 RISC − RISC stands for Reduced Instruction Set Computers. It reduces the operational
time by shortening the clock cycle per instruction.
1.2.6 Programming in Microcontroller

`
Microcontrollers were originally programmed only in assembly language, but various high-
level programming languages, such as C, Python and JavaScript, are now also in common use to
target microcontrollers and embedded systems.These languages are either designed specially for
the purpose, or versions of general purpose languages such as the C programming language.
Simulators are available for some microcontrollers. A simulator will show the internal processor
state and also that of the outputs, as well as allowing input signals to be generated .
Recent microcontrollers are often integrated with on-chip debug circuitry that when accessed by
an in-circuit emulator (ICE) via JTAG, allow debugging of the firmware with a debugger. A
real-time ICE may allow viewing and/or manipulating of internal states while running. A tracing
ICE can record executed program and MCU states before/after a trigger point.
1.2.7 Applications of Microcontrollers
Microcontrollers are used in wide range of products which are automatically controlled. The
various products that make use of microcontrollers in our everyday life are:
 Home Appliances
 Television
 DVD player
 Telephone
 Cellular Phones
 Camera
 Security systems
 Sewing machine
 Musical instrument
 Exercising machine
 Video games
 Microwave oven
 Computer
 Office
 Computers
 Fax machine
 Printers
 Security Systems
 Telephones

`
1.3 Memory Types

A Memory module is a physical device which is used to store user programs or data in a
temporary or permanent manner. The different types of memory modules are available based on
the nature of the applications. The selection of a memory module is an essential part in designing
a microcontroller based applications. All memory structures have an address bus and a data bus.

The various types of memories used in microcontroller are

 RAM (Random Access Memory)


 ROM (Read Only Memory)
 Flash Memory

1.3.1 RAM (Random Access Memory)

This is the volatile memory which means that the stored programs and data are lost when
the power is shut off. It offers fast read access times. There are different types of RAM. They
are:
 Static RAM
 Dynamic RAM

1.3.1.1 Static RAM

The Static RAM (SRAM) uses transistor to store a single bit of data. Its structure is
complex than Dynamic RAM (DRAM). It does not need periodic refreshment to maintain data. It
is more expensive and faster than DRAM. It is used in Cache memory.

1.3.1.2 Dynamic RAM

The Dynamic RAM (DRAM) uses a separate capacitor to store each bit of data. It is
available in large storage capacity. It needs the data to be refreshed periodically to retain the
data. It consumes high power. It is used in Main memory.

1.3.2 ROM (Read Only Memory)

It is a non-volatile memory which means that the stored programs are retained even if the
power is shut off. Data stored in ROM neither be erased nor replaced. The instructions are

`
written in ROM at the time of manufacturing and it is used to execute on start-up of computer
and makes the system ready for work. It contains a set of start-up instructions to check that
memory is functioning well and check for other hardware devices. These instructions also check
for an operating system and load its necessary part to RAM.

The different types of ROM are:

 PROM (Programmable ROM)


 EPROM (Erasable Programmable ROM)
 EEPROM (Electrically Erasable Programmable ROM)

1.3.2.1 PROM (Programmable ROM)

It is a memory chip in which the data is written only once. Once the data is written, it
cannot be altered. It can be executed at a very high speed and it is used for converting critical and
lengthy operations into micro-programs that are fused into a chip. The fuse is existed for every
bit of the PROM and it is programmed by blowing the fuses. If any error occurs, it cannot be
removed and it is unusable. It is also referred to as OTP (One Time Programmable).

1.3.2.2 EPROM (Erasable Programmable ROM)

It is initially blank and the user can write programs and data on it using special ultraviolet
rays. The data written on EPROM can be erased and reprogrammed with the help of electrical
pulses.

1.3.2.3 EEPROM (Electrically Erasable Programmable ROM)

It can be erased and reprogrammed by exposing it to an electrical charge. It retains its


contents even if the power is switched off. It can be erased single byte at a time, rather than
erasing the entire chip with ultraviolet light.

1.3.2.4 Flash Memory

It is a non-volatile memory chip used for storage and for transferring data between a
personal computer (PC) and digital devices. Devices uses flash memory erases data at the block
level and rewrite data at the byte level. It is used in a wide range of consumer devices include
USB (Universal Serial Bus) flash drives, smart phones, tablet computers, digital cameras and
embedded controllers.

`
The architecture of flash memory consists of a memory array stacked with a large number
of flash cells. It has a grid of columns and rows with a cell that has two transistors at each
intersection. It consists of afloating-gate transistor which based on complementary metal-oxide
semiconductor (CMOS) technology used to hold an electrical charge in a memory to store data.

Flash memory devices operates on two different technologies which are NAND and NOR
to map the data. NOR flash provides high-speed random access, reading and storing data in
specific memory locations. NAND flash is used to read and write data sequentially at high speed.
It handles data in tiny blocks called pages. It is used in digital cameras, audio and video players,
solid-state and USB flash drives, and TV set-top boxes. The time taken to read the contents is
faster than to write the data.

`
Chapter 2

Peripheral Devices
2.1 Peripherals

The microcontroller includes CPU, memory and peripheral devices. The various
peripheral devices are:

 I/O ports
 Timers/Counters
 ADC (Analog to Digital Converter)
 DAC (Digital to Analog Converter)
 Interrupt Control
 Real-Time Clock (RTC)
 UART (Universal Asynchronous Receiver Transmitter)

2.1.1 I/O Ports

It is used to facilitate the flow of signal between the CPU and the external devices. There
are 32 I/O pins in microcontroller which are configured as either input or output ports.

I/O port is the physical port that connects to communicate other hardware devices. I/O
interface is the software interfaces that allow the Operating System (OS) to communicate with
hardware devices. An I/O port generally refers to the physical port (e.g., DB-9, USB connector,
DB-25 connector, etc.

I/O Ports and Connectors

1 ICMB connectors
2 Video connector
3 Serial port B
4 Keyboard connector
5 Mouse connector

`
6 Serial port A
7 Parallel port connector
8 USB connectors 0 and 1

Intelligent Chassis Management Bus [ICMB] is a multi-drop, multi-master, 2-wire, half-


duplex, differential drive bus, using RS-485 transceivers.

Timers/Counters

Embedded systems often require mechanisms for counting the occurrence of events and for
performing tasks at regular intervals. Embedded processors are often equipped with hardware
support for this functionality. By providing this support, we can ensure that events are not missed
(within limits, of course) and that timing of behavior occurs at regular intervals.
A timer is a specialized type of clock which is used to measure time intervals. A timer that
counts from zero upwards for measuring time elapsed is often called a stopwatch. It is a device
that counts down from a specified time interval and used to generate a time delay.

Timers are used to generate timings of internal or external events, scheduling events, measuring
the width of a pulse, speed control of motors (PWM)‫‏‬, generation of complex waveforms and
frequency generation.

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. It is used to count the events happening
outside the microcontroller.

Difference between a Timer and a Counter

`
Timer Counter

The register incremented for every The register is incremented considering 1 to 0


machine cycle. transitions at its corresponding to an external input
pin (T0, T1).

Maximum count rate is 1/12 of the Maximum count rate is 1/24 of the oscillator
oscillator frequency. frequency.

A timer uses the frequency of the A counter uses an external signal to count pulses.
internal clock, and generates delay.

2.1.2 Analog to Digital Converter (ADC)

The ADC is used to convert analog input signal into digital output signal. Analog signals
are generated from the transducers and it is processed by the microcontroller in digital signal.
The data processing in digital signal reduces the effects of noise and increases the accuracy.

Analog-to-Digital converters (ADC) translate analog real world signals like temperature,
pressure, voltage, current, distance, or light intensity, into its equivalent digital signal.

Basic Operation of ADC

An ADC samples an analog waveform at uniform time intervals and assigns a digital value to
each sample. The digital value appears on the converter’s output in a binary coded format. The
value is obtained by dividing the sampled analog input voltage by the reference voltage and them
multiplying by the number of digital codes. The resolution of converter is set by the number of
binary bits in the output code.

ADC Process

There are mainly two steps involves in the process of conversion. They are
 Sampling and Holding
 Quantizing and Encoding
Sampling and Holding

`
In the process of Sample and hold (S/H), the continuous signal will gets sampled and hold the
value at a steady level for a particular least period of time. It is done to remove variations in
input signal which can alter the conversion process and thereby increases the accuracy. The
minimum sampling rate has to be two times the maximum data frequency of the input signal.

Quantizing and Encoding


For understanding quantizing, we can first go through the term Resolution used in ADC. It is
the smallest variation in analog signal that will result in a variation in the digital output. This
actually represents the quantization error.

V → Reference voltage range


2N → Number of states
N→Number of bits in digital output
Quantizing
It is the process in which the reference signal is partitioned into several discrete quanta and
then the input signal is matched with the correct quantum.
Encoding
For each quantum, a unique digital code will be assigned and after that the input signal is
allocated with this digital code.

ADC represents an analog signal, which has infinite resolution, as a digital code that has finite
resolution. The ADC produces 2N digital values where N represents the number of binary output
bits.

Types of ADC
The transducer’s electrical analog output serves as the analog input to the ADC. The ADC
converts this analog input to a digital output. This digital output consists of a number of bits that
represent the value of the analog input. An analog-to-digital converter takes an analog input
voltage and after a certain amount of time produces a digital output code which represents the

`
analog input. The A/D conversion process is generally more complex and time-consuming than
the D/A process.
The types of ADC are:

• Flash ADC
• Counter type ADC
• Sigma-delta ADC
• Dual slope ADC
• Successive approximation ADC
Flash type ADC
It is the fastest ADC among all the ADC types. In flash ADC of n-bit in size, (2n - 1)
comparators and 2 n registers are needed.Each comparator compares Vin to a different reference
voltage, starting with Vref = 1/2 (LSB). Op-amp is used as comparator.
Counter type ADC
It uses counter and DAC. It compares DAC output with analog voltage and does the same till
both are equal in magnitude. At this moment counter will stop. Maximum conversion time is
equal to (2n -1)* TCLK for n-bit of ADC. The conversion time depends on analog input voltage.
Sigma-delta type ADC
The serial output is proportional to analog input voltage. It has high resolution. It does not
require any external components. It is slow in conversion due to oversampling.
Dual Slope ADC

The dual-slope integration type of A/D conversion is a very popular method for digital
voltmeter applications. When compared to other types of ADC techniques, the dual-slope
method is slow but is quite adequate for a digital voltmeter used for laboratory measurements.

In the dual-slope technique, an integrator is used to integrate an accurate voltage reference for
a fixed period of time. The same integrator is then used to integrate with the reverse slope, the
input voltage, and the time required to return to the starting voltage is measured.
Successive Approximation type ADC
Successive Approximation type ADC is the most widely used and popular ADC method. The
conversion time is maintained constant in successive approximation type ADC, and is
proportional to the number of bits in the digital output, unlike the counter and continuous type
A/D converters. The basic principle of this type of A/D converter is that the unknown analog

`
input voltage is approximated against an n-bit digital value by trying one bit at a time, beginning
with the MSB.
It consists of a successive approximation register (SAR), DAC and comparator. The output of
SAR is given to n-bit DAC. The equivalent analog output voltage of DAC, VD is applied to the
non-inverting input of the comparator. The second input to the comparator is the unknown
analog input voltage VA. The output of the comparator is used to activate the successive
approximation logic of SAR. When the start command is applied, the SAR sets the MSB to logic
1 and other bits are made logic 0, so that the trial code becomes 1000.
This type of ADC operates by successively dividing the voltage range by half, as explained in
the following steps.
(1) The MSB is initially set to 1 with the remaining three bits set as 000. The digital equivalent
voltage is compared with the unknown analog input voltage.
(2) If the analog input voltage is higher than the digital equivalent voltage, the MSB is retained
as 1 and the second MSB is set to 1. Otherwise, the MSB is set to 0 and the second MSB is set to
1. Comparison is made as given in step (1) to decide whether to retain or reset the second MSB.
Advantages:
 Conversion time is very small.
 Conversion time is constant and independent of the amplitude of the analog input signal
VA.
Disadvantages:
 Circuit is complex.
 The conversion time is more as compared to flash type ADC.
2.1.2.1 Applications of ADC

 Digital Voltmeter – It measures voltage in analog form and converts it into equivalent
digital form.
 Voice Recorder – It uses ADC to convert analog voice information to the digital
information.
 Scanner – It uses ADC to convert analog information provided by the picture into digital
information.
 Mobile Phone –The voice in analog form is converted into digital form for speech
compression, encoding etc.

`
2.1.3 Digital to Analog Converter (DAC)

The DAC is used to convert digital input signal into analog output signal. It is used in
digital systems to provide interface with analog sensors. The digital data may be produced from a
microprocessor, Application Specific Integrated Circuit (ASIC), or Field Programmable Gate
Array (FPGA), but ultimately the data requires the conversion to an analog signal in order to
interact with the real world.

2.1.3.1 Applications of DAC

 MODEMS – It uses DAC to convert the digital data to analog form in order to carry the
analog signal over telephone lines.
 Digital Motor Control
 Sound Systems
 Function Generators
 Oscilloscopes
 Digital Audio Systems
 Video adapters

2.1.4 Interrupt Control

It is a signal to the microcontroller generated by hardware or software indicating an event


that needs immediate attention. The microcontroller responds to an interrupt by temporarily
suspending its current activities, saving its state and executing a function called an interrupt
handler to deal with the event. After servicing the interrupt, the microcontroller continues to
perform the normal activities.

2.1.5 Real Time Clock (RTC)

It is used to enable accurate time measurements for microcontroller operation. It is an


electronic device in the form of Integrated Chip (IC) available in different packing options.

2.1.6 UART (Universal Asynchronous Receiver Transmitter)

`
It is a hardware component that can transmit and receive digital data. It is used to perform
communications over the serial ports through an RS-232 serial interface standard. UART devices
can operate at various clock speeds.

It is a microchip which performs serial to parallel conversion of data received from


peripheral devices and parallel to serial conversion of data from the microcontroller to peripheral
devices.

`
Chapter 3

IC8051 Microcontrollers

3.1 IC8051 Microcontroller

An 8-bit microcontroller performs arithmetic and logical operations with 8-bits. The
examples of 8-bit microcontroller are IC8051 andIC8031. The IC8051 microcontroller is
launched in the year 1980 by Intel Corporation. The IC8031 is a member of the IC8051 family.
IC8031 has no on-chip ROM as compared to IC8051.

3.2 Features of IC8051 Microcontroller

 8-bit Microcontroller
 4 Kilobytes on-chip program memory (ROM)
 128 bytes on-chip data memory (RAM)
 128 user defined software flags
 Four register banks
 40-pin DIP IC
 8-bit bi-directional data bus
 16-bit unidirectional address bus
 32 general purpose registers each of 8-bit
 Two 16-bit Timers
 Three internal and two external interrupts
 Four 8-bit I/O ports
 8-bit Stack Pointer
 16-bit Program Counter and Data Pointer
 Operating frequency is 24MHz – 33MHz
 One Microsecond instruction cycle with 12 MHz crystal
 Operates on +5V Regulated DC Power Supply
 Full duplex UART
 It has 21 Special Function Registers (SFRs)
 Bit and Byte addressable

`
3.3 Block Diagram of Microcontroller

The fig.1 shows the basic layout of a microcontroller. The microcontroller includes
Processor Core, Memory (RAM and EEPROM), Timer/Counter module, Digital I/O module,
Analog module and Interrupt Controller.
The system bus connects all the support devices to the CPU. The system bus consists of an 8-bit
data bus, a 16-bit address bus and bus control signals. All other devices like program memory,
ports, data memory, serial interface, interrupt control, timers, and the CPU are all interfaced
together through the system bus.
3.3.1 Processor Core

It is the CPU of the microcontroller. It contains the Arithmetic Logic Unit (ALU), the
control unit, and the registers include program counter, stack pointer, accumulator, register file
etc.

3.3.2 Memory

The memory of the microcontroller is divided into program memory and data memory.
The program memory is used for storing of permanent programs and the data memory is used for
storing temporary storage of data. The EEPROM acts as program memory and the RAM acts as
data memory. A Direct Memory Access (DMA) controller is used to transfer data between
memory and peripheral components in larger microcontrollers.

3.3.3 Timer/Counter

A Timer/Counter module allows the microcontroller to perform tasks for certain time
periods. The 8051 microcontroller consists of two 16-bit timers and counters such as timer 0 and
timer 1. Both the timers consist of a 16-bit register in which the lower byte is stored in the TL
and the higher byte is stored in the TH. The Timer can be used as a counter as well as for timing
operation that depends on the source of the clock pulses to the counters.This module is used in
operations which include clock functions, frequency generation and measurement, modulation
and pulse generation.

The Timers and Counters in IC8051 microcontrollers contain two special function registers
which are

`
 TMOD (Timer Mode) register
 TCON (Timer Control) register

POWER SUPPLY – Vcc (+5V), Vss (GND)

Fig. 1 Basic layout of a microcontroller

3.3.4 Digital I/O Module

The important features of microcontroller are parallel digital I/O ports. The I/O ports are
multiplexed with alternate functions for the peripheral devices on the microcontroller. They are
used to interface peripherals such as printers, external memories, LEDs and LCDs to the
microcontroller. There are serial ports in microcontroller which is used to interface serially
connected peripherals with the microcontroller.

3.3.5 Analog Module

Microcontroller can read the analog voltage from the output of sensors and convert it into
digital by using Analog to Digital Converter (ADC). This digital signal is processed by the

`
microcontroller and converts it back into analog voltage as output by using Digital to Analog
Converter (DAC).

3.3.6 Serial Interface Module

It is used to interface the microcontroller with the peripheral devices. Serial communication is
the process of transmitting or receiving single bit at a time between the microcontroller and the
peripheral devices. The rate of serial data transmission is expressed in baud rate. The serial
communication is performed using UART (Universal Asynchronous Receiver and Transmitter).
Asynchronous indicates that data is transferred without the need of external clock signal. A
microcontrollers UART device has separate signals for transmitting and receiving serial data.
Asynchronous communication requires start bit, data bits, synchronization bits, parity bits and
stop bit.

3.3.7 Interrupt Controller

Interrupt is an event that suspends the main program temporarily and transfers the control to a
special routine which executes the event-related function. After the completion of event, the
program control returns back to the main program where the interrupt is called. Interrupt Service
Routine (ISR) is a code that tells the microcontroller what to do when the interrupt occurs.

Interrupts are classified as hardware and software interrupts. Hardware interrupts are
generated by the inbuilt devices of the microcontroller such as timer or by the interfacing
devices. Software interrupts are generated through the program.

8051 Interrupts

The various interrupts in IC8051 microcontroller are

 Two External interrupt (INT0 and INT1)


 Two Timer interrupt (T0 and T1)
 Serial interrupt (TI/RI)

The external interrupt flags are cleared when the processor branches to the interrupt service
routine, provides the interrupt is a negative edge triggered.

IE (Interrupt Enable) Register

`
This register is responsible for enabling and disabling the interrupt. EA register is set to one
for enabling interrupts and set to 0 for disabling the interrupts.
IP (Interrupt Priority) Register
The priority levels of the interrupts can be changed by changing the corresponding bit in the
Interrupt Priority (IP) register as shown in the following figure.
 A low priority interrupt can only be interrupted by the high priority interrupt, but not
interrupted by another low priority interrupt.
 If two interrupts of different priority levels are received simultaneously, the request of
higher priority level is served.
 If the requests of the same priority levels are received simultaneously, then the internal
polling sequence determines which request is to be serviced.
3.4 Registers in IC8051

A register is a tiny part in a CPU that can store small amount of data during arithmetic or
logical operations and loads the output on the memory. Registers contain the address of the
memory location where the data is to be stored.

3.4.1 Types of Registers

The IC8051 contains two types of registers

 General Purpose Registers (Byte addressable)


 Special Function Registers (Bit addressable)

The IC8051 microcontroller consists of 256 bytes of RAM memory which is divided into
two parts.

 128 bytes for general purpose


 128 bytes for special purpose registers
The RAM memory is used for general purpose which stores the data during the execution of
the program. The special function registers contains all the peripheral related registers like
Accumulator, ‘B’ register, Timers/Counters and interrupt related registers. The memory location
of RAM is divided into three areas include Banks, bit-addressable area and scratch-pad area. The
various general purpose registers of banks are R0-R7, and all these registers are byte-addressable
registers that store only single byte of data.

`
3.4.2 Accumulator (A)

It is an 8-bit addressable used for arithmetic operations. It is an essential register associated


with the ALU.It holds the result of arithmetic and logic operations.

3.4.3 B register

It is both a bit and byte-addressable register. It is used for multiply and divide operations. It can
also be used for general purpose operations.

3.4.4 Program Status Word (PSW) register

The flag register in the IC8051 is called the Program Status Word (PSW) register. It is an 8-bit
register. The four flags in IC8051 are

 Carry flag
 Auxiliary Carry flag
 Overflow flag
 Parity flag

3.4.4.1 Carry Flag

After the execution of arithmetic or logic operations, if there is a carry out of D 7th bit, this flag is
set. Otherwise, it is reset.

3.4.4.2 Auxiliary Carry Flag

This flag is set when there is a carry from digit D3 to D4after performing arithmetic operations.
Otherwise, it is reset. It is used in BCD operations.

3.4.4.3 Parity Flag

After the execution of arithmetic or logic operations, if the accumulator contains odd number
of 1’s, then the parity flag will be set. If the accumulator contains even number of 1’s, then the
parity flag will be reset.

3.4.4.4 Overflow flag

`
This flag is set whenever the result of a signed number operation is too large, causing the high-
order bit to overflow into the sign bit. It is used to detect errors in signed arithmetic operations.

3.4.4.5 RS1 and RS0

These two bits RS1 and RSO in PSW register are used to select various memory locations
(Bank0 to Bank3) in the RAM memory location.

RS1 RS0 Bank Selection


0 0 Bank0
0 1 Bank1
1 0 Bank2
1 1 Bank3

Format of Program Status Word (PSW) register

3.4.5 Stack Pointer (SP)

Stack is used to store the data temporarily in RAM locations. It is 8 bit register, it indicate the
address of the top of the stack. The operation of stack is Last-In First-Out.

3.4.6 Program Counter (PC)

The PC in the 8051 is 16-bits wide. It tells the microcontroller where the next instruction to
execute is found in memory. When the IC8051 is initialized, PC usually starts at 0000h and is
incremented each time an instruction is executed.

`
I/O Ports
8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or
output. Hence, total 32 input/output pins allow the microcontroller to be connected with the
peripheral devices. The I/O pins can be configured as 1 for input and 0 for output as per the
logic state.
Input Configuration
If any pin of this port is configured as an input, then it acts as if it “floats”, i.e. the input has
unlimited input resistance and in-determined potential.
Output Configuration
When the pin is configured as an output, then it acts as an “open drain”. By applying logic 0 to
a port bit, the appropriate pin will be connected to ground (0V), and applying logic 1, the
external output will keep on “floating”.
In order to apply logic 1 (5V) on this output pin, it is necessary to build an external pull-up
resistor.
Port 0
The P0 (zero) port is characterized by two functions.
 When the external memory is used then the lower address byte (addresses A0A7) is
applied on it, else all bits of this port are configured as input/output.
 When P0 port is configured as an output then other ports consisting of pins with built-in
pull-up resistor connected by its end to 5V power supply, the pins of this port have this
resistor left out.
Port 1
P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this port can be
configured as general I/O only. It has a built-in pull-up resistor and is completely compatible
with TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy addresses
intended for the external memory chip. This port can be used for higher address byte with
addresses A8-A15. When no memory is added then this port can be used as a general
input/output port similar to Port 1.

`
Port 3
In this port, functions are similar to other ports except that the logic 1 must be applied to
appropriate bit of the P3 register.

`
Chapter 4

Pin Diagram of IC8051

4.1 IC8051 Pin Diagram

The IC8051 is a 40-pin IC available in Dual-In line package (DIP). It requires a single +5V
power supply. The maximum internal clock frequency is 12 MHz.

Fig. 1 Pin Diagram of IC8051

`
4.1.1 Pins 1-8 (PORT 1)

These pins are called as port 1. It is used as 8-bit bi-directional Input/Output port with internal
pull-up resistors.

4.1.2 Pin 9 (RST)

It is a RESET pin. It is active in HIGH state. It this pin is HIGH for a minimum of two
machine cycles, the microcontroller will be reset.

4.1.3 Pins 10-17 (PORT 3)

These pins are the port 3 of the 8051 microcontroller. Port 3 acts as a bi-directional I/O port
with internal pull-ups. Port 3 is also performs various functions include interrupts, timer input,
control signals, and serial communication.

PORT 3 Pin Function Description

P3.0 RXD Serial Input

P3.1 TXD Serial Output

P3.2 INT0 External Interrupt 0

P3.3 INT1 External Interrupt 1

P3.4 T0 Timer 0

P3.5 T1 Timer 1

P3.6 WR External Memory Write

P3.7 RD External Memory Read

4.1.4 Pins 18 & 19 (XTAL2 and XTAL1)

These two input pins are on-chip oscillator and clock generator circuit. It is used for
interfacing an external crystal to get the system clock.

4.1.5 Pin 20 (GND)

`
This pin is grounded.

4.1.6 Pins 21-28 (PORT 2)

These pins are used for Port 2 of IC8051 microcontroller. Port 2 is used as I/O port. It also serves
as high order address bus (A8-A15).

4.1.7 Pin 29 (PSEN)

This is PSEN pin which stands for Program Store Enable. It is used to read a signal from the
external program memory.

4.1.8 Pin 30 (ALE)

This is ALE pin which stands for Address Latch Enable. It is used to de-multiplex the
multiplexed address/data bus AD7-AD0. The ALE is activated twice in every machine cycle. If
external RAM & ROM is not accessed, then ALE is activated at constant rate of 1/6 oscillator
frequency, which can be used as a clock pulses for driving external devices.

4.1.9 Pin 31 (EA)

This is EA pin which stands for External Access input. It is used to enable or disable external
memory.

4.1.10 Pins 32-39 (PORT 0)

These pins are called as port 0. It is used as I/O port. The lower address and data bus signals
are multiplexed using this port 0.

4.1.11 Pin 40 (Vcc)

This Vcc pin is used for power supply which is +5V DC.

4.2 Applications of 8051 Microcontroller

The applications of IC8051 are:


 Light sensing and controlling devices
 Temperature sensing and controlling devices
 Fire detections and safety devices

`
 Automobile applications (Engine Control, Temperature Control etc.)
 Rail Transport
 Defense applications
 Industrial Process Control
 Communication Systems (Mobile Phones, Intercoms, Paging devices etc.)
 Process control devices
 Voltmeter applications
 Measuring and revolving objects
 Current meter objects
 Hand held metering system
 Remote Sensing
 Security
 Robotics
 Consumer electronics (Remote Controls, Computers, TV Tuners, etc.)
 Medical Equipment

4.3 Graphics Processing Unit (GPU)

It is a processor designed to perform graphics operations. The purpose of GPU is to provide 3D


graphics, which are comprised of polygons. GPUs are designed to perform floating point
operations. It is used to manage and increase the performance of video and graphics. GPU is
widely used in smart phones, workstations, display adapters etc. The GPU is connected to the
CPU and is completely separate from the motherboard. A GPU is a heterogeneous chip multi-
processor.

GPU is made to process and output both 2D and 3D computer graphics. GPU implements
the graphics pipeline consisting of:

 Vertex transformations
 Geometry processing
 Rasterizing polygons to pixels
 Processing the pixels
 Writing to the framebuffer

`
GPU have faster and more advanced memory interfaces. It enables to run high definition
graphics on Personal Computer. It works as both a programmable graphics processor and a
scalable parallel computing platform. GPUs are an essential part of chipsets equipped with
modern smartphones.

The first GPU was developed by NVidia in 1999 and called the GeForce 256. This GPU model
could process 10 million polygons per second and had more than 22 million transistors. The
GeForce 256 was a single-chip processor with integrated transform, lighting effects, triangle
setup/clipping and rendering engines.The GPU is connected to the CPU and is completely
separate from the motherboard. The random access memory (RAM) is connected through the
accelerated graphics port (AGP) or the peripheral component interconnect express (PCI-Express)
bus.

4.4 Floating Point Unit (FPU)

An FPU is a processor that performs floating point calculations. It supports the real, integer and
BCD integer data types. It greatly improves the efficiency of Intel Architecture processors in
handling the high precision floating point processing operations. It can be defined as a
specialized coprocessor that can manipulate data faster than the basic microprocessor. It is
difficult to implement in hardware and it can be part of the CPU since it can be implemented as a
micro-program within the CPU.

`
Chapter 5

IC8051 Instruction Set

Instruction Set of IC8051

8051 instructions are classified into following groups

 Data transfer instructions


 Arithmetic instructions
 Logical instructions
 Boolean variable manipulation instructions
 Branch instructions

Abbreviations of Instruction set

Rn Register R7-R0 of the currently selected Register Bank


direct 8-bit internal data location’s address. This could be an Internal Data RAM
location or a Special Function Register [i.e., I/O port, control register, status
register, etc.]
@Ri 8-bit internal data RAM location (0-255) addressed indirectly through register
R1or R0.
#data 8-bit constant included in instruction.
#data 16 16-bit constant included in instruction
addr 16 16-bit destination address. Used by LCALL and LJMP. A branch can be
anywhere within the 64K byte Program Memory address space.
addr 11 11-bit destination address. Used by ACALL and AJMP. The branch will be
within the same 2K byte page of program memory as the first byte of the
following instruction.
rel Signed (two’s complement) 8-bit offset byte. Used by SJMP and all conditional
jumps. Range is -128 to +127 bytes relative to first byte of the following
instruction.
bit Direct Addressed bit in Internal Data RAM or Special Function Register.

`
Data Transfer Instructions

Data transfer instructions move the content of one register to another. The register the content of
which is moved remains unchanged. The MOVX instruction is used to exchange data between
microcontroller and external memory.

Mnemonic Description Byte Cycle

MOV A,Rn Moves the register to the accumulator 1 1

MOV A,direct Moves the direct byte to the accumulator 2 2

Moves the indirect RAM to the


MOV A,@Ri 1 2
accumulator

Moves the immediate data to the


MOV A,#data 2 2
accumulator

MOV Rn,A Moves the accumulator to the register 1 2

MOV Rn,direct Moves the direct byte to the register 2 4

MOV Rn,#data Moves the immediate data to the register 2 2

MOV direct,A Moves the accumulator to the direct byte 2 3

MOV direct,Rn Moves the register to the direct byte 2 3

MOV direct,direct Moves the direct byte to the direct byte 3 4

Moves the indirect RAM to the direct


MOV direct,@Ri 2 4
byte

Moves the immediate data to the direct


MOV direct,#data 3 3
byte

Moves the accumulator to the indirect


MOV @Ri,A 1 3
RAM

Moves the direct byte to the indirect


MOV @Ri,direct 2 5
RAM

`
Moves the immediate data to the indirect
MOV @Ri,#data 2 3
RAM

MOV DPTR,#data Moves a 16-bit data to the data pointer 3 3

Moves the code byte relative to the


MOVC A,@A+DPTR DPTR to the accumulator 1 3
(address=A+DPTR)

Moves the code byte relative to the PC to


MOVC A,@A+PC 1 3
the accumulator (address=A+PC)

Moves the external RAM (8-bit address)


MOVX A,@Ri 1 3-10
to the accumulator

Moves the external RAM (16-bit address)


MOVX A,@DPTR 1 3-10
to the accumulator

Moves the accumulator to the external


MOVX @Ri,A 1 4-11
RAM (8-bit address)

Moves the accumulator to the external


MOVX @DPTR,A 1 4-11
RAM (16-bit address)

PUSH direct Pushes the direct byte onto the stack 2 4

POP direct Pops the direct byte from the stack 2 3

Exchanges the register with the


XCH A,Rn 1 2
accumulator

Exchanges the direct byte with the


XCH A,direct 2 3
accumulator

Exchanges the indirect RAM with the


XCH A,@Ri 1 3
accumulator

Exchanges the low-order nibble indirect


XCHD A,@Ri 1 3
RAM with the accumulator

Arithmetic instructions
Arithmetic instructions perform arithmetic operations such as addition, subtraction,
multiplication and division.

`
Mnemonic Description Byte Cycle

ADD A, Rn Adds the register to the accumulator 1 1

ADD A, direct Adds the direct byte to the accumulator 2 2

Adds the indirect RAM to the


ADD A, @Ri 1 2
accumulator

Adds the immediate data to the


ADD A, #data 2 2
accumulator

Adds the register to the accumulator with


ADDC A, Rn 1 1
a carry flag

Adds the direct byte to the accumulator


ADDC A, direct 2 2
with a carry flag

Adds the indirect RAM to the


ADDC A, @Ri 1 2
accumulator with a carry flag

Adds the immediate data to the


ADDC A, #data 2 2
accumulator with a carry flag

Subtracts the register from the


SUBB A, Rn 1 1
accumulator with a borrow

Subtracts the direct byte from the


SUBB A, direct 2 2
accumulator with a borrow

Subtracts the indirect RAM from the


SUBB A, @Ri 1 2
accumulator with a borrow

Subtracts the immediate data from the


SUBB A, #data 2 2
accumulator with a borrow

INC A Increments the accumulator by 1 1 1

INC Rn Increments the register by 1 1 2

INC Rx Increments the direct byte by 1 2 3

INC @Ri Increments the indirect RAM by 1 1 3

`
DEC A Decrements the accumulator by 1 1 1

DEC Rn Decrements the register by 1 1 1

DEC Rx Decrements the direct byte by 1 1 2

DEC @Ri Decrements the indirect RAM by 1 2 3

INC DPTR Increments the Data Pointer by 1 1 3

MUL AB Multiplies A and B 1 5

DIV AB Divides A by B 1 5

Decimal adjustment of the accumulator


DA A 1 1
according to BCD code
Logical Instructions

Logic instructions perform logic operations such as AND, OR, X-OR, Complement and
rotate bits of two registers.

Mnemonic Description Byte Cycle

ANL A, Rn AND register to accumulator 1 1

ANL A, direct AND direct byte to accumulator 2 2

ANL A, @Ri AND indirect RAM to accumulator 1 2

ANL A, #data AND immediate data to accumulator 2 2

ANL direct, A AND accumulator to direct byte 2 3

ANL direct, #data AND immediate data to direct register 3 4

`
ORL A, Rn OR register to accumulator 1 1

ORL A, direct OR direct byte to accumulator 2 2

ORL A, @Ri OR indirect RAM to accumulator 1 2

ORL direct, A OR accumulator to direct byte 2 3

ORL direct, #data OR immediate data to direct byte 3 4

XRL A, Rn Exclusive OR register to accumulator 1 1

XRL A, direct Exclusive OR direct byte to accumulator 2 2

XRL A, @Ri Exclusive OR indirect RAM to accumulator 1 2

XRL A, #data Exclusive OR immediate data to accumulator 2 2

XRL direct, A Exclusive OR accumulator to direct byte 2 3

XRL direct, #data Exclusive OR immediate data to direct byte 3 4

CLR A Clears the accumulator 1 1

CPL A Complements the accumulator (1=0, 0=1) 1 1

SWAP A Swaps nibbles within the accumulator 1 1

RL A Rotates bits in the accumulator left 1 1

`
Rotates bits in the accumulator left through
RLC A 1 1
carry

RR A Rotates bits in the accumulator right 1 1

Rotates bits in the accumulator right through


RRC A 1 1
carry

Boolean Variable Manipulation Instructions


It is similar to logic instructions, it performs logic operations. The difference is that these are
performed upon single bits.

Mnemonic Description Byte Cycle

CLR C Clears the carry flag 1 1

CLR bit Clears the direct bit 2 3

SETB C Sets the carry flag 1 1

SETB bit Sets the direct bit 2 3

CPL C Complements the carry flag 1 1

CPL bit Complements the direct bit 2 3

ANL C, bit AND direct bit to the carry flag 2 2

ANL C, /bit AND complements of direct bit to the carry flag 2 2

ORL C, bit OR direct bit to the carry flag 2 2

ORL C, /bit OR complements of direct bit to the carry flag 2 2

MOV C, bit Moves the direct bit to the carry flag 2 2

MOV bit, C Moves the carry flag to the direct bit 2 3

`
Branch Instructions

These instructions can change the sequence of program execution. There are two types of
branch instructions.

 Unconditional jump instructions


 Conditional jump instructions

Mnemonic Description Byte Cycle

ACALL addr11 Absolute subroutine call 2 6

LCALL addr16 Long subroutine call 3 6

RET Returns from subroutine 1 4

RETI Returns from interrupt subroutine 1 4

AJMP addr11 Absolute jump 2 3

LJMP addr16 Long jump 3 4

Short jump (from –128 to +127 locations relative


SJMP rel 2 3
to the following instruction)

JC rel Jump if carry flag is set. Short jump. 2 3

JNC rel Jump if carry flag is not set. Short jump. 2 3

JB bit,rel Jump if direct bit is set. Short jump. 3 4

Jump if direct bit is set and clears bit. Short


JBC bit,rel 3 4
jump.

JMP @A+DPTR Jump indirect relative to the DPTR 1 2

JZ rel Jump if the accumulator is zero. Short jump. 2 3

JNZ rel Jump if the accumulator is not zero. Short jump. 2 3

Compares direct byte to the accumulator and


CJNE A,direct,rel 3 4
jumps if not equal. Short jump.

`
Compares immediate data to the accumulator and
CJNE A,#data,rel 3 4
jumps if not equal. Short jump.

Compares immediate data to the register and


CJNE Rn,#data,rel 3 4
jumps if not equal. Short jump.

Compares immediate data to indirect register and


CJNE @Ri,#data,rel 3 4
jumps if not equal. Short jump.

Decrements register and jumps if not 0. Short


DJNZ Rn,rel 2 3
jump.

Decrements direct byte and jump if not 0. Short


DJNZ Rx,rel 3 4
jump.

NOP No operation 1 1

`
Chapter 6

IC8051 Interfacing

6.1 Interfacing of Digital I/O with IC8051

Interfacing can be defined as transmitting data between microcontrollers and peripherals include
keyboard, ADC, sensors, LCD displays, motors etc. It is essential to interface the microcontroller
with the I/O devices include keyboard, mouse, printer etc. The IC8051 microcontroller has four
I/O ports each comprising 8-bits which can be configured as input or output.

The ports are classified as two types.

 Serial Port
 Parallel Port

6.2 Serial Port

It requires single cable for data transmission. The 8051 has two signals for serial communication
which are TxD (Transmit Data) and RxD (Receive Data).The TXD line is pin 11 of the
microcontroller (P3.1) while the RXD line is on pin 10 (P3.0).The 8051 includes an on-chip
serial port that can be programmed to operate in one of four different modes and at a range of
frequencies. In serial communication the data is rate is known as the baud rate, which simply
means the number of bits transmitted per second.The 8051 serial port is full duplex. In other
words, it can transmit and receive data at the same time.

The different types of Serial ports are

 Synchronous Serial Input


 Synchronous Serial Output
 Asynchronous Serial UART input
 Asynchronous Serial UART output

6.3 Parallel Port

It requires multiple wires through which the data bits are transmitted in parallel. The
parallel port was designed to be used with the printers. In the parallel I/O mode, devices can be
interfaced using two techniques: peripheral mapped I/O and memory-mapped I/O. In peripheral-

`
mapped I/O, a device is identified with an 8-bit address and enabled by I/O-related control
signals. In memory-mapped I/O, a device is identified with a 16-bit address and enabled by
memory-related control signals.

The various types of parallel ports are

 Parallel Port one bit Input


 Parallel Port one bit Output
 Parallel Port multi-bit Input
 Parallel Port multi-bit Output

6.4 DAC IC0808 Interfacing with IC8051

The Digital to Analog Converter (DAC) is used to interface the IC8051 with the external
devices to get the output in analog form. The output of DAC is analog signal which is used to
control the process.

6.4.1 Features of DAC IC0808

 8-bit DAC
 Fast settling time: 150 ns
 TTL and CMOS compatible
 Power Supply: 4.5 to 18 V (Positive or Negative)
 Low Power Consumption: 33 mW
 Accuracy: 0.19 (Positive or Negative)

6.4.2 Interfacing Diagram

Port 1 of IC8051 is connected to the data lines D7-D0 of Digital to Analog Converter (DAC)
IC0808. The output of DAC is connected to the inverting terminal of the operational amplifier
IC741. The analog output is generated from the 8-bit digital input.

`
Fig. 1 Interfacing DAC with IC8051 microcontroller

6.5Interfacing Analog I/O with IC8051

Analog signals have infinite number of data like a sine wave. ADC converts analog data into
particular states, which can be measured in numbers as a physical quantity. It converts data in
periodical manner, which is known a sampling rate. The benefit of converting analog to digital is
that the noise can be eliminated from the original signal and digital signal can be represented
more accurately.

6.5.1 ADC IC0808

It is an 8-bit ADC. It has 8-channels IN0-IN7. It has three address lines which are represented by
A, B and C. These address lines are used to select the analog channels.

A B C Channel

0 0 0 IN0
0 0 1 IN1

0 1 0 IN2

`
0 1 1 IN3
1 0 0 IN4

1 0 1 IN5
1 1 0 IN6

1 1 1 IN7

The ADC IC0808 has three control signals which are

 SOC (Start of Conversion) – When this signal goes from High to Low state, ADC
initiates conversion of analog to digital.
 EOC (End of Conversion) – ADC sends this High EOC signal to Microcontroller to
indicate conversion is completed.
 OE (Output Enable) – When it is High, the output latch of ADC get enables and the
converted data is then available to microcontroller.

The reference voltage determines the range of analog input voltage.

6.5.2 Features of ADC 0808

 8-analog channels with multiplexer


 Zero or full scale adjustment is not required
 0 to 5V input voltage range with a single polarity 5V supply
 TTL compatible output
 High speed
 Low conversion time (100 micro-second)
 High accuracy
 8-bit resolution
 Low power consumption (less than 15mW)
 Easy to interface with all microprocessor
 Minimum temperature dependence

`
6.5.3 Interfacing Diagram

The analog input signal from sensors is read through one of eight input channels by using
three selection lines A, B and C. Port 2 in IC8051 is used to select the channel, initiates start of
conversion and to receive the end of conversion signal. Once the end of conversion signal is
enabled, then the IC8051 reads 8-bit data using Port 1 through data bus.

Fig. 2 Interfacing Analog I/O with IC8051 Microcontroller

6.6Display

6.6.1 Interfacing Seven-Segment Display with IC8051

A seven-segment display device is an electronic device used to display digital data and it is
made up of seven LED(Light Emitting Diode) segments. The seven segments are represented as
A, B, C, D, E, F and G. The common signal is grounded. DP denotes decimal point.

LED is made up of PN junction in which the current conduction takes place only in forward
bias. The current doesn’t flow in reverse bias. Each LED has two pins which are anode and
cathode. Anode is a positive terminal and the cathode is the negative terminal. Seven segment

`
displays is used to display numbers 0 to 9. The seven LEDs are used to form the seven segments
and a dot point. It is used in variety of devices include clocks, weight lift, home appliances,
traffic light control etc.

Fig. 3 Seven Segment Display

The seven segment displays are connected either in common cathode or common anode.
Depending upon the decimal digit to be displayed, the particular set of LEDs is forward biased.
For instance, to display the numerical digit 0, we will need to light up six of the LED segments
corresponding to A, B, C, D, E and F.

6.6.1.1 Common Anode

In this type, all the anode terminals are made to common and tied to Vcc (5v). The segments A
to G require a logic LOW signal (GND) in order to glow.

Fig. 4 Common Anode Connection

6.6.1.2 Common Cathode

In this type, all the cathode terminals are made common and tied to GND. The
segments A to G require a logic High signal (5v) in order to glow.

`
Fig. 5 Common Cathode Connection

Fig. shows the interfacing seven segment display with IC8051. Port 1 of IC8051 is connected
to the seven segment and a decimal point.

Fig. 6 Interfacing Seven Segment display with IC8051 Microcontroller

`
Chapter 7
Programmable Logic Controller

7.1 Introduction to PLC (Programmable Logic Controller)


Programmable Logic Controllers were discovered by the automotive industry to substitute the
re-wiring of the machine’s control panel. Before the invention of PLC, automobiles were
manufactured using plenty of relays, cam timers, and closed loop controllers. The electricians
had to re-wire every part of the machine daily which was time consuming and highly expensive
on the financial front.
In the year 1968, a request for an electronic device for the hard-wired relay systems was made
by GM hydramatic. Bedford Associates won the proposal and started a new company to develop,
fabricate, sell, and service this new launched product. The first PLC launched was designated
084 as it was the eighty fourth projects of Bedford Associates. Dick Morley worked on this
project and is being considered as the Father of PLC. In the year 1977, the brand invented by
Modicon was sold to Gould Electronics. The Gould Electronics later sold it to German Company
AEG which was later taken over by French Schneider Electric. The first 084 model of PLC was
revealed in North Andover, Massachusetts at the Modicon headquarters.

PLC stands for Programmable Logic Controller. It is introduced in the late 1960’s. It is a
specialized computer used to control the industrial processes. It is developed to replace hard
wired logic relays at a large scale. It performs many functions, providing an interface between
analog and digital input and output.

A PLC interfaces numerous types of external electrical and electronic signals. These
signals can be AC or DC currents or voltages. Typically, they range from 4 to 20 milli-amperes
(mA) or 0 to 120VAC, and 0 to 48VDC. These signals are referred to as I/O (input/output)
points.

7.2 Hard Wired Control

The variety of control tasks were performed by contactors, relays and other
electromechanical devices prior to PLCs. This is referred to as hard-wired control.

`
7.3 Basic Operation of PLC

The functions of a PLC input circuit is to convert the input signals provided by sensors and
switches into logic signals that can be used by the CPU. The program instructions are written
onto the programming device through mnemonics and stored in the user memory. The CPU
fetches these instructions from the memory and executes the input signals by manipulating,
computing, processing them to control the output.

7.4 Block Diagram of PLC

The block diagram of PLC includes

 Central Processing Unit (CPU)


 Programming device
 Input and Output module

7.4.1 Central Processing Unit (CPU)

It is the heart of the PLC system. It reads input data from various sensing devices, executes the
user program from the memory and sends appropriate output commands to control devices. A
DC power source is required to produce the low-level voltage used by the processor and I/O
modules.

Fig. 1 Block Diagram of PLC

`
7.4.2 Programming Device

The control logic or the program is written using the programming device. The data is entered
into the PLC processor through the keyboard. The methods of programming in PLC are Ladder
diagram, Instruction list and block diagram.

7.4.3 Input and Output Module

It is used to interface the input devices with the processor and to interface the processor with
the output devices. The I/O module provides the isolation between processor and I/O devices.

Input module
The input module has two functions: reception of an external signal and status display of that
input point. In other words, it receives the peripheral sensing unit's signal and provides signal
conditioning, termination, isolation and/or indication for that signal's state.
The input to an input module is in either a discrete or analog form. If the input is an ON-OFF
type, such as with a push button or limit switch, the signal is considered to be of a discrete
nature. If, on the other hand, the input varies, such as with temperature, pressure, or level, the
signal is analog in nature.
Peripheral devices sending signals to input modules that describe external conditions can be
switches (limit, proximity, pressure, or temperature), push buttons, or logic, binary coded
decimal (BCD) or analog-to-digital (A/D) circuits. These input signal points are scanned, and
their status is communicated through the interface module or circuitry within each individual
PLC and I/O base.
The various input modules of PLC are:
 DC voltage (110, 220, 14, 24, 48, 15-30V) or current (4-20 mA).
 AC voltage (110, 240, 24, 48V) or current (4-20 mA).
 TTL (transistor transistor logic) input (3-15VDC).
 Analog input (12-bit).
 Word input (16-bit/parallel).
 Thermocouple input.
 Resistance temperature detector.
 High current relay.
 Low current relay.

`
 Latching input (24VDC/110VAC).
 Isolated input (24VDC/85-132VAC).
 Intelligent input (contains a microprocessor).
 Positioning input.
 PID (proportional, integral, differentiation) input.
 High-speed pulse.
Output module
The output module transmits discrete or analog signals to activate various devices such as
hydraulic actuators, solenoids, motor starters, and displays the status (through the use of LEDs)
of the connected output points. Signal conditioning, termination, and isolation are also part of the
output module's functions. The output module is treated in the same manner as the input module
by the processor.
The various output modules of PLC includes:
 DC voltage (24, 48,110V) or current (4-20 mA).
 AC voltage (110, 240v) or current (4-20 mA).
 Isolated (24V DC).
 Analog output (12-bit).
 Word output (16-bit/parallel).
 Intelligent output.
 ASCII output.
 Dual communication port.

7.4.4 Memory

The memory is divided into two types which are data memory and program memory. The
program information or the control logic is stored in the user memory or the program memory
from where the CPU fetches the program instructions.

The memory section stores retrievable digital information in three dedicated locations of the
memory. These memory locations are routinely scanned by the processor. The memory will
receive ("write" mode) digital information or have digital information accessed ("read" mode) by
the processor. This read/write (R/W) capability provides an easy way to make program changes.

`
7.4.5 Power Supply

The Power Supply section gets its input power from an external 120V AC or 240V AC source
line voltage. This line voltage is then stepped-down, rectified, filtered, regulated, voltage- and
current-protected, and status-monitored, with status indication displayed.

7.4.6 System Busses


The internal paths along which the digital signals flow within the PLC are called busses.
The system has four busses:

The CPU uses the data bus for sending data between the different elements
 The address bus to send the addresses of locations for accessing stored data
 The control bus for signals relating to internal control actions
 The system bus is used for communications between the I/O ports and the I/O
unit.

7.4.7 Input Devices

It is the computer hardware equipment used to provide data, and control signals to an
information processing system. The various input devices are

 Switches and Push buttons


 Sensing devices
 Proximity sensors
 Photoelectric sensors
 Temperature switches
 Level switches
 Pressure switches
 Limit switches
 Condition sensors
 Vacuum switches

7.4.8 Output Devices

It is hardware equipment used to communicate the processor output into an understandable


form. The various output devices are

`
 Valves
 Motors
 Relays
 Alarms
 Pumps
 Fans
 Printers

PLC Programming
A CPU of the PLC executes two different programs:
 The Operating System
 The User Program
The Operating System
The operating system organizes all the functions, operations and sequences of the CPU that are
not associated with a control task. The OS tasks include
 Handling a hot restart and warm restart
 Updating and outputting the process image tables of input and outputs
 Executing the user program
 Detecting and calling the interrupts
 Managing the memory areas
 Establishing communication with programmable devices
The User Program
It is a combination of various functions which are required to process an automated task. This
must be created by the users and need to be downloaded to the CPU of the PLC. Some of the
tasks of the user program include:
 Initiating all the conditions for starting the specified task
 Reading and evaluating all binary and analog input signals
 Specifying output signals to all binary and analog output signals
 Executing interrupts and handling errors
In present industrial automation sector, there are several leading PLC manufactures that develop
typical PLC’s ranging from small to high-end PLC’s. Each and every PLC manufacturer has its
own dedicated software to program and configure the PLC hardware. But the PLC programming

`
language is varied depending on the manufacturers. Some manufacturers have common
programming languages and some others have dissimilar. Some of the standard programming
languages of PLC are basically of two types, which are further sub-divided into several types,
which are as follows:
1. Textual language
 Instructions List (IL)
 Structured Text (ST)
2. Graphical language
 Ladder Diagrams (LD)
 Function Block Diagram (FBD)
 Sequential Function Chart (SFC)
Compared with text based languages, graphical languages are preferred by many users to
program a PLC due to their simple and convenient programming features. All the necessary
functions and functional blocks are available in the standard library of each PLC software. These
function blocks include timers, counters, strings, comparators, numeric, arithmetic, bit-shift,
calling functions, and so on.
PLC Programming Devices
Various types of programming devices are used to enter, modify and troubleshoot a PLC
program. These programming terminal devices include handheld and PC based devices. In the
handheld programming device method, a proprietary device is connected to PLC through
a connecting cable. This device consists of a set of keys that allows entering, editing and
dumping the code into the PLC. These handheld devices consist of small display to make the
instruction that has been programmed visible. These are compact and easy to use devices, but
these handheld devices have limited capabilities.
Ladder Logic PLC Programming
Among several programming languages ladder logic diagram is the most basic and simplest form
of programming the PLC. Before going to program the PLC with this language, one should know
some basic information about it. The below figure shows the hardwired-ladder diagram wherein
the same lamp load is controlled by two push button switches, In case if any one of the switches
gets closed, the lamp glows. Here two horizontal lines are called rungs which are connected
between two vertical lines called rails. Each rung establishes the electrical continuity between
positive (L) and negative rails (N) so that the current flows from the input to output devices.

`
Ladder Logic PLC Programming

PLC selection criteria


The various selection criteria of PLC are:
 System requirements
 Application requirements
 Type of Inputs/Outputs
 Memory size
 CPU speed
 Electrical requirements
 Speed of operation
 Communication requirements
 Software
 Operator interface
 Physical environments
PLC Installation & Commissioning
Typical installation
 Typical installation (enclosure, disconnect device, fused isolation transformer, master
control relay, terminal blocks and wiring ducts, suppression devices).
 Spacing controllers – follow the recommended minimum spacing to allow the convection
cooling.
 Preventing excessive heat (0–60?) C

`
 Grounding guidelines.
 Power considerations.
 Safety considerations.
 Preventive maintenance considerations.
Commissioning and testing of a PLC system
 Checking that all cable connections between the PLC and the plant are complete, safe,
and to the required specification and meeting local standards.
 Checking that all the incoming power supply matches the voltage setting for which the
PLC is set.
 Checking that all protective devices are set to their appropriate trip settings.
 Checking that emergency stop button work.
 Checking that all input/output devices are connected to the correct input/output points
and giving the correct signals.
 Loading and testing the software.
Testing inputs and outputs
Input devices can be manipulated to give the open and closed contact conditions and the
corresponding LED on the input module observed. Forcing also can be used to test inputs and
outputs. This involves software, rather than mechanical switching on or off, being used with
instructions to turn off or on inputs/outputs.
Testing Software
Most PLCs contain some software checking program. This checks through the installed program
and provides a list on a screen or as printout with any errors detected.

7.5 Advantages of PLC

 Rugged and designed to withstand vibrations, temperature, noise and humidity


 User friendly and easy to operate
 Faster response
 Easier to troubleshoot
 Need less maintenance
 Better reliability
 Flexibility
 Handles complicated systems

`
 Less expensive
 Integrated diagnostics and override functions
 Smaller physical size than hard-wire solutions
 Remote control and Communication capability
 Interface for Input and Output readily available

7.6 Disadvantages of PLC

 Requires skilled engineers to detect the errors


 Designed by semi-conductors, which are depends on thermal characteristics

`
Chapter 8
PID Controller

8.1 Introduction

PID stands for Proportional Integral Derivative Controller. It is a feedback control mechanism
used in control system. PID controller maintains the output such that there is zero error between
process variable and set point by closed loop operations.

8.2 Block Diagram of Open Loop Control System

An open-loop control system takes input under consideration and doesn’t react on the
feedback to obtain the output. An open loop control system works on fixed operation conditions
and there are no disturbances. The structure of open loop control system is easy to construct and
implement.

8.3 Block Diagram of Closed Loop Control System

Fig.1 shows the block diagram of closed loop control system. The output is given feedback to
the input for correction. The closed loop control systems are complex in design and very
expensive. It produces accurate output.

`
Fig. 1 Block Diagram of Closed Loop Control System
The tuning of PID controller is based on the error signal which is the difference between the
setpoint and process variable. The output of PID controller is given to the process in order to
maintain the steady state. The process output is measured by suitable sensor which is feedback to
the input to generate the error signal. The disturbance enters the process which is to be measured
and eliminated.

The error signal is fed to the controller and the controller provides output u(t). Since the
capacity of the controller to deliver output power is limited, an actuator is needed in between the
controller and the process, which will actuate the control signal. It may be a valve positioner to
open or close a valve; or a damper positioner to control the airflow through a damper.

Basis For Comparison Open Loop System Closed Loop System

Definition The system whose control In closed loop, the output


action is free from the output depends on the control action
is known as the open loop of the system.
control system.

Other Name Non-feedback System Feedback System

Components Controller and Controlled Amplifier, Controller,


Process. Controlled Process, Feedback.

Construction Simple Complex

Reliability Non-reliable Reliable

Accuracy Depends on calibration Accurate because of feedback.

Stability Stable Less Stable

Optimization Not-Possible Possible

Response Fast Slow

Calibration Difficult Easy

`
8.4 Proportional Controller
The output of the proportional controller is the product of gain and measured error.It is the most
common of all industrial process control action. It calculates the difference between the process
variable signal and the set point signal, which is called as an error.It provides an immediate
reaction to a change in the process variable. The higher gain value of proportional control causes
repeatedly overshoot the setpoint, leading to oscillation.
If the error is greater, the greater will be the controller output and as long as the error remains,
it continues to generate corrective effort. As the error is zero, it produces zero output. In
proportional control the correction factor is determined by the size of the difference between set
point and the measured value. It provides stable operation but always maintains the steady state
error. When the proportional constant increases, the speed of response is increased. It can be
used to obtain fast response systems with a large transmission coefficient. A high proportional
gain results in a large change in the output for a given change in the error. A small gain results in
a small output response to a large input error, and a less responsive or less sensitive controller.
Proportional band is the percentage change in the process variable needed to cause a 100 percent
change in controller output.

The output of the proportional controller is given by

Where Kc – Proportional gain, E – Error

Bias is the 50% of the controller output.

8.4.1 Advantages of Proportional Controller

 It reduces rise time


 It reduces peak error

8.4.2 Disadvantages of Proportional Controller

 It produces steady state error


 It increases the maximum overshoot of the system

8.5 Integral Controller

`
It overcomes the drawback of proportional controller. It is the process of accumulating the
process variable value as the time progress. Integral action decides how fast to move the output.It
eliminates the steady state error by the process of integration. It integrates the error over a period
of time until error value reaches to zero. When the negative error occurs, the output of the
integral control will decrease. It limits the speed of response and affects stability of the system.
By reducing the integral gain, the speed of the response can be increased. The controller output
depends on the integral of error signal over time. It doesn’t be used alone, but mostly it is used
along with proportional control. If there is any deviation between set point and process variable,
an addition corrective signal is supplied by the integral control mode function till steady state
error becomes zero.

The output of the integral controller is given by

where TI– Integral time

8.5.1 Advantages of Integral Controller

 It eliminates offset
 It reduces integrated error

8.5.2 Disadvantages of Integral Controller

 It produces overshoot
 It has integral wind-up problem

8.6 Derivative Controller

Integral controller does not have the capability to predict the future behavior of error. Derivative
controller overcomes this problem be anticipating future behavior of the error. It provides an
output which is proportional to the rate of change of the error with respect to time. It is used to
prevent overshoot and undershoot of the setpoint and to restore the process value rapidly to the
setpoint.

`
It is also called as anticipatory controller because it moves the control valve in such a direction
as to counteract the rapid change of process variable. The output of derivative action is the
product of derivative constant and the rate of change of error with respect to time.It must not be
used alone because of rapid start of control output that can result extremely large rate of change
of output, even for a small error change. It is used along with proportional plus integral control
or with only proportional control.

8.6.1 Advantages

 It improves the transient response of the system


 It makes the loop more stable
 It reduces rise time
 It reduces peak error
 It is used to make the control action faster
 Output is proportional to rate of change of deviation

8.6.2 Disadvantages

 It amplifies the noise

8.7 Proportional Integral Controller

It eliminates the offset and produces quick response. It is widely used in process industries for
controlling parameters like pressure, level, flow etc. The drawback of PI controller is it produces
slow response to disturbance.

The PI controller output is given by

8.8 Proportional Derivative Controller

It is a combination of proportional and a derivative controller. The output is equals to the


summation of proportional and derivative of the error signal. It is effective for systems having
large number of time constants. The output of the PD controller is

`
Where Kd– Derivative gain

8.9 Proportional Integral Derivative Controller

A PID controller removes steady-state error and decreases system settling times while
maintaining a reasonable transient response. PID control is combined with logic, sequential
functions, selectors, and simple function blocks to build the complicated automation systems
used for energy production, transportation, and manufacturing applications.

The output of the PID controller output is given by

Where u – Controller output


Kp – Proportional gain
Ki – Integral gain
Kd – Derivative gain
e – Error signal

8.10 PID Tuning Method


The determination of corresponding PID parameter values for getting the optimum
performance from the process is called tuning. This is obviously a crucial part in case of all
closed loop control systems. There are number of tuning methods have been introduced to obtain
fast and acceptable performance.
The steps involved in these methods include experimental determination of the dynamic
characteristics of the control loop and estimating the controller tuning parameters that produce a
desired performance for the dynamic characteristics determined. The various tuning methods are
discussed below.

`
Trial and Error Method
This is the simple method of tuning a PID controller. Once we get the clear understanding of
PID parameters, the trial and error method become relatively easy.
 Set integral and derivative terms to zero first and then increase the proportional gain until
the output of the control loop oscillates at a constant rate. This increase of proportional
gain should be in such that response the system becomes faster provided it should not
make system unstable.
 Once the P-response is fast enough, set the integral term, so that the oscillations will be
gradually reduced. Change this I-value until the steady state error is reduced, but it may
increase overshoot.
 Once P and I parameters have been set to a desired values with minimal steady state error,
increase the derivative gain until the system reacts quickly to its set point. Increasing
derivative term decreases the overshoot of the controller response.
8.10.1 Zeigler-Nichols Method
It is another popular method for tuning PID controllers. Ziegler and Nichols presented two
classical methods for determining values of proportional gain, integral time and derivative time
based on transient response characteristics of a given plant or system.
First Method
 Obtain a unit step response of the plant experimentally and it may look‘s’ shaped curve as
shown in figure below. This method applies, if obtained response exhibit s-shaped curve
for unit step input otherwise it cannot be applied.
 Obtain two constants, delay time L and time constant T by drawing a tangent line at the
inflection point of the s-shaped curve.
 Set the parameters of Kp, Ti, and Td values from the table given below for three types of
controllers.

`
Second Method
 It is very similar to the trial and error method where integral and derivative terms are set to
the zero, i.e., making Ti infinity and Td zero.
 Increase the proportional gain such that the output exhibits sustained oscillations. If the
system does not produce sustained oscillations then this method cannot be applied. The
gain at which sustained oscillations produced is called as critical gain.

 Once the sustain oscillations are produced, set the values of Ti and Td as per the given
table for P, PI and PID controllers based on critical gain and critical period.

`
8.10.2 Internal Model Control (IMC)

• A more comprehensive model-based design method, Internal Model Control (IMC), was
developed by Morari and coworkers (Garcia and Morari, 1982; Rivera et al., 1986).

• The IMC method, like the DS method, is based on an assumed process model and leads
to analytical expressions for the controller settings.

• These two design methods are closely related and produce identical controllers if the
design parameters are specified in a consistent manner.

`
• The model response is subtracted from the actual response Y, and the difference, is used
as the input signal to the IMC controller.
• In general, due to modeling errors and unknown disturbances that is not accounted for in
the model.
• The IMC method can be used to derive PID controller settings for a variety of transfer
function models.
8.10.3 Tuning Relations Based on Integral Error Criteria

• Controller tuning relations have been developed that optimize the closed-loop response
for a simple process model and a specified disturbance or set-point change.

• The optimum settings minimize an integral error criterion.

The three popular integral error criteria are:

 Integral of the absolute value of the error (IAE)


 Integral of the squared error (ISE)
 Integral of the time-weighted absolute error (ITAE)

`
Integral of the Absolute value of the Error (IAE)


IAE   e(t ) dt
0
where the error signal e(t) is the difference between the set point and the measurement.

Integral of Square Error (ISE)



ISE   e(t ) dt
2

Integral of the time weighted absolute error (ITAE)


ITAE   t e(t ) dt
0

NPTEL Notes Link

http://nptel.ac.in/courses/117104072/

http://nptel.ac.in/courses/Webcourse-contents/IIT
KANPUR/microcontrollers/micro/ui/Course_home1_1.htm

You might also like