PROGRAMMABLE LOGIC CONTROLLERS AND MICROCONTROLLERS
Basics of programmable Logic Controllers, their working and
Instructions sets like latch master control self holding
Timer and counter instructions sets
Electrical drives which were controlled by relays
Design , modify and troubleshoot control circuit
UNIT 1: INTRODUCTION TO PLC
1.1 What is PLC? A programmable logic controller (PLC) or
programmable controller is an industrial digital
computer which has been ruggedized and adapted for the control
of manufacturing processes,
such as assembly lines, or robotic devices, or any activity that
requires high reliability control
and ease of programming and process fault diagnosis.
They were first developed in the automobile manufacturing
industry to provide flexible, ruggedized and easily programmable
controllers to replace hard-wired relays, timers and
sequencers. Since then they have been widely adopted as
high-reliability automation controllers
suitable for harsh environments. A PLC is an example of a "hard"
real-time system since output
results must be produced in response to input conditions within
a limited time, otherwise
unintended operation will result
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 a count of thousands of
I/O, and which are often networked to other PLC and SCADA
They can be designed for multiple arrangements of digital and
analog I/O, extended temperature ranges, immunity to electrical
noise, and resistance to vibration and impact. Programs to
machine operation are typically stored in battery-backed-up or
It was from the automotive industry in the USA that the PLC was
born. Before the PLC, control, sequencing, and safety interlock
logic for manufacturing automobiles was mainly composed of relays,
cam timers, drum sequencers, and dedicated closed-loop controllers.
Since these could
number in the hundreds or even thousands, the process for
updating such facilities for the yearly
model change-over was very time consuming and expensive, as
electricians needed to
individually rewire the relays to change their operational
When digital computers became available, being general-purpose
programmable devices, they were soon applied to control sequential
and combinatorial logic in industrial processes. However
these early computers required specialist programmers and
stringent operating environmental
control for temperature, cleanliness, and power quality. To meet
these challenges the PLC was developed with several key attributes.
It would tolerate the shop-floor environment, it would
support discrete (bit-form) input and output in an easily
extensible manner, it would not require
years of training to use, and it would permit its operation to
be monitored. Since many industrial processes have timescales
easily addressed by millisecond response times, modern (fast,
reliable) electronics greatly facilitate building reliable
controllers, and performance could be
traded off for reliability.
1.2Invention and early development
In 1968 GM Hydramatic (the automatic transmission division of
issued a request for proposals for an electronic replacement for
systems based on a white paper written by engineer Edward R.
Clark. The winning
proposal came from Bedford Associates of Bedford, Massachusetts.
The first PLC,
designated the 084 because it was Bedford Associates'
eighty-fourth project, was the
result Bedford Associates started a new company dedicated to
manufacturing, selling, and servicing this new product: Modicon,
which stood for
modular digital controller. One of the people who worked on that
project was Dick
Morley, who is considered to be the "father" of the PLC.
The Modicon brand was sold in 1977 to Gould Electronics, later
acquired by German
Company AEG, and then by French Schneider Electric, the current
oOne of the very
first 084 models built is now on display at Schneider Electric's
facility in North
Andover, Massachusetts. It was presented to Modicon by GM, when
the unit was
retired after nearly twenty years of uninterrupted service.
Modicon used the 84
moniker at the end of its product range until the 984 made its
Modern PLCs can be programmed in a variety of ways, from the
logic to programming languages such as specially adapted
dialects of BASIC and C.
Another method is state logic, a very high-level programming
language designed to
program PLCs based on state transition diagrams. The majority of
today adhere to the IEC 61131/3 control systems programming
standard that defines
5 languages: Ladder Diagram (LD), Structured Text (ST), Function
(FBD), Instruction List (IL) and sequential function chart
Many early PLCs did not have accompanying programming terminals
capable of graphical representation of the logic, and so the
logic was instead
represented as a series of logic expressions in some version of
similar to Boolean algebra. As programming terminals evolved, it
common for ladder logic to be used, for the aforementioned
reasons and because it
was a familiar format used for electro-mechanical control
panels. Newer formats
such as state logic and Function Block (which is similar to the
way logic is depicted
when using digital integrated logic circuits) exist, but they
are still not as popular as
ladder logic. A primary reason for this is that PLCs solve the
logic in a predictable
and repeating sequence, and ladder logic allows the programmer
(the person writing
the logic) to see any issues with the timing of the logic
sequence more easily than
would be possible in other formats.
PLC programs are typically written in a special application on a
computer, then downloaded by a direct-connection cable or over a
network to the
PLC. The program is stored in the PLC either in
battery-backed-up RAM or some
other non-volatile flash memory. Often, a single PLC can be
replace thousands of relays.
Early PLCs, up to the mid-1990s, were programmed using
programming panels or special-purpose programming terminals,
which often had
dedicated function keys representing the various logical
elements of PLC
programs Some proprietary programming terminals displayed the
PLC programs as graphic symbols, but plain ASCIIcharacter
contacts, coils, and wires were common. Programs were stored on
cartridges. Facilities for printing and documentation were
minimal due to lack of
memory capacity. The oldest PLCs used non-volatile magnetic core
More recently, PLCs are programmed using application software on
computers, which now represent the logic in graphic form instead
symbols. The computer is connected to the PLC through USB,
232, RS-485, or RS-422 cabling. The programming software allows
editing of the ladder-style logic. In some software packages, it
is also possible to
view and edit the program in function block diagrams, sequence
and structured text. Generally the software provides functions
for debugging and
troubleshooting the PLC software, for example, by highlighting
portions of the
logic to show current status during operation or via simulation.
The software will
upload and download the PLC program, for backup and restoration
some models of programmable controller, the program is
transferred from a
personal computer to the PLC through a programming board which
program into a removable chip such as an EPROM.
UNIT2: Timers and counters
2.1 INTRODUCTION-The main function of a timer is to keep an
output on for a specific length of time. A good example of this is
a garage light, where you want power to be cut off after 2 minutes
so as to
give someone time to go into the house. The three different
types of timers that are commonly used
are a Delay-OFF, a Delay-ON, and a Delay-ON-Retentive. A
Delay-OFF timer activates immediately when turned on, counts down
from a programmed time before cutting off, and is cleared when
enabling input is off. A Delay-ON timer is activated by input
and starts accumulating time, counts up
to a programmed time before cutting off, and is cleared when the
enabling input is turned off. A Delay-ON-Retentive timer is
activated by input and starts accumulating time, retains the
value even if the (ladder-logic) rung goes false, and can be
reset only by a RESET contact.Counters
are primarily used for counting items such as cans going into a
box on an assembly line. This is important because once something
is filled to its max the item needs to be moved on so something
can be filled. Many companies use counters in PLC's to count
boxes, count how many feet of
something is covered, or to count how many pallets are on a
truck. There are three types of counters,
Up counters, Down counters, and Up/Down counters. Up counters
count up to the preset value, turn on the CTU (CounT Up output)
when the preset value is reached, and are cleared upon receiving
reset. Down counters count down from a preset value, turns on
the CTD (CounT Down output) when
0 is reached, and are cleared upon reset. Up/Down counters count
up on CU, count down on CD, turn on CTUD (CounT Up/Down output)
when the preset value is reached, and cleared on reset.
2.2 Programmable logic relay (PLR) -In more recent years, small
products called PLRs (programmable logic relays), and also by
similar names, have become more common and accepted. These are much
like PLCs, and are used in light industry where only a few points
of I/O (i.e. a few
signals coming in from the real world and a few going out) are
needed, and low cost is desired. These
small devices are typically made in a common physical size and
shape by several manufacturers, and branded by the makers of larger
PLCs to fill out their low end product range. Popular names
PICO Controller, NANO PLC, and other names implying very small
controllers. Most of these have 8
to 12 discrete inputs, 4 to 8 discrete outputs, and up to 2
analog inputs. Size is usually about 4" wide,
3" high, and 3" deep. Most such devices include a tiny
postage-stamp-sized LCD screen for viewing simplified ladder logic
(only a very small portion of the program being visible at a given
status of I/O points, and typically these screens are
accompanied by a 4-way rocker push-button plus
four more separate push-buttons, similar to the key buttons on a
VCR remote control, and used to
navigate and edit the logic. Most have a small plug for
connecting via RS-232 or RS-485 to a personal computer so that
programmers can use simple Windows applications for programming
instead of being forced to use the tiny LCD and push-button set
for this purpose. Unlike regular PLCs
that are usually modular and greatly expandable, the PLRs are
usually not modular or expandable, but their price can be two
orders of magnitude less than a PLC, and they still offer robust
deterministic execution of the logics. 2.3 Scan time: A PLC
program generally loops i.e. executes repeatedly, as long as the
system is running. At the start of each execution loop, the
status of all physical inputs are copied to
an area of memory, sometimes called the "I/O Image Table", which
is accessible to the processor.
The program then runs from its first instruction rung down to
the last rung. It takes some time for the processor of the PLC to
evaluate all the rungs and update the I/O image table with the
outputs. Scan times of a few milliseconds may be encountered
for small programs and fast
processors, but for older processors and very large programs
much longer scan times (on the order of 100 ms) may be encountered.
Excessively long scan times may mean the response of the PLC to
changing inputs or process conditions is too slow to be useful
.As PLCs became more advanced,
methods were developed to change the sequence of ladder
execution, and subroutines were
implemented. This simplified programming could be used to save
scan time for high-speed processes; for example, parts of the
program used only for setting up the machine could be segregated
those parts required to operate at higher speed. Newer PLCs now
have the option to run the logic
program synchronously with the IO scanning. This means that IO
is updated in the background and the logic reads and writes values
as it's required during the logic scanning.
UNIT 3: WORKING OF PLC
3.1Process of a scan cycle -There are 5 main steps in a scan
Executing the program
Processing communication requests
Executing CPU diagnostics
3.2User interface-User interface and List of human-computer
interaction topics.PLCs may need to
interact with people for the purpose of configuration, alarm
reporting, or everyday control. A human-
machine interface (HMI) is employed for this purpose. HMIs are
also referred to as man-machine
interfaces (MMIs) and graphical user interfaces (GUIs). A simple
system may use buttons and lights to interact with the user. Text
displays are available as well as graphical touch screens. More
systems use programming and monitoring software installed on a
computer, with the PLC connected via a communication interface.
3.2 Communications-Many models of PLCs have built-in
communications ports, using RS-232, RS-422, RS-485, or Ethernet.
Various protocols are usually included. Many of these protocols are
specific.Most modern PLCs can communicate over a network to some
other system, such as a
computer running a SCADA (Supervisory Control And Data
Acquisition) system or web browser.PLCs used in larger I/O systems
may have peer-to-peer (P2P) communication between
processors. This allows separate parts of a complex process to
have individual control while allowing
the subsystems to co-ordinate over the communication link. These
communication links are also often
used for HMI devices such as keypads or PC-type workstations.
Formerly, some manufacturers offered dedicated communication
modules as an add-on function where the processor had no
3.3 Security-Prior to the discovery of the Stuxnet computer worm
in June 2010, security of PLCs received little attention. Modern
PLCs generally contain a real-time operating system such as OS-
9 or VxWorks, and exploits for these systems exist much as they
do for desktop computer operating
systems such as Microsoft Windows. PLCs can also be attacked by
gaining control of a computer they communicate with.
3.4 Simulation-In order to properly understand the operation of
a PLC, it is necessary to spend considerable time programming,
testing, and debugging PLC programs. PLC systems are inherently
expensive, and down-time is often very costly. In addition, if a
PLC is programmed incorrectly it can result in lost productivity
and dangerous conditions. PLC simulation software such as PLCLogix
save time in the design of automated control applications and
can also increase the level of safety
associated with equipment since many"what if" scenarios can be
tried and tested before the system is activated.
3.5 Redundancy-Some special processes need to work permanently
with minimum unwanted down time. Therefore, it is necessary to
design a system which is fault-tolerant and capable of handling the
process with faulty modules. In such cases to increase the system
availability in the event of hardware
component failure, redundant CPU or I/O modules with the same
functionality can be added to
hardware configuration for preventing total or partial process
shutdown due to hardware failure
3.6 PLC Hardware-The hardware components of a PLC system are
CPU, Memory, Input/Output,
Power supply unit, and programming device. Below is a diagram of
the system overview of PLC.
An Overview Of Hardware Components Of A PLC System
CPU – Keeps checking the PLC controller to avoid errors. They
perform functions including logic
operations, arithmetic operations, computer interface and many
Memory – Fixed data is used by the CPU. System (ROM) stores the
data permanently for the operating
system. RAM stores the information of the status of input and
output devices, and the values of timers,
counters and other internal devices.
I/O section – Input keeps a track on field devices which
includes sensors, switches.
O/P Section - Output has a control over the other devices which
includes motors, pumps, lights and
solenoids. The I/O ports are based on Reduced Instruction Set
Power supply – Certain PLCs have an isolated power supply. But,
most of the PLCs work at 220VAC or
Programming device – This device is used to feed the program
into the memory of the processor. The
program is first fed to the programming device and later it is
transmitted to the PLC’s memory. System Buses – Buses are the paths
through which the digital signal flows internally of the PLC. The
system buses are: Data bus is used by the CPU to transfer data
among different elements.Address bus
sends the location’s addresses to access the data.
3.7Working of PLC (Programmable Logic Controller)
The Programmable logic controller functions in four steps.
Typical Block Diagram Of Programmable Logic Controller
Input scan: The state of the input is scanned which is connected
externally. The inputs include switches,
pushbuttons, and proximity sensors, limit switches, pressure
switches. Ideally, they are transformers and
Program scan: The loaded program is executed to carry out the
Output scan: The input sources have a control over the output
ports to energize or de-energize them. The
outputs include solenoids, valves, motors, actuator, and pumps.
Depending on the model of PLC, these
relays can be transistors, triacs or relays.
UNIT4: PLC Applications
4.1 INTRODUCTION-The simple suitable application is a conveyor
system. The requirements of the
conveyor systems are as follows:
A programmable logic controller is used to start and stop the
motors of the conveyor belt.
The conveyor system has three segmented conveyor belts. Each
segment is run by a motor.
To detect the position of a plate, a proximity switch is
positioned at the segment’s end.
The first conveyor segment is turned ON always.
The proximity switch in the first segment detects the plate to
turn ON the second conveyor segment.
The third conveyor segment is turned ON when the proximity
switch detects the plate at the second
As the plate comes out of the detection range, the second
conveyor is stopped after 20 secs.
When the proximity switch fails to detect the plate, the third
conveyor is stopped after 20 secs.
Programmable Logic Controllers were discovered by the automotive
industry to substitute the re-
wiring of the machine’s control panel.
Prior to the invention of PLC, automobiles were manufactured
using plenty of relays, cam timers,
and closed loop controllers. The electricians had to re-wire
every part of the machine daily which
was time consuming and highly expensive on the financial
Later in the year 1968, a request for an electronic device for
the hard-wired relay systems was
made by GM hydramatic. Bedford Associates won the proposal and
started a new company to
develop, fabricate, sell, and service this new launched product.
The first PLC launched was
designated 084 as it was the eighty fourth projects of Bedford
Associates. Dick Morley worked on
this project and is being considered as the Father of PLC. In
the year 1977, the brand invented by
Modicon was sold to Gould Electronics. The Gould Electronics
later sold it to German Company
AEG which was later taken over by French Schneider Electric.
The first 084 model of PLC was revealed in North Andover,
Massachusetts at the Modicon
The automotive industry is one of the largest users of PLC.
4.3Advantages & Disadvantages Advantages
PLCs can be programmed easily which can be understood clearly
They are fabricated to survive vibrations, noise, humidity, and
The controller has the input and output for interfacing.
It is a tedious job when replacing or bringing any changes to
Skilful work force is required to find its errors.
Lot of effort is put to connect the wires.
The hold up time is usually indefinite when any problem
UNIT 5: .PLC Memory Organisation:
The term processor memory organization refers to how certain
areas of memory in a given Basis of PLC
Programming are used. Different PLC manufacturers organize their
memories in different ways. Even
though they do not use the same memory make up and terminology,
the principles involved are the same.
Figure 21.67(a) shows a typical connection of a switch to the
input image table through the input
module. When the switch is closed the processor detects a
voltage at the input terminal and
records that information by storing a binary 1 in the proper bit
location. Each connected input
has a bit in the input image table that corresponds exactly to
the terminal to which the input is connected. The input image table
is constantly being changed to reflect the current status of
switch. If the input is ON (switch closed), its corresponding
bit in the table is set to 1. If the input is OFF (switch open) the
corresponding bit is cleared or reset to zero.
The output image table is an array of bits that controls the
status of digital output devices which
are connected to output interface circuits. Figure 21.67(b)
shows a typical connection of a light to the output image table
through the output module.
The status of this light (ON-OFF) is controlled by the user
program and indicated by the
presence of 1 ‘ s (ON) and 0’s (OFF). Each connected output has
a bit in the output image table
that corresponds exactly to the terminal to which output is
connected. If the program calls for a specific output to be ON,
it’s corresponding bit in the table is set to 1, if the program
calls for the output to be OFF, its corresponding bit in the table
is set to 0.
During each operating cycle, the processor reads all the inputs
takes their values and according to the user program energises or
de-energises the outputs. This process is known as a scan. Figure.
21.68 illustrates a single PLC scan, which consists of the 1/0 scan
and the program scan.
5.3 The Basis of PLC Programming-
Scan time specification indicates how fast the controller can
react to changes in inputs. Scan time varies with program content
and length. The time required to make a single scan can
vary from 1 ms to 100 ms. If a controller has to react to an
input signal that changes states twice during the scan time it is
possible that the PLC will never be able to detect this change.
The scan is normally a continuous and sequential process of
reading the status of inputs, evaluating the control logic and
updating the outputs. Figure. 21.69 illustrates this process.
When the input device connected to address 10114 is closed, the
input module circuit senses a voltage and a 1 (ON) condition is
entered into the input image table bit 101-14.
During the program scan, the processor examines bit 101-14 for a
1 (ON) condition. In this case, since input 101-14 is 1, the rung
is said to be TRUE. The processor then sets the output image
table 001-04 to 1. The processor turns on output 101-14 during
the next I/O scan, and the output
device (light) wired to this terminal becomes energized. This
process is repeated as long as the processor is in the RUN mode. If
the input device were to open, a 0 would be placed in the input
image table. As a result, the rung would be said to be False.
The processor would then set the output image table bit 001-04 to 0
causing the output device to turn off.
5.4 PLC PROCESSOR MEMORY ORGANIZATION
The memory of a PLC is organized by types.
The memory space can be divided into two broad categories:
5.4.1Program and Data Memory:
Advanced ladder logic functins allow controllers to perform
calculatins, make decisions and do
other complex tasks. Timers and counters are examples of ladder
logic functions. They are more comples than basic inputs contacts
and output coils and relay heavily upon data stored in the
memory of the PLC.
The user program will account for most of the memory of a PLC
system. Program files contain the logic controlling machine
This logic consistes of instructions that are programmed in a
ladder logic format.
5.4.2 DATA FILES:
The data file protion of memory stores input and output status,
processor status, the status of
various bits and numerical data.
5.5 Programmable Logic Controllers (PLCs) are the major
components in industrial automation and control systems. The
controlling nature of PLC is ranging from simple- push button
switching to a single
motor to several complex control structures. The PLC programming
is an important task of designing and implementing control
application depending on customers need. A PLC program consists of
a set of
instructions either in textual or graphical form, which
represents the logic to be implemented for
specific industrial realtime applications.
A dedicated PLC programming software comes from a PLC hardware
of specific manufacturer that allows entry and development of user
application code, which can be finally download to the PLC
hardware. This software also ensures Human Machine Interface
(HMI) as a graphical representation of
variables. Once this program gets downloaded to the PLC and if
the PLC is placed in Run mode, then the
PLC continuously works according to the program. Before going to
the program of the PLC, let us know
the basics of the PLC programming tutorial and its basic
UNIT6: MICRO CONTROLLER SERIES (MCS-51)
The Intel MCS-51 (commonly termed 8051) is a single chip
microcontroller (MCU) series developed by Intel in 1980 for use in
embedded systems. The architect of the instruction set of the
Intel MCS-51 was John H. Wharton. Intel's original
versions were popular in the 1980s and
early 1990s and enhanced binary compatible derivatives remain
popular today. It is an example of a complex instruction set
computer, and has separate memory spaces for program
and data (Harvard architecture). Intel's original MCS-51 family
was developed using N-type metal-oxide-semiconductor (NMOS)
technology like its predecessor Intel MCS-48, but later
versions, identified by a letter C in their name (e.g., 80C51) used
complementary metal–oxide–semiconductor (CMOS) technology and
consume less power than their NMOS predecessors. This made them
more suitable for battery-
The family was continued in 1996 with the enhanced 8-bit MCS-151
and the 8/16/32-bit MCS-251 family of binary compatible
microcontrollers. While Intel no longer manufactures the
MCS-51, MCS-151 and MCS-251 family, enhanced binary compatible
derivatives made by
numerous vendors remain popular today. Some derivatives
integrate a digital signal
processor (DSP). Beyond these physical devices, several
companies also offer MCS-51 derivatives as IP cores for use in
field-programmable gate array (FPGA) or application-specific
integrated circuit (ASIC) designs.
6.2 PIN DIAGRAM OF MCS-51
Pins 1 to 8 − These pins are known as Port 1. This port doesn’t
serve any other functions. It is
internally pulled up, bi-directional I/O port.
Pin 9 − It is a RESET pin, which is used to reset the
microcontroller to its initial values.
Pins 10 to 17 − These pins are known as Port 3. This port serves
some functions like interrupts,
timer input, control signals, serial communication signals RxD
and TxD, etc.
Pins 18 & 19 − These pins are used for interfacing an
external crystal to get the system clock.
Pin 20 − This pin provides the power supply to the circuit.
Pins 21 to 28 − These pins are known as Port 2. It serves as I/O
port. Higher order address bus
signals are also multiplexed using this port.
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 EA pin which stands for External Access input.
It is used to enable/disable the
external memory interfacing.
Pin 31 − This is ALE pin which stands for Address Latch Enable.
It is used to demultiplex the
address-data signal of port.
Pins 32 to 39 − These pins are known as Port 0. It serves as I/O
port. Lower order address and
data bus signals are multiplexed using this port.
Pin 40 − This pin is used to provide power supply to the
UNIT 7: ASSEMBLY LANGUAGE PROGRAMMING
An assembler program creates object code by translating
combinations of mnemonics and syntax for operations and addressing
modes into their numerical equivalents. This representation
typically includes an operation code ("opcode") as well as other
control bits and
data. The assembler also calculates constant expressions and
resolves symbolic names for
memory locations and other entities. The use of symbolic
references is a key feature of
assemblers, saving tedious calculations and manual address
updates after program modifications. Most assemblers also include
macro facilities for performing textual substitution –
e.g., to generate common short sequences of instructions as
inline, instead of called subroutines.
Some assemblers may also be able to perform some simple types of
instruction set-specific optimizations. One concrete example of
this may be the ubiquitous x86 assemblers from various vendors.
Most of them are able to perform jump-instruction replacements
replaced by short or relative jumps) in any number of passes, on
request. Others may even do
simple rearrangement or insertion of instructions, such as some
assemblers for RISC architectures that can help optimize a sensible
instruction scheduling to exploit the CPU
pipeline as efficiently as possible.
Like early programming languages such as Fortran, Algol, Cobol
and Lisp, assemblers have been available since the 1950s and the
first generations of text based computer interfaces.
However, assemblers came first as they are far simpler to write
than compilers for high-level
languages. This is because each mnemonic along with the
addressing modes and operands of an instruction translates rather
directly into the numeric representations of that particular
instruction, without much context or analysis. There have also
been several classes of translators
and semi automatic code generators with properties similar to
both assembly and high level
languages, with speedcode as perhaps one of the better known
There may be several assemblers with different syntax for a
particular CPU or instruction set architecture. For instance, an
instruction to add memory data to a register in a x86-family
processor might be add eax,[ebx] , in original Intel syntax,
whereas this would be written addl
(%ebx),%eax in the AT&T syntax used by the GNU Assembler.
Despite different appearances,
different syntactic forms generally generate the same numeric
machine code, see further below. A
single assembler may also have different modes in order to
support variations in syntactic forms
as well as their exact semantic interpretations (such as
FASM-syntax, TASM-syntax, ideal mode
etc., in the special case of x86 assemblyprogramming).
It is a computer program that transforms computer code written
in one programming language (the source language) into another
programming language (the target language).
Compilers are a type of translator that support digital devices,
primarily computers. The
name compiler is primarily used for programs that translate
source code from a high-level programming language to a lower level
language (e.g., assembly language, object code,
or machine code) to create an executable program.
However, there are many different types of compilers. If the
compiled program can run on a computer whose CPU or operating
systemis different from the one on which the compiler runs, the
compiler is a cross-compiler. A bootstrap compiler is written in
the language that it intends to
compile. A program that translates from a low-level language to
a higher level one is
a decompiler. A program that translates between high-level
languages is usually called a source-
to-source compiler or transpiler. A language rewriter is usually
a program that translates the form of expressions without a change
of language. The term compiler-compiler refers to tools
used to create parsers that perform syntax analysis.
A compiler is likely to perform many or all of the following
operations: preprocessing, lexical analysis, parsing, semantic
analysis(syntax-directed translation), conversion of input programs
to an intermediate representation, code optimization and code
generation. Compilers implement
these operations in phases that promote efficient design and
correct transformations of source
input to target output. Program faults caused by incorrect
compiler behavior can be very difficult to track down and work
around; therefore, compiler implementers invest significant effort
ensure compiler correctness.
Compilers are not the only translators used to transform source
programs. An interpreter is computer software that transforms and
then executes the indicated operations. The translation
process influences the design of computer languages which leads
to a preference of compilation or interpretation. In practice, an
interpreter can be implemented for compiled languages and
compilers can be implemented for interpreted languages.
Assembly directives, also called pseudo-opcodes,
pseudo-operations or pseudo-ops, are commands given to an assembler
"directing it to perform operations other than assembling
instructions." Directives affect how the assembler operates and
"may affect the object code, the
symbol table, the listing file, and the values of internal
assembler parameters." Sometimes the
term pseudo-opcode is reserved for directives that generate
object code, such as those that
The names of pseudo-ops often start with a dot to distinguish
them from machine instructions. Pseudo-ops can make the assembly of
the program dependent on parameters input by a
programmer, so that one program can be assembled different ways,
perhaps for different
applications. Or, a pseudo-op can be used to manipulate
presentation of a program to make it easier to read and maintain.
Another common use of pseudo-ops is to reserve storage areas
run-time data and optionally initialize their contents to known
Symbolic assemblers let programmers associate arbitrary names
(labels or symbols) with memory locations and various constants.
Usually, every constant and variable is given a name so
instructions can reference those locations by name, thus promoting
self-documenting code. In
executable code, the name of each subroutine is associated with
its entry point, so any calls to a
subroutine can use its name. Inside subroutines, GOTO
destinations are given labels. Some assemblers support local
symbols which are lexically distinct from normal symbols (e.g., the
of "10$" as a GOTO destination).
Some assemblers, such as NASM, provide flexible symbol
management, letting programmers manage different namespaces,
automatically calculate offsets within data structures, and
labels that refer to literal values or the result of simple
computations performed by the assembler.
Labels can also be used to initialize constants and variables
with relocatable addresses.
Like most other computer languages, allow comments to be added
to program source code that will be ignored during assembly.
Judicious commenting is essential in assembly
language programs, as the meaning and purpose of a sequence of
instructions can be difficult to determine. The "raw"
(uncommented) assembly language
generated by compilers or disassemblers is quite difficult to
read when changes must be
UNIT 8 :Applications of 8051 microcontroller
1.1Applications of 8051 Microcontroller:
The microcontroller 8051 applications include large amount of
machines, principally because it is simple to incorporate in a
project or to assemble a machine around it. The
following are the key spots of spotlight:
Energy Management: Competent measuring device systems aid in
calculating energy consumption in domestic and industrialized
applications. These meter systems are prepared competent by
Touch screens: A high degree of microcontroller suppliers
integrate touch sensing abilities in their designs. Transportable
devices such as media players, gaming devices & cell phones
are some illustrations of micro-controller integrated with touch
Automobiles: The microcontroller 8051 discovers broad
recognition in supplying automobile solutions. They are extensively
utilized in hybrid motor vehicles to control engine variations.
In addition, works such as cruise power and anti-brake mechanism
has created it more capable with the amalgamation of
Medical Devices: Handy medicinal gadgets such as glucose &
blood pressure monitors bring into play micro-controllers, to put
on view the measurements, as a result, offering
higher dependability in giving correct medical results.
MULTIPLE CHOICE QUESTIONS
Q1. The PLC was invented by. a) Bill Gates b) Dick Morley c)
Bill Landis d) Tod Cunningham
Q2. The first company to build PLCs was .
a) General Motors b) Allen Bradley c) Square D d) Modicon
Q3. Classify the following as automatic control, manual control,
discrete control or continuous control.
a) A sensor is used to turn on and off the lights of a room.
b) A temperature sensor is used to adjust the room temperature
and maintain it at a set point.
c) A user starts the bottle filling machine, places the bottle
on the conveyor belt to fill it with the required
d) The luggage system at the airport.
e) A factory that makes red pens and has no human employees.
Q4. The part that monitors the inputs and makes decisions in a
PLC is the CPU.
a. True b. False c. None of the above
Q5. One of the following is an input device
a. Motor b. Light c. Valve d. Sensor
Q6. Which one of the following is not a PLC manufacturer
a. Siemens b. Mitsubishi c. Microsoft d. ABB
Q7. Solenoids, lamps, motors are connected to:
a. Analog output b. Digital output c. Analog input d. Digital
Q8. In a PLC “I” is used for output and “Q” is used for
a. True b. False c. None of the above
Q9. PLC stands for programmable logo controller
a. True b. False c. None of the above
Q10. To increase the number of inputs and outputs of the PLC,
one can use expansion modules.
a. True b. False c. None of the above
Q11. An example of discrete (digital) control is:
a. Varying the volume of a music system
b. Turning a lamp ON or OFF
c. Varying the brightness of a lamp
d. Controlling the speed of a fan
Q12. A solenoid is an example of an output device.
a. True b. False c. None of the above
Q13. Which of the following statements is not correct? a) The
PLC rung output [-( )-] is a discrete output instruction or bit in
b) Each rung of the ladder logic represents a logical statement
executed in software – inputs on the right
and outputs on the left.
c) Input and output instructions in ladder logic do not directly
represent the switches and actuators.
d) PLC input instructions are logical symbols associated with
voltage at the input module terminals.
Q14. Which of the following statements is correct?
a) Ladder logic is a PLC graphical programming technique
introduced in the last 10 years.
b) A ladder logic program is hard to analyze because it is
totally different when compared with the
equivalent relay logic solution.
c) The number of ladder logic virtual relays and input and
output instructions is limited only by memory
d) The number of contacts for a mechanical relay is limited to
number of coils on the relay.
Q15. Which of the following statements is NOT correct?
a) The status of each input can be checked from one location and
outputs can be forced on and off.
b) All symbols in the RLL represent actual components and
contacts present in the control system.
c) PLCs are not as reliable as electromechanical relays in
d) Input (-| |-) and output (- ( ) -) instruction symbols in the
ladder logic represent only data values stored
in PLC memory.
Q16. Which of the following statements is NOT correct?
a) If a problem in a PLC module occurs, the module can be
changed in a matter of minutes without any
changes in wiring.
b) Outputs can be paralleled on the same rung.
c) The physical wires between the input and output field devices
and the PLC input and output modules
are the only signal wires required in the PLC system.
d) The cost and size of PLCs have increased significantly in the
last 10 years.
Q17. Which of the following statements about a single pole
double throw relay is NOT true?
a) It is called an SPDT type of relay.
b) It has one common contact.
c) It has two positions (NC and NO).
d) It has a center off position.
Q18. Which of the following statements about a single pole
double throw relay is true?
a) Insulators are used in the armature to isolate the electrical
switching contacts from the rest of the
b) The NC contact and the pole are in contact when the relay is
c) It has just one coil.
d) All of the above.
Q19. Which of the following statements about RLL is NOT
a) NO contact symbol has two parallel lines to indicate an open
b) RLL stands for Relay Ladder Logic.
c) NC contact symbol has the same two parallel lines with a line
across them to indicate closed contacts.
d) The right power rail is positive or the high side of the
source, and the left power rail is the power
return or ground.
Q20. The _____ is moved toward the relay electromagnet when the
relay is on.
a) Armature b) Coil c) NO contact d) NC contact
Q21. When a relay is NOT energized:
a) There is an electrical path through the NO contacts
b) There is an electrical path through the NC contacts
c) Neither the NO or the NC contacts have an electrical path
d) Both the NO and the NC contacts have an electrical path
Q22. Which of the following RLL applications is not normally
performed in early automation systems?
a) On/off control of field devices
b) Logical control of discrete devices
c) On/off control of motor starters
d) Proportional control of field devices
Q23. Current flows into the _____
a) Input terminal of a sinking DC input module
b) Input terminal of a sinking output field device
c) Output terminal of a sinking input field device
d) All of the above
Q24. In a current sinking DC input module _____
a) The current flows out of the input field device
b) Requires that a AC sources be used with mechanical
c) The current flows out of the input module
d) Currents can flow in either direction at the input module
Q25. AC output field devices can interface to _____
Short Questions & Answers
Q1. What is PLC?
Q2. Role of PLC in Automation ?
Q3. Difference Between Fixed and Modular PLCs ?
Q4. What is meaning of scan time in PLC?
Q5. What is redundancy ?
Q6. What are components of redundant PLC system ?
Q.7 Manufacturers of PLC?
Long Questions & Answers
Q1. What is ladder diagram ?
Q.2. Difference between PLC & Relay ?
Q.3 Memory Organization of PLC??
Q.4 What is role of I/O modules?
Q.5 Scan cycle of PLC?
Q.6 Architecture of PLC?
Q7. Working of PLC and its applications?
Q8.Pin diagram of MCS8051?
UNIT2: Timers and counters2.1 INTRODUCTION-The main function of
a timer is to keep an output on for a specific length of time. A
good example of this is a garage light, where you want power to be
cut off after 2 minutes so as to give someone time to go into the
house. The thre...2.2 Programmable logic relay (PLR) -In more
recent years, small products called PLRs (programmable logic
relays), and also by similar names, have become more common and
accepted. These are much like PLCs, and are used in light industry
where only a fe...2.3 Scan time: A PLC program generally loops i.e.
executes repeatedly, as long as the controlled system is running.
At the start of each execution loop, the status of all physical
inputs are copied to an area of memory, sometimes called the "I/O
Imag...UNIT 3: WORKING OF PLC3.1Process of a scan cycle -There are
5 main steps in a scan cycle:Reading inputsExecuting the
programProcessing communication requestsExecuting CPU
diagnosticsWriting outputs3.2User interface-User interface and List
of human-computer interaction topics.PLCs may need to interact with
people for the purpose of configuration, alarm reporting, or
everyday control. A human-machine interface (HMI) is employed for
this purpose. ...3.2 Communications-Many models of PLCs have
built-in communications ports, using RS-232, RS-422, RS-485, or
Ethernet. Various protocols are usually included. Many of these
protocols are vendor specific.Most modern PLCs can communicate over
a network t...3.3 Security-Prior to the discovery of the Stuxnet
computer worm in June 2010, security of PLCs received little
attention. Modern PLCs generally contain a real-time operating
system such as OS-9 or VxWorks, and exploits for these systems
exist much a...3.4 Simulation-In order to properly understand the
operation of a PLC, it is necessary to spend considerable time
programming, testing, and debugging PLC programs. PLC systems are
inherently expensive, and down-time is often very costly. In
addition, ...3.5 Redundancy-Some special processes need to work
permanently with minimum unwanted down time. Therefore, it is
necessary to design a system which is fault-tolerant and capable of
handling the process with faulty modules. In such cases to increase
t...3.6 PLC Hardware-The hardware components of a PLC system are
CPU, Memory, Input/Output,Power supply unit, and programming
device. Below is a diagram of the system overview of
PLC.4.2History4.3Advantages & Disadvantages5.4 PLC PROCESSOR
MEMORY ORGANIZATIONThe memory of a PLC is organized by types.UNIT
7: ASSEMBLY LANGUAGE PROGRAMMING7.1 AssemblerQ2. The first company
to build PLCs was .Q3. Classify the following as automatic control,
manual control, discrete control or continuous control.Q4. The part
that monitors the inputs and makes decisions in a PLC is the
CPU.Q5. One of the following is an input deviceQ6. Which one of the
following is not a PLC manufacturerQ7. Solenoids, lamps, motors are
connected to:Q8. In a PLC “I” is used for output and “Q” is used
for inputQ9. PLC stands for programmable logo controllerQ10. To
increase the number of inputs and outputs of the PLC, one can use
expansion modules.Q11. An example of discrete (digital) control
is:Q12. A solenoid is an example of an output device.Q13. Which of
the following statements is not correct?Q14. Which of the following
statements is correct?Q15. Which of the following statements is NOT
correct?Q16. Which of the following statements is NOT correct?Q17.
Which of the following statements about a single pole double throw
relay is NOT true?Q18. Which of the following statements about a
single pole double throw relay is true?Q19. Which of the following
statements about RLL is NOT true?Q20. The _____ is moved toward the
relay electromagnet when the relay is on.Q21. When a relay is NOT
energized:Q22. Which of the following RLL applications is not
normally performed in early automation systems?Q23. Current flows
into the _____Q24. In a current sinking DC input module _____Q25.
AC output field devices can interface to _____Short Questions &
Q1. What is PLC?Q2. Role of PLC in Automation ?Q3. Difference
Between Fixed and Modular PLCs ?Q5. What is redundancy ?Q6. What
are components of redundant PLC system ?Q.7 Manufacturers of
PLC?Long Questions & AnswersQ1. What is ladder diagram ?Q.2.
Difference between PLC & Relay ?Q.3 Memory Organization of
PLC??Q.4 What is role of I/O modules?Q.5 Scan cycle of PLC?Q.6
Architecture of PLC?Q7. Working of PLC and its applications?Q8.Pin
diagram of MCS8051?