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

Basics of PLC Programming

The memory of a PLC is organized into program memory and data memory. Program memory contains the user-written logic instructions, often in ladder logic format. Data memory stores input/output status, timers, counters, and other variable data used by the program. Memory is divided into files like input, output, data, and program files. The PLC performs a continuous scanning process where it reads inputs, executes the program logic, and sets outputs each scan cycle. Common PLC programming languages include ladder logic, function block, and sequential function charts.

Uploaded by

Dhanush S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views

Basics of PLC Programming

The memory of a PLC is organized into program memory and data memory. Program memory contains the user-written logic instructions, often in ladder logic format. Data memory stores input/output status, timers, counters, and other variable data used by the program. Memory is divided into files like input, output, data, and program files. The PLC performs a continuous scanning process where it reads inputs, executes the program logic, and sets outputs each scan cycle. Common PLC programming languages include ladder logic, function block, and sequential function charts.

Uploaded by

Dhanush S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 58

Programmable

Logic Controllers
Chapter 5

Basics of PLC
Programming
Processor Memory Organization
The memory of a PLC is organized
by data types.

The memory space can be divided


into two broad categories:
program and data memory.

Advanced ladder logic functions allow controllers to


perform calculations, make decisions and do other
complex tasks. Timers and counters are examples of
ladder logic functions. They are more complex than
basic inputs contacts and output coils and rely
heavily upon data stored in the memory of the PLC.
Memory Map
A memory map can be used to show how memory is
organized in a PLC.

 Input/output locations
Data table  Internal relay and
timer/counter locations

The user program causes


User program the controller to operate
in a particular manner
Used to carry out
Housekeeping memory functions needed to make
the processor operate
(no access by user)
Memory Addresses
Memory is organized
into blocks of elements
in an array called a file.

The individual sections,


their order, and sections'
lengths will vary and may
be fixed or variable,
depending on the
manufacturer and model.
Program Files

The user program will


account for most of the
memory of a PLC system.

Program files contain


the logic that controls
the machine operation.
This logic consists of
instructions that are
Program file organization programmed in a
for SLC-500 controller. ladder logic format.
Data file organization Data Files
for SLC-500 controller.

The data file portion of memory


stores input and output status,
processor status, the status of
various bits and numerical data.
Data Files
Data files are organized by the type of data they contain
PLC-5 Memory
Organization

There are about 1,000


program files.
The
Withdata
thefiles are where
processor
the
setvariable data are
up for standard
stored
ladderthat thethe
logic, PLCmain
programs
program operate on.
will always
be in program file 2,
and the program files
3 through 999 will be
subroutines.
PLC-5 Data Files
Timer, counter, and
control elements are
All element and bit
three words in length.
addresses in the
All data
output
Each and
datatypes isexcept
input
file data
made
Floating
the
files
up point
floating-point
arenumerous
off numbered
elements
files,
octally.
elementsare are
treated
Element
of twoas
and
different
bitwords
whole in length.
numbers.
addresses
lengths. in all
other data files are
All other decimally.
numbered elements
are a single word
in length, with each
word consisting of
16-bits.
Input Table File Operation

Input module

Switch Open Processor continually


reads current input
Switch Closed
status and updates
input image table file
Binary
Binary 01 stored
stored
1
0
Output Table File Operation

Output module
Output
Processor continually OFF
activates or deactivates
output status according
to output image table
file status Output
ON
1
0
Status 1
0
Program Scan
During each operating cycle, the processor reads all
inputs, takes these values, and energizes or de-energizes
the outputs according to the user program. This
process is known as a scan.
I/O scan – records status data of input
devices. Energizes output devices that
have their associated status bits set to
ON (1)

Program scan – instructions are


executed sequentially
Because the inputs can change at any time, the PLC
must carry on this process continuously.
Scan Process
The scan time indicates how fast the controller can react
to changes in inputs. Scan times vary with computer
model and program content, and length. If a controller
has to react to an input signal that changes states twice
during the scan time, it is is possible that the PLC will
never be able to detect this change.

Scan time may be a concern


in high speed operations
Scan Process

Read inputs

The scan is a
a continuous
and sequential
process
Adjusts Run
outputs program
Data Flow Overview

Input Output
Input data Input Output data Output
image
modules table file image
modules
table file

Examine data Return results


Program

Check/compare/examine Take some


specific conditions action
Scan Process
Input Output
Module Module
Input Output
Input Output
file device
device file
I:3/6 O:4/7
I:3/6 O:4/7

Program
When the input is The processor turns
closed, the input light output O:4/7
module senses a I:3/6 O:4/7
ON during the next
voltage and an ON During the program I/O scan
condition (1) is scan the processor
entered into the sets instructions I:3/6
input table bit I:3/6 and O:4/7 to ON (1)
Scan Patterns
Horizontal Scanning
Order 
Used by Allen Bradley
The processor examines
input and output
instructions from the
first command, top left
in the program,
horizontally, rung by
rung.
End of ladder

In addition to the program itself, the scan time is also


dependent on the clock frequency of the processor!
Scan Patterns

Vertical Scanning
Order

The processor examines


input and output
instructions from the
first command, vertically,
column by column and
page by page. Pages are
executed in sequence.
End of ladder

Misunderstanding the way the PLC scans can cause


programming bugs!
PLC Programming Languages
The term PLC programming language refers to the
method by which the user communicates information
to the PLC.

The three most common


language structures are:
Ladder diagram language
ladder diagram language,
Boolean language, and
functional chart.
Functional
chart
Boolean language
Comparing Programming Language
PB1 CR1 CR2 SOL
Relay Schematic
LS1

PB1 CR1 CR2 SOL


Equivalent ladder
diagram language
LS1

Equivalent Boolean language


Sequential Function Chart (SFC) Programming

A functional chart program is a pictorial representation


or a special type of flowchart of a sequential control
process.

It allows the description of the process to become the


actual program.

Functional chart programming uses function blocks


made up of steps and transition units.
Sequential Function Chart (SFC) Programming

Check for stop


Wait for Check for Lock the Press the Unlock Move
start part clamp part clamp conveyor

One Continuous
cycle

Check mode
International Standard for Programmable
Controllers (IEC 61131-3) Defined Standard
Programming Languages

Sequential
Ladder Diagram
Functional Function
Block(LD) Charts
– graphically
Diagram (SFC) – graphical
(FBD) flowchart
depicts a process
of
Structured List
Instruction Text(IL)
(ST)– –assembler-type,
a language developed for IEC
text-based
steps
with rungs
(one or
depiction ofofprocess
more
logic,actions)
similar and
to the
flow using transitions
relay and
simple ladder
(defined
logic
complex
to provide
language high-level
for building syntax
small using "If" and
applications or "Then"
conditions)
schemes
buildingthatbefore
were
blocks, passing
replaced
ranging toby
from the
PLCs.
next step.
analog I/O to closed
statements.complex systems.
optimizing
loop control, algorithms, and diagnostics.
Relay-Type Instructions
The ladder diagram language is basically a symbolic
set of instructions used to create the controller
program.

These ladder instructions symbols are arranged to


obtain the desired control logic.
Examine If Closed (XIC) Instruction

Symbol Analogous to the normally open


relay contact. For this instruction
we ask the processor to EXAMINE
IF (the contact is) CLOSED (XIC)

Typically represents any input. Can be a switch


or pushbutton, a contact from a connected output,
or a contact from an internal output.
Has a bit-level address which is examined for an
ON condition.

The status bit will be either 1 (ON) or 0 (OFF).


Examine If Closed (XIC) Instruction

I:012
I:012

04

IfIfthe
thestatus
statusbit
bitisis0 1(OFF),
(ON), then the instruction
is TRUE.
is FALSE.
Examine If Open (XIO) Instruction

Symbol Analogous to the normally closed


relay contact. For this instruction
we ask the processor to EXAMINE
IF (the contact is) OPEN (XIO).

Typically represents any input. Can be a switch


or pushbutton, a contact from a connected output,
or a contact from an internal output.
Has a bit-level address which is examined for an
OFF condition.

The status bit will be either 1 (ON) or 0 (OFF).


Examine If Open (XIO) Instruction

I:012
I:012

04

IfIfthe
thestatus
statusbit
bitisis1 0(ON), then
(OFF), thethe
then instruction
instruction
isisFALSE.
TRUE.
Output Energize (OTE) Instruction
Analogous to the relay coil. The
Symbol processor makes this instruction
true (analogous to energizing a coil)
when there is path of true XIC and
XIO instructions in the rung.

Typically represents any output that is controlled by


some combination of input logic. Can be a connected
device or an internal output (internal relay).

If any left-to-right path of input conditions is TRUE,


the output is energized (turned ON).
Output Energize (OTE) Instruction

O:013

I:012

I:012 I:012 O:013

11 15 01

OUTPUT ENERGIZE instruction - TRUE


FALSE
Status Bit Examples
A Input module
Bit status

Button
Buttonnot actuated
actuated

A Output
ON
OFF

False
True
A Output
ON
OFF

True
False
Ladder Rung
Output
A B C instruction

Input conditions
D

Each
AFor contact
ladder or coil
an output
rung symbol
consists
to be of aisset
activated referenced
or
of input with at
energized, anleast
conditions,
address number
represented bythat
one left-to-right identifies
contact
path whatmost
ofinstructions,
contacts is and
being
beanclosed.
output
evaluated andatwhat
instruction
A complete is referred
the end
path is being
of thecontrolled.
rung, Thelogic
sameby the
represented
to as having
contact
coil instruction
symbol.
continuity. Whencan logicbeexists
used throughout the program
the rung condition is
whenever that
said to be condition needs to be evaluated.
TRUE.
Rung Continuity

Bit in memory Bit in memory


1
0 01

LS_1 SOL_5

The
The Examine
Examine IfIf Closed
Closed instruction
instruction isis TRUE
FALSE
making
making the
the rung
rung TRUE
False
Allen-Bradley SLC-500 Controller Addressing
Address
output
terminal
Output image table O0:4/6
file 0

O:0:4/6
Address Bit address
input
terminal Input image table
I1:3/12 Energized
file 1
output

I:3/12
Bit address
Closed input
I1:3 O:0:4
User-programmed rung
12 6
Structure of A 16-Bit Word
Bit OFF ON
Word 0
(16 bits)
1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

I/O Connection Diagram


L1 L2 L1 L2
PB1 SOL 1
I:4/5 O:2/3
PL 1
LS1
I:4/6 O:3/6 R
Parallel Input Branch Instructions
A C Branch instructions are used
to create parallel paths of
input condition instructions.
If at least one of these parallel
B branches forms a true logic
path, the logic is enabled.
Parallel Output Branching
A C

D
B
E

On most PLC models, branches can be established at


both the input and output portion of the rung.

With output branching, you can program parallel


outputs on a rung to allow a true logic path to
control multiple outputs.
Nested Input and Output Branches

Input and output branches can be nested to avoid


redundant instructions and to speed up the processor
scan time.
A nested branch starts or ends within another branch.
Nested Contact Program
A B C Y
On some PLC models,
the programming of a
D Nested nested branch circuit
contact cannot be done directly.
E

A B C Y
Reprogrammed to
obtain the required
Contact logic.
D C instruction
C repeated
E
PLC Matrix Limitation Diagram
Max series
contacts

Max parallel No. outputs


lines per rung and
location of the
output in the rung

There may be limitations to the number of series


contacts instructions, number of parallel lines, and
the number of outputs and their location on the rung.
Programming of Vertical Contacts
A D Y
Original program
C
Y = (AD) + (BCD) + (BE) + (ACE)
B E

A D Y

B C D
Reprogrammed to obtain the
B E required logic
A C E
Programming for Different Scan Patterns

A B C Y
Original program
D E

F
Y = (ABC) + (ADE) + (FE) + (FDBC)

A B C Y

A D E
Reprogrammed to obtain the
F E required logic

F D B C
Internal Control Relay
The internal output operates just as any other output
that is controlled by programmed logic; however, the
output is used strictly for internal purposes.

The internal output does not directly control an


output device.

The advantage of using internal outputs is that there


are many situations where an output instruction is
required in a program, but no physical connection to
a field device is needed. Their use in this type of
instance can minimize output card requirements.
Extending the Number of Series Contacts Using
an Internal Control Relay

Internal
relay coil
Rung 1

Rung 2

Internal Discrete output (requires


relay one physical connection
contact on the output module)
Programming The XIC Instruction
PB1 PB2
Hardwired Circuit
PL

PB1 PB2 PL User program


providing the
same results
Note that both pushbuttons are represented by the
XIC symbol. This is because the normal state of an input
(NO or NC) does not matter! What does matter is that if
contacts need to close to energize the output, then the XIC
instruction is used. Since both PB1 and PB2 must close to
energize the PL, the XIC instruction is used for both.
Programming The XIO Instruction
PB1
PB1
CR PL
CR1
PL
User program providing
the same results
Hardwired Circuit
When the pushbutton is open in the hardwired circuit,
relay coil CR is de-energized and contacts CR1 close to
switch the PL on. When the pushbutton is closed, relay
coil CR is energized and contacts CR1 open to switch the
PL off. The pushbutton is represented in the user program
by an XIO instruction. This is because the rung must be
true when the external pushbutton is open, and false
when the pushbutton is closed.
Operation of The XIC and XIO Instructions

Summary of status conditions

The status of the instruction is:


XIC XIO OTE
If the data Examine If Closed Examine If Open Output Energize
table bit is:

Logic 0 False True False


Logic 1 True False True
Operation of The XIC and XIO Instructions
State of the output as determined by the changing
state of the inputs in the rung

Inputs Output Bit status


Time
XIC XIO OTE XIC XIO OTE
t1 (initial) False True False 0 0 0
t2 True True Goes true 1 0 1
t3 True False Goes false 1 1 0
t4 False False Remains false 0 1 0

Input instructions Output instruction


XIC XIO OTE
Entering the Ladder Diagram
A personal computer is most often used to enter the
ladder diagram.

The computer is adapted


to the particular PLC
model using the relevant
programmable controller
software.
RSLogix Main Screen
Different screens, toolbars and windows dialog boxes are
used to navigate through the Windows environment
Bit Instructions Tool Bar

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.
Select Processor Type Screen
The programming software needs to know what
processor is being used in conjunction with the program.

1747-L40E
You simply
scroll down
the list until
you find the
processor you
are using and
select it.
I/O Configuration Screen

The I/O screen


lets you click or
drag-and-drop a
module from an
all inclusive list to
assign it to a slot
in your
configuration.
Data File Screen
Data file screens
contain data that
is used in
conjunction with
ladder program
instructions. These
include:
Input
Output
Timer
Counter
Integer
Bit
Monitoring a Ladder Logic Program
Operation of the logic is apparent from the highlighting
of rungs of the various instructions on screen, which
identifies the logic state in real time and has logic
continuity.

Highlighted rungs indicate the instruction is true


Modes of Operation
A processor has basically two modes of operation:
the program mode or some variation of the run mode.
Program Mode – may be used to
 enter a new program
 edit or update an existing program
 upload files
 download files
 document programs
 change software configurations
When the PLC is switched into the
program mode, all outputs from the PLC
are forced off regardless of their rung
logic status, and the ladder I/O scan
sequence is halted.
Variations of the Run Mode

Run Mode – is used to execute the


user program. Input devices are monitored
and output devices are energized
accordingly.

Test Mode – is used to operate, or monitor,


the user program without energizing any
outputs.

Remote Mode – allows the PLC to be


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

You might also like