Professional Documents
Culture Documents
Introduction to Microcontrollers
1.1 Introduction
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.
`
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.
`
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.
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.
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.
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.
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
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.
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.
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.
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).
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.
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)
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.
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
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.
`
Timer Counter
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.
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.
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.
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.
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
`
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.
`
Chapter 3
IC8051 Microcontrollers
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.
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
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.
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).
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.
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 external interrupt flags are cleared when the processor branches to the interrupt service
routine, provides the interrupt is a negative edge triggered.
`
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.
The IC8051 microcontroller consists of 256 bytes of RAM memory which is divided into
two parts.
`
3.4.2 Accumulator (A)
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.
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
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.
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.
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.
`
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.
These two bits RS1 and RSO in PSW register are used to select various memory locations
(Bank0 to Bank3) in the RAM memory location.
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.
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
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.
`
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.
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.
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.
P3.4 T0 Timer 0
P3.5 T1 Timer 1
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.
`
This pin is grounded.
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).
This is PSEN pin which stands for Program Store Enable. It is used to read a signal from the
external program memory.
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.
This is EA pin which stands for External Access input. It is used to enable or disable external
memory.
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.
This Vcc pin is used for power supply which is +5V DC.
`
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
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.
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
`
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.
`
Moves the immediate data to the indirect
MOV @Ri,#data 2 3
RAM
Arithmetic instructions
Arithmetic instructions perform arithmetic operations such as addition, subtraction,
multiplication and division.
`
Mnemonic Description Byte Cycle
`
DEC A Decrements the accumulator by 1 1 1
DIV AB Divides A by B 1 5
Logic instructions perform logic operations such as AND, OR, X-OR, Complement and
rotate bits of two registers.
`
ORL A, Rn OR register to accumulator 1 1
`
Rotates bits in the accumulator left through
RLC A 1 1
carry
`
Branch Instructions
These instructions can change the sequence of program execution. There are two types of
branch instructions.
`
Compares immediate data to the accumulator and
CJNE A,#data,rel 3 4
jumps if not equal. Short jump.
NOP No operation 1 1
`
Chapter 6
IC8051 Interfacing
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.
Serial Port
Parallel 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.
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 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.
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)
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
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.
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
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.
`
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.
6.6Display
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.
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.
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.
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.
`
Chapter 7
Programmable Logic Controller
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.
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.
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.
`
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.
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.
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.
It is the computer hardware equipment used to provide data, and control signals to an
information processing system. The various input 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
`
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.
`
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
`
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.
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.
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.
`
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.
`
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.
It eliminates offset
It reduces integrated error
It produces overshoot
It has integral wind-up problem
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
8.6.2 Disadvantages
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.
`
Where Kd– Derivative gain
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.
`
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.
`
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.
ITAE t e(t ) dt
0
http://nptel.ac.in/courses/117104072/
http://nptel.ac.in/courses/Webcourse-contents/IIT
KANPUR/microcontrollers/micro/ui/Course_home1_1.htm