Embedded Systems

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 136

Embedded System

CPEEL1
What is an Embedded System?
• It has hardware.
• It has application software.
• It has Real Time Operating system (RTOS)
Characteristics of an Embedded System
• Single-functioned
• Tightly Constrained
• Reactive and Real time
• Microprocessor/Microcontroller based
• Memory
• Connected Peripherals
• HW-SW system
Advantages
• Easily Customizable
• Low power consumption
• Low cost
• Enhanced performance
Disadvantages
• High development effort
• Larger time to market
Basic Structure of an Embedded System
Difference between Microprocessor
and Microcontroller
• What is Microcontroller?
• A microcontroller is a chip optimized to control
electronic devices. It is stored in a single integrated
circuit which is dedicated to performing a particular
task and execute one specific application.
• It is specially designed circuits for embedded
applications and is widely used in automatically
controlled electronic devices. It contains memory,
processor, and programmable I/O.
Difference between Microprocessor
and Microcontroller
• What is a Microprocessor?
• A microprocessor is a controlling unit of a micro-
computer wrapped inside a small chip. It performs
Arithmetic Logical Unit (ALU) operations and
communicates with the other devices connected with
it. It is a single Integrated Circuit in which several
functions are combined.
Difference between Microprocessor
and Microcontroller
• KEY DIFFERENCES
• A microprocessor is a controlling unit of a micro-
computer wrapped inside a small chip. It performs
Arithmetic Logical Unit (ALU) operations and
communicates with the other devices connected with
it. It is a single Integrated Circuit in which several
functions are combined. KEY DIFFERENCES
• Microprocessor consists of only a Central Processing
Unit, whereas Micro Controller contains a CPU,
Memory, I/O all integrated into one chip.
• Microprocessor is used in Personal Computers whereas
Micro Controller is used in an embedded system.
Difference between Microprocessor
and Microcontroller
• KEY DIFFERENCES
• Microprocessor uses an external bus to interface to
RAM, ROM, and other peripherals, on the other hand,
Microcontroller uses an internal controlling bus.
• Microprocessors are based on Von Neumann model
Micro controllers are based on Harvard architecture
• Microprocessor is complicated and expensive, with a
large number of instructions to process but
Microcontroller is inexpensive and straightforward with
fewer instructions to process.
Architecture Types
• Von Neumann Architecture
Architecture Types
• Harvard Architecture
Von-Neumann Architecture vs
Harvard Architecture
Custom Single-purpose Processors
• A single-purpose processor is a digital system
intended to solve a specific computation task.
• A custom single purpose processor to execute a
specific task within the ES
• An embedded system designer choosing to use a
custom single-purpose, rather than a general
purpose processor to implement part of a
system’s functionality may achieve several
benefits.
Combinational logic design
• A combinational circuit is a digital circuit whose output
is purely a function of its current inputs; such a circuit
has no memory of past inputs.
• A transistor is the basic electrical component of digital
systems. Combinations of transistors form components
called logic gates.
• The basic principle of a NPN transistor to act as a switch
is, a high voltage (typically +5 Volts as logic 1) is applied
to the gate, the transistor conducts, so current flows.
When low voltage (refer to as logic 0, typically ground,)
is applied to the gate, the transistor does not conduct.
Creation of Gates using transistors
Basic logic gates
Basic logic gates
Combinational circuit design
• Q: y is 1 if a is equal to 1, or b and c is equal to 1. z
is 1 if a is equal to 1 and b is equal to 1 or if b or c
is equal to 1, but not both.
Combinational circuit design
Combinational circuit design
RT –level combinational components
• RT level uses combination components that are
more power full than gates.
• Such Components are
• Multiplexer
• Decoder
• Adder
• Comparator
• ALU
Multiplexer
• A multiplexer, sometimes called a selector, allows
only one of its data inputs to pass through to the
output according to the selection pins inputs.
• If there are m data inputs, then there are log2(m)
select lines.
Multiplexer
Decoder
• A decoder converts its binary input I into a one-
hot output O. "One-hot“ means that exactly one
of the output lines can be 1 at a given time.
• Thus, if there are n outputs, then there must be
log2(n) inputs.
Decoder
Adder
• An adder adds two n-bit binary inputs A and B,
generating an n-bit output sum along with an
output carry.
Adder
Comparator
• A comparator compares two n-bit binary inputs A
and B, generating outputs that indicate whether A
is less than, equal to, or greater than B.
Comparator
Arithmetic Logic Unit (ALU)
• An ALU (arithmetic-logic unit) can perform a
variety of arithmetic and logic functions on its n-
bit inputs A and B.
• The select lines S choose the current function; if
there are m possible functions, then there must
be at least log2(m) select lines.
Arithmetic Logic Unit (ALU)
Sequential logic design
• A sequential circuit is a digital circuit whose
outputs are a function of the current as well as
previous input values.
• In other words, sequential logic possesses
memory.
Flip-flops
Flip-flops
Registers
• A register stores n bits from its n-bit data input I,
with those stored bits appearing at its output O.
• A register usually has at least two control inputs,
clock and load. For a rising-edge-triggered
register, the inputs I are only stored when load is
1 and clock is rising from 0 to 1.
Registers
Shift Register
• A shift register has a one-bit data input I, and at
least two control inputs clock and shift.
• When clock is rising and shift is 1, the value of I is
stored in the (n)’th bit, while the (n)’th bit is
stored in the (n-1)’th bit, and likewise, until the
second bit is stored in the first bit.
• The first bit is typically shifted out, meaning it
appears over an output Q.
Shift Register
Types of SR’s
PISO SR
Counters
• A counter is a register that can also increment
(add binary 1) to its stored binary value.
• A counter has a clear input, which resets all
stored bits to 0, and a count input, which enables
incrementing on the clock edge.
4 bit Asynchronous Counter
4 bit Synchronous Counter
Sequential logic design eg:
• Q: You want to construct a clock divider to slow
down your pre-existing clock so that you output a
1 for every four clock cycles.
Sequential logic design eg:
Sequential logic design eg:
Sequential logic design eg:
General-purpose
processors
General-purpose processors
• A general-purpose processor is a programmable
digital system intended to solve computation
tasks in a large variety of applications.
• Copies of the same processor may solve
computation problems in applications as diverse
as communication, automotive, and industrial
embedded systems.
Basic architecture
• A general-purpose processor, sometimes called a
CPU (Central Processing Unit) or a
microprocessor, consists of a datapath and a
controller, tightly linked with a memory.
Datapath
• The datapath consists of the circuitry for
transforming data and for storing temporary data.
• The datapath contains an arithmetic-logic unit
(ALU) capable of transforming data through
operations such as addition, subtraction, logical
AND, logical OR, inverting, and shifting.
• The datapath also contains registers capable of
storing temporary data.
Controller
• The controller consists of circuitry for retrieving
program instructions, and for moving data to,
from, and through the datapath according to
those instructions.
• The controller contains a program counter (PC)
that holds the address in memory of the next
program instruction to fetch.
• The controller also contains an instruction register
(IR) to hold the fetched instruction.
Memory
• While registers serve a processor’s short term
storage requirements, memory serves the
processor’s medium and long-term information-
storage requirements.
• We can classify stored information as either
program or data.
• Program information consists of the sequence of
instructions that cause the processor to carry out the
desired system functionality.
• Data information represents the values being input,
output and transformed by the program.
Memory
• We can store program and data together or
separately.
• In a Princeton architecture, data and program words
share the same memory space.
• In a Harvard architecture, the program memory space is
distinct from the data memory space.
Cache memory
• To reduce the time needed to access (read or
write) memory, a local copy of a portion of
memory may be kept in a small but especially fast
memory called cache.
Operation
• We can think of a microprocessor’s execution of
instructions as consisting of several basic stages:
• Fetch instruction: the task of reading the next instruction from
memory into the instruction register.
• Decode instruction: the task of determining what operation
the instruction in the instruction register represents (e.g., add,
move, etc.).
• Fetch operands: the task of moving the instruction’s operand
data into appropriate registers.
• Execute operation: the task of feeding the appropriate registers
through the ALU and back into an appropriate register.
• Store results: the task of writing a register into memory.
Pipelining
• Pipelining is a common way to increase the
instruction throughput of a microprocessor.
• Note that for pipelining to work well, instruction
execution must be decomposable into roughly
equal length stages, and instructions should each
require the same number of cycles.
Programmer’s view
• A programmer writes the program instructions
that carry out the desired functionality on the
general-purpose processor.
• The programmer may not actually need to know
detailed information about the processor’s
architecture or operation, but instead may deal
with an architectural abstraction, which hides
much of that detail.
Programmer’s view
• The first is assembly-language programming, in which one
programs in a language representing processor-specific
instructions as mnemonics.
• The second is structured-language programming, in which
one programs in a language using processor independent
instructions.
• A compiler automatically translates those instructions to
processor-specific instructions.
• Ideally, the structured-language programmer would need no
information about the processor architecture, but in
embedded systems, the programmer must usually have at
least some awareness,
Program and data memory space
• The embedded systems programmer must be
aware of the size of the available memory for
program and for data.
• For example, a particular processor may have a
64K program space, and a 64K data space.
• The programmer must not exceed these limits.
Registers
• The assembly-language programmer must know
how many registers are available for general-
purpose data storage.
• He/she must also be familiar with other registers
that have special functions.
• For example, a base register may exist, which
permits the programmer to use a data-transfer
instruction where the processor adds an operand
field to the base register to obtain an actual
memory address.
I/O
• The programmer should be aware of the
processor’s input and output (I/O) facilities, with
which the processor communicates with other
devices.
• One common I/O facility is parallel I/O, in which
the programmer can read or write a port (a
collection of external pins) by reading or writing a
special-function register.
Interrupts
• An interrupt causes the processor to suspend
execution of the main program, and instead jump
to an Interrupt Service Routine (ISR) that fulfills a
special, short-term processing need.
• In particular, the processor stores the current PC,
and sets it to the address of the ISR.
• After the ISR completes, the processor resumes
execution of the main program by restoring the
PC.
Operating system
• An operating system is a layer of software that provides
low-level services to the application layer, a set of one or
more programs executing on the CPU consuming and
producing input and output data.
• The task of managing the application layer involves the
loading and executing of programs, sharing and allocating
system resources to these programs, and protecting these
allocated resources from corruption by non-owner
programs.
• One of the most important resource of a system is the
central processing unit (CPU), which is typically shared
among a number of executing programs.
Development environment
• Several software and hardware tools commonly
support the programming of general-purpose
processors.
• First, we must distinguish between two processors
we deal with when developing an embedded system.
• One processor is the development processor, on which we
write and debug our program. This processor is part of our
desktop computer.
• The other processor is the target processor, to which we
will send our program and which will form part of our
embedded system’s implementation.
Development environment
• Assemblers translate assembly instructions to
binary machine instructions. In addition to just
replacing opcode and operand mnemonics by
binary equivalents, an assembler may also
translate symbolic labels into actual addresses.
• Compilers translate structured programs into
machine (or assembly) programs.
• Structured programming languages possess high-level
constructs that greatly simplify programming, such as
loop constructs, so each high-level construct may
translate to several or tens of machine instructions.
Development environment
• Debuggers help programmers evaluate and
correct their programs.
• Device programmers download a binary machine
program from the development processor’s
memory into the target processor’s memory.
• Emulators support debugging of the program
while it executes on the target processor. An
emulator typically consists of a debugger coupled
with a board connected to the desktop processor
via a cable.
Microcontrollers
• Numerous processor IC manufacturers market devices
specifically for the embedded systems domain.
• These devices may include several features.
• First, they may include several peripheral devices
• Second, they may include some program and data memory on
the same IC.
• Third, they may provide the programmer with direct access to a
number of pins of the IC.
• Fourth, they may provide specialized instructions for common
embedded system operations, such as bit manipulation
operations.
• A microcontroller is a device possessing some or all of
these features.
Communication Protocols in Embedded
Systems
• Communication Protocols are a set of rules that
allow two or more communication systems to
communicate data via any physical medium.
• The rules, regulations, synchronization between
communication systems, syntax to be followed
and semantics are all defined by the term
protocol.
• Protocols can be implemented by both hardware
and software or combination of both.
Communication Protocols in Embedded
Systems
• Embedded System is an electronic system or device
which employs both hardware and software.
• A processor or controller takes input from the
physical world peripherals like sensors, actuators
etc., processes the same through appropriate
software and provides the desired output.
• In this case, the components have to communicate
with each other to provide the anticipated output.
• Each communicating entity should agree to some
protocol to exchange information.
Types of Communication Protocols in
Embedded Systems
• Communication protocols are broadly classified
into two types:
• Inter System Protocol
• Intra System Protocol
Inter System Communication Protocols
• Inter system protocols establish communication
between two communicating devices i.e.
between PC and microprocessor kit,
developmental boards, etc. In this case, the
communication is achieved through inter bus
system.
Types of Inter System Communication
Protocols
• Inter system protocol can be categorized into:
• USB Communication protocols
• UART Communication protocols
• USART Communication protocols
USB Communication Protocols
• Universal Serial Bus (USB) is a two-wired serial
communication protocol.
• It allows 127 devices to be connected at any given
time. USB supports plug & play functionality.
• USB protocol sends and receives the data serially
between host and external peripheral devices
through data signal lines D+ and D-.
• Apart from two data lines, USB has VCC and
Ground signals to power up the device.
USB Communication Protocols
USB Communication Protocols
• Data is transmitted in the form of packets where
two devices communicate each other.
• Data packets compose of 8 bits (byte) with LSB
(Least Significant Bit) transmitted first.
• In USB, data is transferred in three different
speeds such as:
Advantages and Disadvantages of USB
Communication Protocol
• The advantages of USB Communication Protocol
are as follows:
• Fast and simple.
• It is of low cost.
• Plug and Play hardware.
• The disadvantages of USB Communication
Protocol are as follows:
• Needs powerful master device.
• Specific drivers are required.
UART Communication Protocols
• Universal Asynchronous Receiver/Transmitter
(UART) is not a communication protocol but just a
physical piece of hardware which converts parallel
data into serial data. Its main purpose is to
transmit and receive data serially.
• UART is also two-wired i.e., the serial data is
handled by Tx (Transmitter) and Rx (Receiver)
pins.
UART Communication Protocols
• UART transmits data asynchronously, which induces
that no clock signal is associated in transmitting and
receiving data. Instead of clock signal, UART embed
start and stop bits with actual data bits, which
defines the start and end of data packet.
• When receiver end detects the start bit, it starts to
read the data bits at specific baud rate meaning both
transmitting and receiving peripherals should work
under same baud rate.
• UART works under half duplex communication mode
meaning it either transmits or receives at a time.
UART Communication Protocols
• UART Frame
USART Communication Protocol
• Universal Synchronous Asynchronous
Receiver/Transmitter (USART) is identical to that of
UART with only added functionality synchronous.
• That is, the transmitter will generate a clock signal
which will be recovered at the receiver end from the
data stream transmitted without knowing baud rate
ahead.
• USART works under full duplex communication
mode meaning it can transmit and receive data at
same time.
USART Communication Protocol
• USART Frame
Advantages and Disadvantages of UART/
USART Communication Protocol
• The advantages of UART/ USART Communication
Protocol are as follows:
• Clock signal is not required
• Cost effective
• Uses parity bit for error detection
• Requires only 2 wires for data communication
• The disadvantages of UART/ USART Communication
Protocol are as follows:
• Doesn’t support multiple master slave functionality
• Baud rate of communicating UART should be within 10
percent of each other
Intra System Communication Protocols
• The Intra system protocol establishes
communication between components within the
circuit board.
• In embedded systems, intra system protocol
increases the number of components connected
to the controller.
• Increase in components lead to circuit complexity
and increase in power consumption.
• Intra system protocol promises secure access of
data from the peripherals.
Types of Intra System Communication
Protocols
• Intra system protocol can be categorized into:
• I2C Protocol
• SPI Protocol
• CAN Protocol
I2C Communication Protocols
• Inter Integrated Circuit (I2C) is a serial
communication protocol developed by Philips
Semiconductors.
• The main purpose of this protocol is to provide
easiness to connect peripheral chips with
microcontroller.
• In embedded systems, all peripheral devices are
connected as memory mapped devices to the
microcontroller.
I2C Communication Protocols
• I2C necessitates two wires SDA (Serial Data Line) and SCL
(Serial Clock Line) to carry information between devices.
• These two active wires are said to be bidirectional.
• I2C protocol is a master to slave communication protocol.
• Each slave is been provided with unique address. In order
to establish communication, master device initially sends
the target slave address along with R/W (Read/Write) flag.
• The corresponding slave device will move into active mode
leaving other devices in off state.
I2C Communication Protocols
• Once the slave device is ready, communication
starts between master and slave devices. One bit
acknowledgment is replied by the receiver if
transmitter transmits 1 byte (8 bits) of data. A
stop condition is issued at the end of
communication between devices.
Advantages and Disadvantages of I2C
Communication Protocols
• The advantages of I2C Communication Protocols
are as follows:
• Provides good communication between onboard
devices which are accessed infrequently
• Addressing mechanism eases master slave
communication
• Cost and circuit complexity does not end up on number
of devices
• Disadvantages of I2C Communication Protocols
• The biggest disadvantage of I2C Communication
Protocols is its limited speed.
Serial Peripheral Interface (SPI)
Communication Protocols
• SPI (Serial Peripheral Interface) is one of the serial
communication protocol developed by Motorola.
It is a 4-wire protocol namely MOSI (Master Out
Slave In), MISO (Master In Slave Out, SS (Slave
Select), and SCLK (Serial Clock).
• As I2C protocol, SPI is also a master to slave
communication protocol. In SPI, the master device
first configures the clock at a particular frequency.
• Furthermore the SS line is used to select the
appropriate slave by pulling the SS line low where
it is normally held high.
Serial Peripheral Interface (SPI)
Communication Protocols
• The communication is established between the
selected slave and the master device as soon as
appropriate slave device is selected.
• SPI is a full duplex communication protocol. SPI
doesn’t limit data transfer to 8 bit words.
Advantages and Disadvantages of SPI
Communication Protocols
• The advantages of SPI Communication Protocol are as
follows:
• Faster than asynchronous serial communication protocol.
• Support multiple slaves connectivity.
• Universally accepted protocol and low cost.
• The disadvantages of SPI Communication Protocol are
as follows:
• Requires more wires than other communication protocols.
• Master device should control all slave communications
(slave-slave communication is impossible).
• Numerous slave devices leads to circuit complexity.
Controller Area Network (CAN)
Communication Protocol
• CAN (Controller Area Network) is a serial
communication protocol developed by the Robert
Bosch for intra vehicular communication. It
requires two wires CAN High (H+) and CAN low
(H-) for data transmission.
Advantages and Disadvantages of CAN
Communication Protocols
• The advantages of CAN Communication Protocols
are as follows:
• Low cost and reliable
• Shows robust performance
• Secured and fast protocol
• The disadvantages of CAN Communication
Protocol are as follows:
• Automotive oriented
• Bit complex protocol
Integrated circuit (IC) technology
• The manner in which a digital (gate-level)
implementation is mapped onto an IC
• IC: Integrated circuit, or “chip”
• IC technologies differ in their customization to a design
• IC’s consist of numerous layers (perhaps 10 or more)
• IC technologies differ with respect to who builds each layer and
when.
Integrated circuit (IC) technology
• Three types of IC technologies
• Full-custom/VLSI
• Semi-custom ASIC (gate array and standard cell)
• PLD (Programmable Logic Device)
Full-custom (VLSI)
• Very Large Scale Integration (VLSI)
• All layers are optimized for an embedded system’s particular digital
implementation
• Placement
• Place and orient transistors
• Routing
• Connect transistors
• Sizing
• Make fat, fast wires or thin, slow wires
• May also need to size buffer
• Benefits
• Excellent performance, small size, low power
Full-custom (VLSI)
• Hand design
• Horrible time-to-market/flexibility/NRE cost…
• Reserve for the most important units in a processor
• ALU, Instruction fetch…

• Physical design tools


• Less optimal, but faster…
• Drawbacks
• High NRE cost (e.g., $300k), long time-to-market
Semi-custom
• Lower layers are fully or partially built
• Designers are left with routing of wires and maybe
placing some blocks
• Benefits
• Good performance, good size, less NRE cost than a full-
custom implementation (perhaps $10k to $100k)
• Drawbacks
• Still require weeks to months to develop
Semi-custom
• Gate Array
• Array of prefabricated gates
• “place” and route
• Higher density, faster time-to-market
• Does not integrate as well with full-custom
• Standard Cell
• A library of pre-designed cell
• Place and route
• Lower density, higher complexity
• Integrate great with full-custom
PLD (Programmable Logic Device)
• Programmable Logic Device
• Programmable Logic Array, Programmable Array Logic, Field Programmable
Gate Array
• All layers already exist
• Designers can purchase an IC
• To implement desired functionality
• Connections on the IC are either created or destroyed to implement

• Benefits
• Very low NRE costs
• Great time to market
• Drawback
• High unit cost, bad for large volume
• Power
• Except special PLA
• slower
Independence of processor and IC
technologies
PID Control Basics
PID meaning
• A proportional–integral–derivative controller (PID
controller or three-term controller) is a control
loop mechanism employing feedback that is
widely used in industrial control systems and a
variety of other applications requiring
continuously modulated control. A PID controller
continuously calculates an error value.
PID meaning
• Closed loop control system is an essential topic for
embedded systems, bringing together actuators and
sensors with the control algorithm in software. For
example, motor speed can be controlled by varying the
PWM duty cycle used to drive the motor. This is the open-
loop control. However, due to the lack of feedback, the
actual motor speed could not be verified. This is important
because driving the motor with the same PWM duty cycle
does not guarantee the motor to run at the same speed
under all circumstances. A motor will run faster in load
free condition than under load with the same PWM signal.
In order to control the motor speed, we need to close the
loop by adding feedback of the actual motor speed to the
controller.
The Problem – DC Motor Position
Control.
• Before we begin to design a PID controller, we
need to understand the problem. In this example,
we want to move the shaft of the motor from its
current position to the target position.
The Problem – DC Motor Position
Control.
• There are a few terms commonly used to describe the
PID control loops, such as:
• Control Variable (CV) – This is the output of the control loop. In
this case, the CV is the duty cycle of the PWM signal that drives
the motor.
• Process Variable (PV) – This is the feedback value returned by
the system to the controller. In this example, the PV is the
current angle of the motor shaft.
• Set Point (SP) – Set point is the value that we desire for the
system. In our case, the SP is the target position of the motor
shaft in angle.
• Error (E) – Error refers to the difference between the set point
and the process variable. In another words, it means how far
the current position of the motor shaft from the target position.
The Hardware – PR24
• The Cytron’s DIY Project Set PR24 (PID Motor
Controller) is the best platform for beginner to
learn the PID algorithm. It has the following
features:
• PIC16F876A as the main controller.
• Geared DC motor as the output.
• Multi-turn variable resistor connected to the motor
shaft for position feedback.
• 2×16 Character LCD for tuning and troubleshooting.
• Presets for PID tuning.
The Hardware – PR24
The Implementation of PID Controller
• The PID controller, just like its name, comprises a
proportional (P), an integral (I) and a derivative
(D) part. The controller parts are introduced in
the following sections individually and in
combined operation.
Proportional Controller
• When the current position of the motor shaft is still far away
from the target position, we want to apply more power to
drive the motor towards the target position so that we can
reach there faster. When the shaft is getting nearer to the
target position, we will reduce the power to slow it down. At
the time the shaft reaches the target position, the motor
needs to be stopped. If the shaft position has overshot, we
need to apply negative power to the motor (reverse the
motor) to bring it back to the target position.
• In short, this is called proportional controller because the
power we apply to the motor is proportional to the error of
the system.
Proportional Controller
• From the block diagram of proportional
controller, we can see that the PWM duty cycle
(output) is the result of multiplying the error with
a constant, Kp.
• Error = Set Point – Process Variable
• Control Variable = Kp * Error
Proportional Controller
• Figure below shows the example of proportional
loop implemented in C language.
Proportional Controller
• The value of Kp needs to be chosen carefully in
order to get the optimum system response. Lower
values for Kp will tend to give smoother but
slower responses.
Proportional Controller
• Higher values of Kp will yield much quicker
response but may cause overshoot, where the
output oscillates before settling.
Proportional Controller
• Excessively high values of Kp may even throw the
loop into an unstable state where the output
oscillates without ever settling at the set point.
Integral Controller
• As can be seen from the graph of P controller, the
actual position of the motor shaft, when settles
down will not reach the target position. This is
because when the current position is near to the
target position, the error becomes very small and
the computed PWM duty cycle is too small for the
motor to overcome the friction and gravity. The
small error that exists when the system has
settled down is called the steady state error.
Integral Controller
• To overcome the problem of steady state error for
the P controller, I controller is being introduced.
As its name suggests, the integral is merely an
accumulated error signals encountered since
startup.
• Integral = ∑(Error)
Integral Controller
• This total is multiplied by a constant, Ki, and is
added into the loop output. Unlike the P
controller, the I controller is rarely used alone, but
mostly in combination with the P or PD controller.
Integral Controller
• When the system has already settled down with a
small steady state error, the integral still
continues to accumulate until the CV is large
enough to bring the PV inline with SP. The
equations for PI controller are as follow:
• Error = Set Point – Process Variable
• Integral = Integral + Error
• Control Variable = (Kp * Error) + (Ki * Integral)
Integral Controller
• Figure below shows the example of PI controller
implemented in C language.
Integral Controller
• Just like the P controller, the value of Ki needs to
be chosen carefully. Too low the value, the steady
state error is corrected very slowly; too high the
value, the system becomes unstable and
oscillates.
Derivative Controller
• Let’s say you are driving a car, and you need to
stop your car exactly 100m from your current
position as soon as possible. If you are travelling
at 10km/h, you would want to accelerate your car
so that you can reach the target sooner. In
contrast, if you are cruising at 100km/h, you need
to start braking so that you can stop at 100m and
will not overshoot. This is where the derivative
controller comes into play.
Derivative Controller
• The derivative of any variable describes how that
variable changes over time. In a PID controller,
the derivative is the rate of change of the error. In
digital form, it can be described as:
• Derivative = Error – Last Error
• where Error is the current error value and Last
Error is the error value for the previous iteration.
Derivative Controller
• Negative values of derivative indicate an
improvement (reduction) in the error signal. For
example, if the last error was 20 and the current
error is 10, the derivative will be -10. When these
negative values are multiplied with a constant, Kd,
and are added to the output of the loop, it can
slow down the system when approaching the
target.
Derivative Controller
• Just like the I controller, the D controller is rarely
used alone, but mostly in combination with the P
or PI controller. The equations for the PD
controller are as follow:
• Last Error = Error
• Error = Set Point – Process Variable
• Derivative = Error – Last Error
• Control Variable = (Kp * Error) + (Kd * Derivative)
Derivative Controller
• Figure below shows the example of PD controller
implemented in C language.
Derivative Controller
• The damping effect of the D controller allows the system to
have a higher value of Kp and/or Ki without overshooting. In
consequent, this will give the system a better response time
to set point changes. However, too high the value of Kd will
also have negative effect. The D controller tense to amplify
the noise exists in the feedback loop. If the Kd is too high,
the system will become jerky if the feedback loop is noisy.
Joining Them Together – PID Controller
• By joining the P, I and D controller, we can take
the advantages of the combined benefits from
each controller. We have the P controller for fast
system response, I controller to correct the steady
state error and D controller to dampen the system
and reduce overshoot.
Joining Them Together – PID Controller
• From the block diagram of PID controller, we can see that the
output of the loop is merely the sum of output from P, I and D
controller. The equations for the PID loop are illustrated below:
• Last Error = Error
• Error = Set Point – Process Variable
• Integral = Integral + Error
• Derivative = Error – Last Error
• Control Variable = (Kp * Error) + (Ki * Integral) + (Kd * Derivative)
Joining Them Together – PID Controller
• Figure below shows the example of PID controller
implemented in C language.
Joining Them Together – PID Controller
• System response for the correctly tuned PID
controller:
Summary
• PID controller is a simple yet effective control
system widely used in industrial. However, to
implement the PID controller is simple, but not
the tuning. The process of tuning the PID
parameters (Kp, Ki and Kd) is a continuous trial
and error process. There is no exact way to
calculate the value for the parameters unless the
whole system is mathematically modeled and
simulated.

You might also like