Microcontroller Technology
Microcontroller Technology
INTRODUCTION TO MICROCONTROLLERS
Microcontrollers
A microcontroller (μC or uC) is a solitary chip microcomputer fabricated from VLSI fabrication.
The microcontroller IC contains the CPU, Memory (Program Memory and Data Memory), I/O
Ports (Input / Output Ports) and few other components integrated on a single chip.
The microcontroller technology enables the integration of a number of useful functions into a
single IC package. These functions are:
The ability to execute a stored set of instructions to carry out user defined tasks.
The ability to access external memory chips to both read and write data from and to the
memory.
Microcontrollers are designed to perform the specific tasks of embedded systems, in applications
that need a degree of control to be applied by the user of the system
If a device or an application involves measuring, storing, calculating, controlling or displaying
information, then device contains a Microcontroller in it.
Some of the areas where microcontrollers are used include:
Home appliances eg Microwave Ovens, home theatre equipment,
Office machines eg Photocopiers, printers,
Industry in Industrial Automation, safety systems, robots
On roads and Cars, Traffic Signals, Vehicle AC systems, Automatic braking systems etc.
Buildings e.g elevators, security doors, etc
1
4. Microprocessor Systems can become bulky and expensive, while Microcontrollers Make
the system simple, economic and compact.
5. Microprocessor designing and hardware cost is high, while microcontroller designing nad
hardware cost is low.
Advantages of Microcontrollers
Integration of all the essential components reduces the cost, design time, and area of the
product (or application).
Usage of microcontroller is simple and easy for troubleshooting and system maintaining.
Most of the pins are programmable by the user for performing different functions.
Easily interface additional RAM, ROM, I/O ports.
Low time required for performing operations.
Disadvantages of Microcontrollers
Microcontrollers have got more complex architecture than that of microprocessors.
Only perform limited number of executions simultaneously.
Mostly used in micro-equipment.
Cannot interface high power devices directly
Classification of Microcontrollers
Microcontrollers can be classified on the basis of internal bus width, architecture, memory, and
instruction set.
For example, 8051 having Program & Data Memory, I/O Ports, Serial
Communication, Counters and Timers and Interrupt Control logic on the
chip is an embedded microcontroller.
For example, 8031 which has no program memory on the chip is an external
memory microcontroller
3
3. Classification Based on Memory Architecture
(a) Von-Neumann/ Princeton Architecture
Microcontrollers based on the Von-Neumann architecture have a common
memory address for the program memory and data memory, and a single
bus that is used to fetch both instructions and data.
4
4. Classification Based on Instruction set Architecture
(a) Complex Instruction Set Computer (CISC) Microcontrollers
A CISC is a computer where single instructions can perform numerous low-
level operations like all evaluating, loading, and storing operations,
CISC allows the programmer to use one instruction in place of many
simpler instructions. Thus, it is associated with such microcontroller
hardware that can deal with the execution of various serially linked
operations using a specific instruction.
It puts the whole emphasis on the way to lessen the total instructions per
program. The main idea is that a single instruction will do all loading,
evaluating, and storing operations just like a multiplication command will
do loading data, evaluating, and storing it, hence it’s complex.
The advantages of the CISC architecture are that many of the instructions
are macro-like, allowing the programmer to use one instruction in place of
many simpler instructions.
An example of CISC architecture microcontroller is Intel 8096 family.
(b) Reduced Instruction Set Computer (RISC) Microcontrollers
RISC offers the execution of computing tasks with multiple simple
instructions. The main idea behind RISC is to make hardware simpler by
using an instruction set composed of a few basic steps for loading,
evaluating, and storing operations, just like a load command will load data,
a store command will store the data.
Both approaches try to increase the CPU performance
RISC: Reduce the cycles per instruction at the cost of the number of
instructions per program.
CISC: The CISC approach attempts to minimize the number of
instructions per program but at the cost of an increase in the number of
cycles per instruction.
5
The microcontroller chip typically includes:
1. CPU (Central Processing Unit)
The CPU is the brain of a microcontroller and it administers all the activities of the system,
connecting every part of a microcontroller into a single system.
The CPU is responsible for fetching instructions, decoding, and executing them.
(a) Registers are a little like internal memory storage areas. These are useful for storing
interim calculation results as this reduces the number of reads/writes to external
memory which is usually slower. Some registers have special functions such
keeping track of where the next instruction is supposed to come from in memory.
(b) The Arithmetic Logic Unit is responsible for carrying out calculations. In some
CPU's this can be quite simple; perhaps only supporting add, subtract and basic
logical operations.
(c) Control Unit coordinates and times the CPU’s functions, and it uses the program
counter to locate and retrieve the next instruction from memory. Another purpose
of control unit is, controlling the data flow between the CPU and peripheral
devices/peripheral chips.
6
2. Memory
The function of memory in a microcontroller is to store data and program. A
microcontroller usually has a certain amount of RAM and ROM (EEPROM, EPROM, etc)
or flash memories for storing program source codes.
In general, there are two types of memory:
(a) Program memory: is used to hold the application program. In most microcomputer
applications the program memory is a Read Only Memory (ROM).
(b) Data memory is used for the dynamic data which is generated by the application
program and for the stack. The stack is a portion of memory where the CPU saves
its own internal register data for calling a subroutine. Stack is a part of RAM used
for storing the current state of the program counter (address) when an interrupt
occurs
4. Timers/counters
A microcontroller may have more than one timer and counter. The timers and counters
provide all timing and counting functions inside the microcontroller.
The major operations of this section are to perform clock functions, modulations, pulse
generations, frequency measuring, making oscillations, counting external pulses, trigger
interrupts after a certain number of clock cycles, etc.
7. Interrupt control
The interrupt control used for providing interrupt (delay) for a working program. interrupts
are signals that cause the CPU to suspend its current activity and perform some other task.
7
The interrupt may be external, activated by using interrupt pin, or internal, by using
interrupt instruction during programming.
The main difference between internal and external interrupts is that the internal interrupt is
synchronous, initiated by some exceptional condition caused by the program itself rather
than by an external event, while external interrupts are asynchronous, coming from input-
output devices through the interrupt pins, depending on external conditions that are
independent of the program being executed at the time.
The 8048 series has a modified Harvard architecture, with internal or external
program ROM and 64–256 bytes of internal (on-chip) RAM. The I/O is mapped into its
own address space, separate from programs and data.
Though the 8048 series was eventually replaced by the very successful 8051 series, it
remained quite popular even by the year 2000 due to its low cost, wide availability,
memory-efficient one-byte instruction set, and mature development tools. Because of this,
it is used in high-volume, cost-sensitive consumer electronics devices such as TV remotes,
computer keyboards, and toys.
It is built with 40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of
RAM storage, 2 16-bit timers. It consists of are four parallel 8-bit ports, which are
programmable as well as addressable as per the requirement. An on-chip crystal oscillator
8
is integrated in the microcontroller having crystal frequency of 12 MHz. It is possible to
add two external memory chips with capacity of 64Kb each
The 8051 became widely popular after intel allowed other manufacturers to make and
market any variants of the 8051 they please, with the condition that they remain code
compatible with the 8051. This has led to many versions of the 8051 with different speeds
and amounts of on-chip ROM marketed by more than half a dozen manufacturers.
Though there are different versions of the 8051 in terms of speed and amount of on-chip
ROM, they are all compatible with the original 8051 as far as the instructions are
concerned. This means that a program written for one, will run on any of them regardless
of the manufacturer.
Intel no longer manufactures the 8051 microcontroller family however, variants of the 8051
from numerous manufacturers remain popular today eg, the Atmel Corp. has a wide
selection of 8051 chips such as the AT89C51, the AT89C52, and the AT89LV2 among
others.
8051 Microcontroller Family Members
There are two other members of the 8051 family of microcontrollers by Intel. They are the
8052 and the 8031.
(a) The 8052 Microcontroller
The 8052 has all the standard features of the 8051 as well as an extra 128 bytes of
RAM and an extra timer. It also has 8k bytes of on-chip program ROM instead of
4k bytes.
(b) The 8031 Microcontroller
This chip is often referred to as a ROM-less 8051 since it has 0 k bytes of on-chip
ROM. To use this chip, you must add an external ROM to it, which must contain
the program that the 8031 will fetch and execute.
Comparison of 8051 family members
9
Feature 8051 8052 8031
ROM (on-chip program space in bytes) 4 K 8K 0
RAM (in bytes) 128 256 128
Timers 2 3 2
I/O ports 32 32 32
Serial ports 1 1 1
Interrupt sources 6 8 6
10
This is often referred to as a power-on reset. Activating a power-on reset will cause all
values in the registers to be lost. It will set program counter to all 0s.
Pins 18 & 19 (XTAL2 & XTAL1) − These pins are used for interfacing an external crystal
to get the system clock.
The 8051 has an on-chip oscillator but requires an external clock to run it. Most often a
quartz crystal oscillator is connected to inputs XTALI (pin 19) and XTAL2 (pin 18)
Pin 20 (GND) − This is the ground terminal.
Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a
signal from the external program memory.
Pin 30 − This is ALE pin which stands for Address Latch Enable. It is used to demultiplex
the address-data signal of port.
Pin 31 − This is EA pin which stands for External Access input. It is used to enable/disable
the external memory interfacing.
Pin 40 − This pin is used to provide power supply to the circuit.
Intel 8051 Input/ Output Ports (I/O Ports)
Intel 8051 microcontrollers have 4 I/O ports each using 8 pins, making them 8-bit ports, which can
be configured as inputs or outputs. In total of 32 input/output pins enabling the microcontroller to
be connected to peripheral devices are available for use.
The following is a summary of features of PO - P3.
Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port.
In 8051-based systems with external memory connections, Port 0 also serves the additional
function of multiplexing both address and data signals.
P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data
output (Data Bus) when the ALE pin is driven low (0).
Pins 1 to 8 − These pins are known as Port 1. Each of these pins can be configured as an
input or an output, so that Port 1 functions as an 8-bit input/output port.
P1 is a true I/O port, because it doesn't have any alternative functions as is the case with
P0, but can be configured as general I/O only.
Pins 21 to 28 − These pins are known as Port 2. It serves as an I/O port.
In 8051-based systems with external memory connections Port 2 also serves the additional
function of being used along with P0, to provide the l6-bit address for the external memory.
Since an 8051 is capable of accessing 64K bytes of external memory, it needs a path for
the 16 bits of the address. While P0 provides the lower 8 bits via A0 - A7, it is the job of
11
P2 to provide bits A8 - A I6 of the address. In other words, when the 8051 is connected to
external memory, P2 is used for the upper 8 bits of the 16-bit address, and it cannot be used
for 1/O.
As shown in Figure (b), port 2 is also designated as A8 - A 15, indicating its dual function.
Pins 10 to 17 − These pins are known as Port 3. Similar to port 1, it can be used as input
or output.
Port 3 also has some additional functions of providing important signals such as interrupts,
timer input, control signals, serial communication signals etc.
The additional functions of Port 3 are carried out by pins 10 to 17 as outlined below:
o Pin 10 (RXD): Serial asynchronous communication input or Serial synchronous
communication output.
o Pin 11 (TXD): Serial asynchronous communication output or Serial synchronous
communication clock output.
o Pin 12 (INT0): Interrupt 0 input
o Pin 13 (INT1): Interrupt 1 input
o Pin 14 (T0): Counter 0 clock input
o Pin 15 (T1): Counter 1 clock input
o Pin 16 (WR): Signal for writing to external (additional) RAM
o Pin 17 (RD): Signal for reading from external RAM
12
The main difference between internal and external interrupts is that the internal interrupt is
synchronous, initiated by some exceptional condition caused by the program itself rather than by
an external event, while external interrupts are asynchronous, coming from input-output devices
through the interrupt pins, depending on external conditions that are independent of the program
being executed at the time.
13
Intel 8051 Register Banks
A total of 32 bytes of RAM are set aside for the register banks and the stack. These 32 bytes are
divided into four register banks in which each bank has 8 registers, R0–R7. RAM locations from
0 to 7 are set aside for bank 0 of R0–R7 where R0 is RAM location 0, R1 is RAM location 1, R2
is location 2, and so on, until the memory location 7, which belongs to R7 of bank 0.
The second bank of registers R0–R7 starts at RAM location 08 and goes to locations OFH. The
third bank of R0–R7 starts at memory location 10H and goes to location to 17H. Finally, RAM
locations 18H to 1FH are set aside for the fourth bank of R0–R7.
Functions:
Used to hold the results of all arithmetic and logic operations
The accumulator is also used in data moving, as data to be moved from one register
to another must go through the accumulator.
The 8051 micro controller has a single instruction for multiplication (MUL) and
division (DIV). To quickly and easily multiply or divide “A” by another number, you
may store the other number in "B" and make use of these two instructions (MUL and
15
DIV). Multiplication and division can be performed only upon numbers stored in A and
B registers.
Function:
These registers function as auxiliary or temporary storage registers in many
operations.
Consider an example of the sum of 10 and 20. Store a variable 10 in an accumulator and
another variable 20 in, say, register R4. To process the addition operation, execute the
following command:
ADD A, R4
After executing this instruction, the accumulator will contain the value 30. Thus "R"
registers are very important auxiliary or helper registers. The Accumulator alone would
not be very useful if it were not for these "R" registers. The "R" registers are meant for
temporarily storage of values.
Let us take another example. We will add the values in R1 and R2 together and then
subtract the values of R3 and R4 from the result.
As you can see, we used R5 to temporarily hold the sum of R3 and R4. Of course, this is
not the most efficient way to calculate (R1 + R2) – (R3 + R4), but it does illustrate the use
of the "R" registers as a way to store values temporarily.
Functions:
16
DPTR is meant for pointing to data. It is used by the 8051 to access external
memory using the address indicated by DPTR.
It is also used for storing data and intermediate results.
17
Intel 8051 Instruction Set
MOV Instruction
Simply stated, the MOV instruction copies data from one location to another, It has the following
format:
MOV destination, source ; copy source to dest.
This instruction tells the CPU to move (in reality, copy) the source operand to the destination
operand.
For example, the instruction "MOV A, R0" copies the contents of register R0 to register A.
After this instruction is executed, register A will have the same value as register R0. The MOV
instruction does not affect the source operand. The following program first loads register A with
value 55H (that is 55 in hex), then moves this value around to various registers inside the CPU,
Notice the "#" in the instruction, this signifies that it is a value. The importance of this will be
discussed later, when talking about the 8051 address modes.
MOV A, #55H ; load value 55H into reg. A
MOV R0, A ; copy contents of A into R0
; (now A = R0 = 55H)
MOV Rl, A ; copy contents of A into Rl
; (now A = R0 = Rl = 55H)
MOV R2, A ; copy contents of A into R2
; (now A = R0 = Rl = R2 = 5SH)
MOV R3, #95H ; load value 95H into R3
; (now R3 = 95H)
MOV A, R3 ; copy contents of R3 into A
; (now A = R3 = 95H)
Trace table
A R0 R1 R2 R3
MOV A, # 55H 55H - - - -
MOV R0, A 55H 55H - - -
MOV R1, A 55H 55H 55H - -
18
MOV R2, A 55H 55H 55H 55H -
MOV R3, # 95 H 55H 55H 55H 55H 95H
MOV A, R3 95H 55H 55H 55H 95H
ADD Instruction
The ADD instruction has the following format:
ADD A, source ; ADD the Source operand; to the accumulator
The ADD instruction tells the CPU to add the Source byte to register A and put the result in register
A. To add two numbers such as 25H and 34H, each can be moved to a register and then added
together:
MOV A, #25H ; load 25H into A
MOV R2, #34H ; load 34H into R2
ADD A, R2 ; add R2 to accumulator
; (A = A + R2)
Trace table
A R2
MOV A, # 25 25H -
MOV R2, #34H 25H 34H
ADD A, R2 59H 34H
Executing the program above results in A = 59H (25H + 34H = 59H) and R2 = 34H. Notice that
the Content of R2 does not change. The program above can be written in many ways depending
on the registers used. Another way might be:
MOV R5, #25H ; load 25H into R5 (R5 = 25H)
MOV R7, #34H ; load 34H into R7 (R7 = 34H)
MOV A, #0 ; load 0 into A (A = 0, clear A)
ADD A, R5 ; add to A content of R5
; where A = A + R5
ADD A, R7 ; add to A content of R7
; where A = A + R7
19
Trace table
R5 R7 A
MOV R5, #25H 25H - -
MOV R7, #34H 25H 34H -
MOV A, #0 25H 34H 0
ADD A, R5 25H 34H 25H
ADD A, R7 25H 34H 59H
The program above results in A = 59H. There are always many ways to write the same program
One question that might come into mind, after looking at the above program, is whether it is
necessary to move both data items into registers before adding them together. The answer is no; it
is not necessary. Look at the following variation of the same program:
MOV A, #25H ; load one operand into A (A = 25H)
ADD A, #34H ; add the second operand 34H to A
In the above case, while one register contained one value, the second value followed the instruction
as an operand. This is called an immediate operand.
The examples shown so far for the ADD instruction indicate that the source operand can be either
a register or immediate data, but the destination must always be register A, the accumulator.
In other words, an instruction such as "ADD R2, #12H" is invalid since register A (accumulator)
must be involved in any arithmetic operation.
Notice that "ADD R4, A" is also invalid for the reason that A must be the destination of any
arithmetic operation. To put it simply: In the 8051, register A must be involved and be the
destination for all arithmetic operations. The foregoing discussion explains why register A is
referred to as the accumulator.
20
The various addressing modes of a microcontroller are determined when it is designed, and
therefore cannot be changed by the programmer. Intel 8051 provides a total of five distinct
addressing modes:
Immediate Addressing Mode
In this addressing mode, the source operand is a constant. In immediate addressing mode,
as the name implies, when the instruction is assembled, the operand comes Immediately
after the opcode. Notice that the immediate data must be preceded by the sign "#". This
addressing mode can be used to load information into any of the registers, including the
DPTR register.
Examples:
MOV A, #25H ; load 25H into A
MOV R4, #62 ; load the decimal value 62 into R4
MOV B, #40H ; load 40H into B
MOV DPTR, #4521H ; DPTR = 4512H
21
See the examples below, and note the absence of "#" sign
MOV R0, 40H ; save content of RAM location 40H in R0
MOV 56H, A ; save content of A in RAM location 56H
MOV R4, 7FH ; move contents of RAM location 7FH to R4
As discussed earlier, RAM locations 0 to 7 are allocated to bank 0 registers R0 - R7. These
registers can be accessed in two ways, as shown below:
MOV A, 4 ; is same as
MOV A, R4 ; which means copy R4 into A
MOV A, 7 ; is same as
MOV A, R7 ; which means copy R7 into A
22
In the register indirect addressing mode, a register is used as a pointer to the data. If the
data is inside the CPU, only registers R0 and R1 are used for this purpose. In other words,
R2 - R7 cannot be used to hold the address of an operand located in RAM when using this
addressing mode. When R0 and R1 are used as pointers, that is, when they hold the
addresses of RAM locations, they must be preceded by the "@" sign, as shown below:
MOV A, @R0 ; move contents of RAM location whose
; address is held by R0 into A
MOV @R1, B ; move contents of B into RAM location
; whose address is held by R1
Notice that R0 (as well as R1) is preceded by the "@" sign. In the absence of the "@" sign,
MOV will be interpreted as an instruction moving the contents of register R0 to A, instead
of the contents of the memory location pointed to by RO.
Indexed Addressing Mode
Indexed addressing mode is widely used in accessing data elements of look-up table entries
located in the program ROM space of the 8051. The instruction used for this purpose is
"MOVC A, @A+DPTR". The 16-bit register DPTR and register A are used to form the
address of the data clement stored in on-chip ROM. Because the data Elements are stored
in the program (code) space ROM of the 8051, the instruction MOVC is used instead of
MOV. The "C" means code. In this instruction the contents of A are added to the 16-bit
register DPTR to form the 16- bit address of the needed data.
Examples:
MOVC A, @A+DPTR
The source operand is @A+DPTR and we know we will get the source data (to
transfer) from this location. It is nothing but adding contents of DPTR with present
content of accumulator. This addition will result a new data which is taken as the
address of source data (to transfer). The data at this address is then transferred to
accumulator.
MOVC A, @A+PC
This example works the same way as the first example. The only difference is,
instead of adding DPTR with accumulator, here data inside program counter (PC)
is added with accumulator to obtain the target address.
23
PROCESS CONTROL SYSTEMS
Introduction
Process control systems, sometimes called industrial control systems, are systems of equipment
along the production line during manufacturing, that test the process in a variety of ways, and
return data for monitoring and troubleshooting.
Process Control Systems in industrial/ manufacturing/ production processes involve the regulation
of all aspects of the process, such as precise control of level of temperature, pressure, and flow.
They consist of monitoring the state of a critical parameter, detecting when it varies from desired
state, and taking action to restore it. Process control systems involve the process variable, set points
and manipulated variable.
(ii) Quality
Process control systems are central to maintaining product quality, such as in
maintaining the proper ratio of ingredients to deliver a consistent product, or tightly
regulating the temperatures, to ensure the required quality standard of a product is
achieved and maintained. Without this type of control, products would vary, and
undermine quality.
(iii) Environment
Process control systems helps to reduce environmental hazards as a result of industrial
processes, by ensuring that the industrial wastes are treated properly, before being
released to the environment, or recycled for other use.
(iv) Economics
Process control systems helps to minimize production costs while producing products
that meet certain specifications.
Better process automation and control allows processes to operate closer to “optimum”
conditions, minimize wastage, and produce products that meet the quality
specifications, helping manufacturers to save money by minimizing the resources
required to produce the end product.
24
Process control terms
(i) Lag time
This is the amount of time after the dead time that the process variable takes to move
63.3% of its final value after a step change in valve position.
It is the delay time it takes the controlled variable to respond to a change in the
controller output signal.
In such a case, the error signal persists for some time before the process can return to
the set point
Dead time is often the result of transportation delays, between the actuators and the
sensors, although sensors and final control elements may add to process dead time.
An example is, if you were taking a shower, the dead time is the amount of time it
would take for you (the controller) to feel the first discernible change in temperature
after you have adjusted the hot or cold water.
For example, if a process temperature needs to kept within 5 °C of 100 °C, then the set
point is 100 °C. A temperature sensor can be used to help maintain the temperature at
set point. The sensor is inserted into the process, and a controller compares the
temperature reading from the sensor to the set point.
In the temperature control loop example, the error is the difference between the 110°C
measured variable and the 100 °C set point—that is, the error is +10°C. The objective
of any control scheme is to minimize or eliminate error
25
(vi) Transient
A short-lived oscillation or signal in a system caused by a sudden change of voltage or
current or load.
In the temperature control loop example, the measured variable is temperature, which
must be held close to 100 °C.
(xi) Offset
This is a sustained deviation of the process variable from the set point.
In the temperature control example, if the control system held the process fluid at 100.5
°C consistently, even though the set point is 100 °C, then an offset of 0.5 °C exists.
26
Process
This refers to some manufacturing sequence, and is an important element of the process control
system, in which the variable of the process is to be controlled. It has one variable or multivariable
output.
Feedback element or Sensor
The feedback element or sensor is the device which converts the output variable into another
suitable variable which can acceptable by error detector.
Error detector
The error detector compares between actual signal and reference input i.e. set point . The error
detector has subtracting/summing points whose output is an error signal to controller for
comparison and for the corrective action.
Automatic controller
The controller detects the actuating error signal, which is usually at a very low power level,
and amplifies it to a sufficiently high level i.e. the automatic controller comprises an error detector
and amplifier.
Actuator or control element
The actuator is a pneumatic or valve, a hydraulic motor or an electric motor, which produces an
input to the plant according to the control signal getting from controller.
Control modes
Control mode refers to the method used by a process control system, to correct an error in a process
variable from the set point.
27
In process control, there are several control modes used to control a parameter such as temperature,
or pressure, and the method of control mode to be used, is selected according to the process, so
that a control strategy is selected that suites the process.
The four most popular control modes are:
(i) On/off
On /off control, also called a two-position control, is whereby the output is either On
or Off, with no middle ground.
This control mode would only switch when the process variable is beyond the set point,
and activates an output until the measured variable reaches the set point.
A common example is the thermostat. No control action takes place until the measured
value deviates from the set point by a minimum amount (dead band). The output then
goes from full off to full on, turning off again when the set point is reached.
Since the temperature crosses the set-point to change the output state, the process
temperature will be cycling continually, going from below set-point to above, and back
below.
While simple and low cost, this mode of control has a tendency to overshoot the desired
value
.
(ii) Proportional (P)
Proportional control is where the controller produces an action that is proportional to
the error. Here the difference between the set point and measured value generates a
continuous, linear control output, and the control sets the system response as a function
of time.
28
In the example of temperature control, a proportional controller decreases the average
power supplied to the heater as the temperature approaches set-point. This has the effect
of slowing down the heater so that it will not overshoot the set-point, but will approach
the set-point and maintain a stable temperature.
This proportioning action can be accomplished by turning the output on and off for
short intervals. This “time proportioning” varies the ratio of “on” time to “off” time to
control the temperature. The proportioning action occurs within a “proportional band”
around the set-point temperature. Proportional Band is another term for controller
sensitivity. Outside this band, the controller functions as an on-off unit, with the output
either fully on (below the band) or fully off (above the band). Within the band, the
output is turned on and off in the ratio of the measurement difference from the set-
point. At the set-point (the midpoint of the proportional band), the output ON: OFF
ratio is 1:1; that is, the on-time and off-time are equal. if the temperature is further from
the set-point, the on- and off-times vary in proportion to the temperature difference.
The integral mode is sometimes used as a single mode of control but is more commonly
used with proportional control.
In case of a sudden and large process load change, the rate control adds a signal to the
control valve, increasing the controller’s output signal in addition to the proportional
29
and integral signals. However, as the rate of change of the measured variable slows
down, the derivative signal reduces, and the valve opening is decreased.
It provides a faster response time than I-only control due to the addition of the
proportional action. PI control stops the system from fluctuating, and it is also able to
return the system to its set point. Although the response time for PI-control is faster
than I-only control, it is still up to 50% slower than P-only control. Therefore, in order
to increase response time, PI control is often combined with D-only control.
On eliminating the proportionality sign, the constant of proportionality gets added with
the error signal as well as the derivative of the error signal. Thus:
30
Where: m(t) = output of the controller
e(t) = the error signal (difference between the desired set point and the actual
process variable)
Kp = the constant of proportionality of error signal/ proportional gain
KD is the constant of proportionality of derivative of the error signal/
derivative gain
In order to have the transfer function of the PD controller, we need to consider the
Laplace transform of the above equation. Therefore,
Further:
We know transfer function is given as output by input and for controllers the input is
error signal and output is controller output.
So, on transposing E(s), we will have
31
(vii) Proportional + Integral + Differential (PID)
PID controllers are the most widely used automatic industrial controllers, that provide
a proportional with integral, and derivative control, that helps the unit to automatically
compensate for changes in the system.
It provides the most accurate and stable control of the three controller types, and
practically, most of modern PID controllers are designed based on microcontroller
technology.
32
To find the values of Kc, Ki, and Kd, and to calculate the tuning constants, the values of Ku, and Tu
are plugged into the Ziegler-Nichols closed loop equations to determine the necessary settings for
the controller.
Closed-Loop Calculations of Kc, Ki, and Kd
N/B: Gain is the parameter that determines how fast the system responds, and adjusting this
tuning parameter higher may cause more sensitive, less stable loops.
Advantages
1. Easy experiment; only need to change the P controller
2. Includes dynamics of whole process, which gives a more accurate picture of how the
system is behaving
Disadvantages
1. Experiment can be time consuming
2. Can venture into unstable regions while testing the P controller, which could cause the
system to become out of control
33
Zeigler-Nichols Closed Loop Method (The Process Reaction Method)
The Ziegler-Nichols open-loop method is also referred to as a process reaction method, because it
tests the open-loop reaction of the process to a change in the control variable output.
This basic test requires that the response of the system be recorded, preferably by a plotter or
computer. Once certain process response values are found, they can be plugged into the Ziegler-
Nichols equation with specific multiplier constants for the gains of a controller with either P, PI,
or PID actions.
The process parameters that may be obtained from this process reaction curve are as follows:
L = Lag time in minutes
T = Time constant estimate in minutes
ΔPV = change in PV in response to step disturbance (% rise)
N = ΔPV/ T = reaction rate in % min-1
The reaction rate and lag time values, are plugged in to the Ziegler-Nichols open-loop tuning
equations for the appropriate controller—P, PI, or PID—to calculate the controller constants. Use
the table below.
Closed-Loop Calculations of Kc, Ki, and Kd
Control Mode Kc Ki Kd
P P/ NL
PI 0.9P/ NL 1/ 1.33L
PID 1.2P/ NL 1/2L 0.5L
Implementation of Controllers
Implementation of the control loops can be achieved using pneumatic devices, analogue
electronics, or digital electronics.
34
The first process controllers were pneumatic. However, these have largely been replaced by
electronic systems, because of improved reliability, less maintenance, easier installation, easier
adjustment, higher accuracy, lower cost, can be used with multiple variables, and have higher
speed operation.
The most popular control implementation devices are:
(i) Pneumatic controllers
A pneumatic controller receives a process variable (PV) signal as a variable air pressure,
compares that signal against a desired set point (SP) value, and then mechanically generates
another air pressure signal as the output, driving a final control element.
The power supply and output of a pneumatic controller is compressed air. The input signal to
the controller is mechanical movement provided by the sensing element that is being used to
sense the process.
Pneumatic controllers are used in automatic control systems for flow rate, pressure,
temperature, level, and other parameters of industrial processes.
The controller mechanically compares the signal against a predetermined set point and
sends a corrective air signal to a pneumatic control valve, which modulates process flow,
thereby returning the application to the desired condition.
35
The action of this particular controller is direct, since an increase in process variable
signal (pressure) results in an increase in output signal (pressure). Increasing process
variable (PV) pressure attempts to push the right-hand end of the beam up, causing the
baffle to approach the nozzle. This blockage of the nozzle causes the nozzle’s pneumatic
backpressure to increase, thus increasing the amount of force applied by the output
feedback bellows on the left-hand end of the beam and returning the flapper (very
nearly) to its original position.
36
1. Pneumatic systems are noisy and there are often leaks in the system.
2. They are always prone to dust and contaminants.
3. Pneumatic systems are suitable only for low-pressure applications.
4. Slow response makes control and speed in pneumatic systems to be more difficult because
of the compressed air, compared to electrical or hydraulic systems.
Electronic PID controllers use operational amplifiers and passive components like resistors
and capacitors, with the gains and control actions of the control system, being decided by the
ratios of various resistors and capacitors, according to the circuit arrangement.
37
Types of Actuators
(i) Solenoid
Solenoids are the most common actuator components. The basic principle of operation is that,
there is a moving ferrous core (a piston) that will move inside wire coil.
Normally the piston is held outside the coil by a spring. When a voltage is applied to the coil
and current flows, the coil builds up a magnetic field that attracts the piston and pulls it into
the center of the coil. The piston can be used to supply a linear force.
Solenoids can be used to electrically open door latches, open or shut valves, move robotic
limbs, and even actuate electric switch mechanisms. However, if a solenoid is used to actuate
a set of switch contacts, then it is termed a relay.
(ii) Stepper motor drives
A stepper motor is a type of electric motor that operates on a pulsed current. The full rotation
of the motor is divided into a number of discrete “Steps” or “Increments”, with the angle of
each rotational movement or step dependent upon the number of stator poles and rotor teeth
the stepper motor has.
Stepper motors are much more precise than standard electric motors as they can be
commanded to turn and stop at any of the steps around its rotation. Because of this, they are
particularly well suited to applications that require accurate positioning and repeatability with
a fast response to starting, stopping, reversing and speed control.
Stepper motors require sufficient and controlled energy for phases in a precise sequence. Due
to this, stepper motors are controlled by a driver consisting of a controller, and the stepper
motor’s connections.
38
All the coils with the same letter are connected together so that energizing, say coils marked
A, will cause the magnetic rotor to align itself with that set of coils.
By applying power to each set of coils in turn, the rotor can be made to rotate or "step" from
one position to the next, by an angle determined by its step angle construction, and by
energizing the coils in sequence, the rotor will produce a rotary motion.
Step Angle
The angle through which the motor shaft rotates for each command pulse is called the step
angle (β). The smaller the step angle, the greater the number of steps per revolution, and higher
the resolution or accuracy of positioning obtained. The step angles can be as small as 0.72º or
as large as 90º. But the most common step sizes are 1.8º, 2.5º, 7.5º and 15º.
The value of step angle can be expressed either in terms of the rotor and stator poles (teeth)
Nr and Ns respectively, or in terms of the number of stator phases (m) and the number of rotor
teeth.
Resolution is given by the number of steps needed to complete one revolution of the rotor
shaft. The higher the resolution, greater the accuracy of positioning of objects by the motor
Resolution = No. of steps / revolution = 360º / β
39
There are three basic types of stepper motors; Variable Reluctance, Permanent Magnet, and
Hybrid (a sort of combination of both).
(iii) Pneumatic
They convert air pressure into mechanical motion. There are two basic types: Linear actuators
(cylinder/piston or diaphragm types) and rotary actuators.
Piston and rotary actuators are functionally similar to their hydraulic counterparts.
The double acting cylinder connects to the valve with two tubes and can be driven in either
direction.
The single acting cylinder can only be driven in one direction with air pressure and is returned
by a spring.
Rotary actuators convert air pressure into rotary mechanical motion. One common design is
the vane motor.
40
The motor consists of a rotor that is offset in housing. Protruding from the rotor are spring-
loaded vanes that seal against the housing and slide in and out of the rotor as it turns.
Motion is achieved because the vanes on the top have more exposed surface area than on the
bottom and hence receive more force, causing the rotor to turn clockwise.
In most cases rotary actuators are not chosen for their efficiencies, but for their power, speed
and torque
(iv) Hydraulic
The most common type of hydraulic actuator is the hydraulic cylinder. A cylinder uses
pressurized fluid to create a linear force/motion.
Single acting cylinders apply force when extending and typically use a spring to retract the
cylinder. Double acting cylinders apply force in both directions.
41
In the figure below, a fluid is pumped into one side of the cylinder under pressure causing that
side of the cylinder to expand, and advancing the piston.
The fluid on the other side of the piston must be allowed to escape freely - if the
incompressible fluid was trapped the cylinder could not advance. The force the cylinder can
exert is proportional to the cross sectional area of the cylinder.
Under normal operating conditions, both ends of the cylinder are filled with fluid. If additional
fluid enters port A, the piston will move toward the right, but the fluid must be able to escape
through port B.
Some actuators can create rotary motion and are very similar to the pump designs. The figure
below shows a gear motor rotary actuator.
42
For the motor, fluid is pumped in the left side of the case, putting that area under pressure.
Within the pressurized area, all surfaces receive a force, but only those three surfaces indicated
with arrow will effect rotation.
The pressure on the teeth next to the case will case the gears to rotate. The pressure on the
meshing teeth in the center would cause the gears to turn in the opposite direction, but this
torque is overpowered because two teeth are pushing the other way.
43
SEQUENTIAL CONTROL SYSTEMS
Sequence control
A sequential control system is a type of control system that involves the sequential execution of
well-defined operations, that are performed in a prescribed order. Each operation or activity is
called a step.
It is a control system that manages a process defined by a series of tasks to be performed i.e. a
sequence of operations, one after the other. Each operation in the sequence is performed either for
a certain period of time (in which case, it is time-driven), or until the task is finished e.g. as
indicated by a limit switch (in which case it is event-driven).
A time-driven sequence is open loop because there is no feedback, while an event-driven task is
closed loop because feedback signal is required to specify when the task is finished.
A typical example of a sequentially controlled system is the automatic washing machine. The first
event in the wash cycle is to fill the tub with water. This is an event-driven task because the water
is admitted till it gets to the proper level, as indicated by a float and limit switch (i.e. a closed loop).
The next two tasks, wash and spin drain, are each done for a specified period of time and are time-
driven events i.e. open loop.
Other examples of systems that use sequential control systems include elevators, and other systems
with interrelated operations, where an automatic sequential control system may trigger a series of
mechanical actuators in the correct sequence to perform a task. For example, various electric and
pneumatic transducers may fold and glue a cardboard box, fill it with the product, and then seal it
in an automatic packaging machine.
44
In sequential control, encoders and decoders are used to convert data from one format to another.
In natural language processing, encoder-decoder models are used to convert input sequences into
a single-dimensional vector (hidden vector). The decoder will convert the hidden vector into the
output sequence.
Encoder-Decoder models are jointly set to maximize the conditional probabilities of the target
sequence, given the input sequence.
45
Manual vs. Automatic Reset of Interlocks
A tripped component (e.g. a solenoid valve) needs to be reset after a trip had been initiated. The
reset may be done either automatically or manually.
Self-Canceling Interlock has automatic reset that returns the interlock system to normal operation,
when the usual process conditions have been re-established, or when the offending situation has
been effectively dealt with.
Manual Reset Interlock requires the operator to re-initiate the process before continuing the
operation of the equipment involved. This method is generally preferable over automatic reset
because it requires an investigation of the possible causes for the trip. Positive action by the
operating personnel to return the operating conditions to normal is required before the interlock
can be cancelled.
Manual reset on a solenoid valve is most commonly carried out by the use of a latching lever that
locks the valve when a trip occurs. Unlatch of the lever is required to return the solenoid valve to
its normal operation. Alternatively, a solenoid valve can simply be reset by the use of a pushbutton
that energizes the valve.
Practical interlock systems can be implanted through:
(i) Solenoid
(ii) Limit switches
(iii)Control relays
(iv) Digital
(v) Analogue
Programmable Logic Controllers
A programmable logic controller or PLC is an industrial-grade digital computer, designed to
perform control functions, applicable to many different types of process control cases.
The word “programmable” in its name reveals just why PLCs are so useful: the end-user is able to
program, or instruct, the PLC to do virtually any control function imaginable.
Unlike PID loop controllers, which are special-purpose devices intended to perform a single type
of control function, a PLC may be instructed to do almost anything with the signals it receives
from input devices.
PLCs can range from small modular devices with tens of inputs and outputs (I/O), in a housing
integral with the processor, to large rack-mounted modular devices with thousands of I/O, and
which are often networked to other PLC and SCADA systems.
46
The architecture of a PLC is based on the same principles of that used in a standard computer
architecture. However, PLC architecture does differ because the design is based around providing
high reliability, immunity to harsh industrial environment, ease of maintenance, and access to large
amounts of peripheral inputs and outputs.
A PLC consists of:
A processor unit (CPU) which interprets inputs, executes the control program stored in
memory and sends output signals,
A power supply unit which converts AC voltage to DC,
A memory unit storing data from inputs and program to be executed by the processor,
An input and output interface, where the controller receives and sends data from/to external
devices,
A communications interface to receive and transmit data on communication networks
from/to remote PLCs.
A programming terminal used to formulate the PLC program (eg ladder logic), load the
program into the controller and monitor/control the PLC and its program.
The block diagram below shows the basic architecture of a PLC
47
PLCs require programming device which is used to develop and later download the created
program into the memory of the controller.
48
Advantages of PLCs over control relay circuits.
Ability to interface/communicate with computers
Flexibility in programming and reprogramming
Supervisory control capability
Easier and cheaper to modify or expand the control system at a later date.
Reduced design, installation and component costs.
Solid-state components tend to last longer than the moving parts of electromechanical
relays
49
50