0% found this document useful (0 votes)
83 views

Ch05 Basics of PLC Programming

Uploaded by

Dupree Cleveland
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Ch05 Basics of PLC Programming

Uploaded by

Dupree Cleveland
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

®

Because learning changes everything.

Programmable
Logic
Controllers
Frank D.
Petruzella

Sixth Edition

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.
Chapter 5
Basics of PLC
Programming

Access the text alternative for slide images.

© McGraw Hill LLC 2


Section 5.1

Processor Memory Organization

© McGraw Hill LLC 3


Rack-based memory
Rack-based memory addresses are derived
using the rack number, the I/O module slot
number and the screw terminal number
where the I/O device is wired.

© McGraw Hill LLC 4


Tag-based memory
Tag-based memory use a tag to identify a memory
location. There are no fixed areas of memory
allocated for I/O addresses or other types of data.

Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 5


Memory space

The Logix 500


memory space is
divided into two:
Program files
and Data files.

Access the text alternative for slide images.

© McGraw Hill LLC 6


Program Files
Program files are the part of
the processor memory that
stores the user ladder logic
program. The program
accounts for most of the total
memory of a given PLC system.

Access the text alternative for slide images.

© McGraw Hill LLC 7


Data Files
The Data file portion stores input and output
status, processor status, the status of various
bits, and numerical data.

© McGraw Hill LLC Access the text alternative for slide images.
8
Type of Data

Data files are


organized by
the type of data
they contain.

Access the text alternative for slide images.

© McGraw Hill LLC 9


SLC address format
I/O address format for the SLC family of PLCs.

Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 10


Data tables
The SLC 500 stores data in data tables that
are based on 16-bit words.
You access these data by specifying the address of
the data you want.

The addresses in the output data file and the input


data file are potential locations for I/O modules
mounted in the chassis.
Access the text alternative for slide images.

© McGraw Hill LLC Source: Courtesy of TheLearningPit 11


Input image table
The input image table
is allocated to storing
the on/off status of
connected discrete
inputs.
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 0.
© McGraw Hill LLC Access the text alternative for slide images.
12
Output image table
The output image table is
allocated to storing the
on/off status of connected
discrete outputs.
If the program calls for
an output to be ON, its
corresponding bit in the
table is set to 1.
If the program calls for
an output to be OFF, its
corresponding bit in the
table is set to 0.
© McGraw Hill LLC Access the text alternative for slide images.
13
Micro PLC connections
Typically, micro PLCs have a fixed number of
inputs and outputs.

This controller has 20 discrete inputs with addresses I/0 through


I/19 and 12 discrete outputs with addresses O/1 through O/11.
Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 14


Section 5.2

Program Scan

© McGraw Hill LLC 15


Program scan cycle
During each program scan cycle, the processor
reads all the inputs, takes these values, and
energizes or de-energizes the outputs according
to the user program.

© McGraw Hill LLC Access the text alternative for slide images.
16
Speed of scan
The time it takes to complete a scan cycle is a
measure of how fast the controller can react to
changes in inputs.
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.
Access the text alternative for slide images.

© McGraw Hill LLC 17


Scan time
The scan time is a function of:
• The speed of the processor module.
• The length of the ladder program.
• The type of instructions executed.
• The actual ladder true/false conditions.

The PLC computes the scan time each time


the END instruction is executed.

Typical scan time data include the


maximum scan time and the last scan time.

© McGraw Hill LLC 18


Electrical Continuity
In a rung of a hardwired circuit there must
be electrical continuity in order for the load
to energize.

The rung has electrical continuity only when the


current flows is established in a path from one
side of the power rail to the other.
© McGraw Hill LLC 19
A PLC ladder logic rung is evaluated
in terms of logical continuity.

When there is a continuous path of true conditional


instructions in a rung, logical continuity exists;
accordingly the output instruction is true and the
status bit will be set 1 (ON).
Access the text alternative for slide images.

© McGraw Hill LLC 20


Overview of the data flow during
the scan process.

Access the text alternative for slide images.

© McGraw Hill LLC 21


Scan process
applied to a
multiple rung
program.

Access the text alternative for slide images.

© McGraw Hill LLC 22


Vertical versus horizontal scan patterns.

Access the text alternative for slide images.

© McGraw Hill LLC 23


Section 5.3

PLC Programming Languages

© McGraw Hill LLC 24


PLC programming language refers to the method
by which the user communicates information to
the PLC.

Standard PLC programming languages


Access the text alternative for slide images.

© McGraw Hill LLC 25


Ladder Diagram programming
Ladder Diagram programming is a symbolic
depiction of instructions arranged in rungs
similar to ladder-formatted schematic diagrams.

Hardwired relay
control circuit

Equivalent ladder
diagram program
© McGraw Hill LLC Access the text alternative for slide images.
26
Instruction List programming
Instruction list programming language consists
of a series of instructions that refer to the basic
AND, OR, and NOT logic functions.

Hardwired relay
control circuit

Equivalent instruction
list program
© McGraw Hill LLC Access the text alternative for slide images.
27
Functional block diagram
Functional block diagram programming uses
instructions that are programmed as blocks
wired together to accomplish certain functions.

© McGraw Hill LLC Access the text alternative for slide images.
28
Ladder and functional block
Ladder diagram and functional block diagram
programming used to produce the same logical
output.

Ladder diagram

Equivalent
function block
diagram.
Access the text alternative for slide images.

© McGraw Hill LLC 29


Sequential function chart
Sequential
function chart
programming
language is
similar to a
flowchart of
your process.
The program is
split into steps with
multiple operations
happening in
parallel branches.
© McGraw Hill LLC Access the text alternative for slide images.
30
Structured text
Structured text is a high level language primarily
used to implement more complex procedures.

Ladder diagram

Equivalent
structured text
program.
Access the text alternative for slide images.

© McGraw Hill LLC 31


Section 5.4

Bit-Level Logic Instructions

© McGraw Hill LLC 32


Ladder diagram – symbolic set
The ladder diagram language is a symbolic set
of instructions used to create the controller
program.

Representations of contacts and coils are the basic


symbols of the logic ladder diagram instruction set.
Access the text alternative for slide images.

© McGraw Hill LLC 33


Symbolic instruction - command
Each symbolic instruction is a command
to perform a specific operation.

The symbols are arranged to obtain the


desired control logic that is to be entered
into the memory of the PLC.
Access the text alternative for slide images.

© McGraw Hill LLC 34


The Examine If Closed (XIC) instruction
looks and operates like a normally open
relay contact.

Examine if closed (XIC)


Examine-on

Associated with each XIC instruction is a memory


bit linked to the status of an input device or an
internal logical condition in a rung.

© McGraw Hill LLC 35


The memory bit is set to 1 or 0 depending
on the status of the input.
A 1 corresponds to a true status or on condition.

If the instruction memory bit is a 1 (true) this


instruction will allow rung continuity through itself,
like a closed relay contact.
Access the text alternative for slide images.

© McGraw Hill LLC 36


A 0 corresponds to a false status or off condition.

If the instruction memory bit is a 0 (false) this


instruction will not allow rung continuity through
itself and will assume a normally open state just
like an open relay contact.
Access the text alternative for slide images.

© McGraw Hill LLC 37


The Examine If Open (XIO)
instruction looks and operates like
a normally closed relay contact.

Examine if open (XIO)


Examine-off

This instruction asks the PLC’s processor to examine


if the contact is open.

It does this by examining the bit at the memory


location specified by the address for a 0 or 1.

© McGraw Hill LLC 38


Normally closed input
As with any other input the memory bit is set to 1 or 0
depending on the status of the input. A 1 corresponds to
a true status or on condition.

The instruction is interpreted as false when the bit is


1 and will not allow rung continuity through itself.
© McGraw Hill LLC Access the text alternative for slide images.
39
Normally open input
A 0 corresponds to a off condition.

The instruction is interpreted as true when the bit is


0 and will not allow rung continuity through itself.
Access the text alternative for slide images.

© McGraw Hill LLC 40


Truth table
Examine-on (XIC) instructions always
interpret a 1 status as true and a 0
status as false.

Examine-off (XIO) instructions


interpret a 1 status as false and a 0
status as true.
© McGraw Hill LLC Access the text alternative for slide images.
41
OTE instruction
The Output Energize (OTE) instruction looks
and operates like a relay coil.

This instruction signals the PLC to energize


(switch on) or de-energize (switch off ) the output.
The instruction is associated with a memory bit that
energizes the output when set to 1 and de-energizes
the output when reset to 0.
© McGraw Hill LLC 42
OTE logic
OTE instruction
is set to 1 to
energize the
output.

A true logic
path is
established by
the input
instructions in
the rung.
© McGraw Hill LLC Access the text alternative for slide images.
43
Action of the field device and PLC bit.

A signal
present
makes the
NO bit (1)
true; a signal
absent makes
the NO bit
(0) false. The
reverse is
true for an
NC bit.
Access the text alternative for slide images.

© McGraw Hill LLC 44


The main function of the ladder logic
The main function of the ladder logic diagram
program is to control outputs based on input
conditions.
Each contact or coil symbol is referenced with an
address that identifies what is being evaluated and
what is being controlled.

The same contact


instruction can be
used throughout the
program whenever
that condition needs
to be evaluated.
© McGraw Hill LLC Access the text alternative for slide images.
45
For an output to be activated or energized,
at least one left-to-right true logical path
must exist.

A complete closed
path is referred to
as having logical
continuity.

When logical continuity exists in at least one path, the


rung condition and Output Energize instruction are
said to be true.
Access the text alternative for slide images.

© McGraw Hill LLC 46


Section 5.5

Instruction Addressing

© McGraw Hill LLC 47


Each instruction is assigned an address.

Access the text alternative for slide images.

© McGraw Hill LLC 48


Allen-Bradley Logix 5000 controllers use tags
for assigning and referencing memory spaces.

Access the text alternative for slide images.

© McGraw Hill LLC 49


The assignment of an I/O address can be
included in the I/O connection diagram.

Inputs and outputs are typically represented by


squares and diamonds, respectively.
Access the text alternative for slide images.

© McGraw Hill LLC 50


Section 5.6

Branch Instructions

© McGraw Hill LLC 51


Branch instructions are used to create parallel
paths of input condition instructions.

The rung will be


true if either
instruction A or
B is true.

Access the text alternative for slide images.

© McGraw Hill LLC 52


Parallel branches can be used to allow more
than one combination of input conditions.

Either A and not B, or C provides logical


continuity and energizes output D.

Access the text alternative for slide images.

© McGraw Hill LLC 53


Output branching allows a true logic path to
control multiple outputs.

Either A or B provides a
true logical path to all
three output instructions:
C, D, and E.

Additional input
instructions can be
programmed in the
output branches.
Access the text alternative for slide images.

© McGraw Hill LLC 54


Input and output branches can be nested to
avoid redundant instructions and to speed up
processor scan time.

A nested branch starts or ends within another branch.


Access the text alternative for slide images.

© McGraw Hill LLC 55


Nested branch
In some PLC models, the
programming of a nested
branch cannot be done
directly.

It is possible, however,
to program a logically
equivalent branching
condition.

Access the text alternative for slide images.

© McGraw Hill LLC 56


The PLC will not
allow for
programming of
vertical contacts.

Boolean equation: Y = (AD) + (BCD) + (BE) + (ACE)

Reprogrammed to eliminate
vertical contact.

Access the text alternative for slide images.

© McGraw Hill LLC 57


Right to left logic
The processor examines the ladder logic rung
for logic continuity from left to right.
If programmed as shown,
contact combination
FDBC would be ignored.

Boolean equation: Y = (ABC) + (ADE) + (FE) + (FDBC)

Reprogrammed circuit.

© McGraw Hill LLC Access the text alternative for slide images.
58
Section 5.7

Internal Relay Instructions

© McGraw Hill LLC 59


Internal relay used for a program that
requires more series contacts than the
rung allows.

This PLC allows for only 7 series contacts when 12


are actually required for the programmed logic.
Access the text alternative for slide images.

© McGraw Hill LLC 60


Section 5.8

Programming
Examine If Closed and
Examine If Open
Instructions
© McGraw Hill LLC 61
Examine If Closed (XIC) instruction

Both the NO and the NC pushbuttons are represented


in the program by the Examine If Closed instruction.

The normal state of the field input device (NO or NC)


does not matter to the controller.

What matters is that contacts need to be closed to


energize the output.
Access the text alternative for slide images.

© McGraw Hill LLC 62


Examine If Open (XIO) instruction

The pushbutton is represented in the user program


by an Examine If Open instruction.

This is because the rung must be true when the


external pushbutton is open and false when the
pushbutton is closed.
Access the text alternative for slide images.

© McGraw Hill LLC 63


OTE Truth Table

The logic states (0 or 1) indicate whether an instruction


is true or false and is the basis of controller operation.

Access the text alternative for slide images.

© McGraw Hill LLC 64


OTE Timed Truth Table

The time aspect relates to the repeated scans of the


program, wherein the input table is updated with
the most current status bits.

Access the text alternative for slide images.

© McGraw Hill LLC 65


Section 5.9

Entering the Ladder Diagram

© McGraw Hill LLC 66


Allen-Bradley’s RSLogix
Rockwell’s RSLogix software packages are
windows programming packages used to
develop ladder logic programs.
Software, in various versions, can be used to program
the SLC 500, ControlLogix, CompactLogix and
MicroLogic family of processors.

A personal computer is most often used and is adapted


to the particular PLC model through the use of the
relevant programmable controller software.

© McGraw Hill LLC 67


RSLogix 500 main window.

Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 68


Instruction toolbar with bit instructions selected.

To place an instruction on a rung, click its


icon on the toolbar and simply drag the
instruction straight off the toolbar onto
the rung of the ladder.

Access the text alternative for slide images.

© McGraw Hill LLC 69


Select Processor Type
The programming
software needs to
know what
processor is being
used in conjunction
with the user
program.

The Select Processor Type screen contains a list of the


different processors that the RSLogix software can
program.
Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 70


I/O Configuration
The I/O Configuration screen lets you double
click or drag-and-drop a module from an all-
inclusive list to assign it to a slot in your
configuration.

Access the text alternative for slide images.

© McGraw Hill LLC Source: Image Courtesy of Rockwell Automation, Inc. 71


Data File B3
Data File screens contain data that are used in
conjunction with ladder program instructions
and include input and output files as well as
timer, counter, integer, and bit files.

The bit file B3 is used for internal relays.


Access the text alternative for slide images.

© McGraw Hill LLC Source: Courtesy of TheLearningPit. 72


Relay ladder logic
Relay ladder logic is a graphical programming
language designed to closely represent the
appearance of a wired relay system.
The logic is apparent
from the
highlighting which
identifies the logic
state of contacts in
real time and which
rungs have logic
continuity.

© McGraw Hill LLC Access the text alternative for slide images.
73
Section 5.10

Modes of Operation

© McGraw Hill LLC 74


Processor modes
A processor has basically two modes of
operation: the program mode and some
variation of the run mode.

A three-position key switch may be used to


select different processor modes of operation.
Access the text alternative for slide images.

© McGraw Hill LLC 75


List of processor modes
The program mode is used to enter a new program,
edit or update an existing program, upload files and
download files.

The run mode is used to execute the user program.

The test mode is used to operate or monitor the user


program without energizing any outputs.

The remote position allows the PLC to be remotely


changed between program and run mode by a
personal computer connected to the PLC processor.

© McGraw Hill LLC 76


Section 5.11

Connecting with Analog Devices

© McGraw Hill LLC 77


Digital vs Analog
Digital devices operate using, discrete ON or
OFF signals, that have only two possible values.

Analog signals can take any shape and represent


an infinite number of possible values.

© McGraw Hill LLC 78


Analog-to-Digital Converter
Analog signals must be coded into digital signals
before they can be processed by the PLC.
An analog-to-digital converter (ADC) converts the
analog input signals to digital signals.

A digital-to-analog converter (DAC) converts the


digital output signals back to analog signals.
© McGraw Hill LLC Access the text alternative for slide images.
79
Analog Control For A Tank-Filling Process

Access the text alternative for slide images.

© McGraw Hill LLC 80


Because learning changes everything. ®

www.mheducation.com

© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.

You might also like