Basics of PLC Programming PDF
Basics of PLC Programming PDF
1 of 62
PLC Architecture
2 of 62
PLC System
3 of 62
4 of 62
Memory Map
A memory map can be used to show how memory is
organized in a PLC.
Input/output locations
Internal relay and
timer/counter locations
Data table
User program
Housekeeping memory
5 of 62
Program Files
The user program will
account for most of the
memory of a PLC system.
6 of 62
Data Files
Data file organization
for SLC-500 controller.
7 of 62
Data Files
Data files are organized by the type of data they contain
8 of 62
Binary 0 stored
0
9 of 62
Switch Closed
Binary 1 stored
1
10 of 62
Processor continually
activates or deactivates
output status according
to output image table
file status
0
Status 0
11 of 62
Output
ON
1
Status 1
12 of 62
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)
Because the inputs can change at any time, the PLC must
carry on this process continuously.
Lecture PLC Programming Basics
13 of 62
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.
14 of 62
Scan Process
Read inputs
The scan is a
a continuous
and sequential
process
Adjusts
outputs
Run
program
15 of 62
Input
modules
Input
data
Input
image
table file
Output
image
table file
Examine data
Output
data
Output
modules
Return results
Program
Check/compare/examine
specific conditions
Lecture PLC Programming Basics
Take some
action
16 of 62
Scan Process
Output
Module
Input
Module
Input
device
Input
file
Output
file
I:3/6
O:4/7
Output
device
O:4/7
I:3/6
Program
When the input is
closed, the input
module senses a
voltage and an ON
condition (1) is
entered into the
input table bit I:3/6
I:3/6
O:4/7
17 of 62
Scan Patterns
Horizontal Scanning
Order
The processor examines
input and output
instructions from the
first command, top left
in the program,
horizontally, rung by
rung.
End of ladder
18 of 62
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!
Lecture PLC Programming Basics
19 of 62
20 of 62
CR1
CR2
SOL
Relay Schematic
LS1
PB1 CR1
CR2
SOL
Equivalent ladder
diagram language
LS1
21 of 62
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.
22 of 62
23 of 62
I:012
I:012
04
24 of 62
I:012
I:012
04
If the status bit is 0 (OFF), then the instruction
is FALSE.
Lecture PLC Programming Basics
25 of 62
I:012
I:012
04
If the status bit is 1 (ON), then the instruction is TRUE.
26 of 62
27 of 62
I:012
I:012
04
If the status bit is 0 (OFF), then the instruction is TRUE.
28 of 62
I:012
I:012
04
If the status bit is 1 (ON), then the instruction is FALSE.
29 of 62
30 of 62
I:012
I:012
I:012
11
15
O:013
01
31 of 62
I:012
I:012
I:012
11
15
O:013
01
32 of 62
Bit status
OFF
False
A
Output
ON
True
Lecture PLC Programming Basics
33 of 62
Bit status
Button actuated
Output
ON
True
Output
OFF
False
Lecture PLC Programming Basics
34 of 62
Ladder Rung
A
Output
instruction
Input conditions
D
35 of 62
Ladder Rung
A
Output
instruction
Input conditions
D
36 of 62
Rung Continuity
Bit in memory
Bit in memory
1
LS_1
SOL_5
37 of 62
Rung Continuity
Bit in memory
Bit in memory
0
LS_1
SOL_5
38 of 62
Address
output
terminal
O0:4/6
O:0:4/6
Bit address
Address
input
terminal
I1:3/12
Energized
output
I:3/12
Bit address
Closed input
I1:3
O:0:4
User-programmed rung
12
Lecture PLC Programming Basics
6
39 of 62
OFF ON
Word
(16 bits)
0 1
15 14 13 12 11 10 9
L2
L1
L2
PB1
SOL 1
O:2/3
I:4/5
PL 1
LS1
O:3/6
I:4/6
40 of 62
41 of 62
C
D
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.
Lecture PLC Programming Basics
42 of 62
43 of 62
Nested
contact
E
A
Contact
instruction
C repeated
Reprogrammed to
obtain the required
logic.
E
Lecture PLC Programming Basics
44 of 62
No. outputs
per rung and
location of the
output in the rung
Max parallel
lines
45 of 62
Original program
C
E
D
B
A
B
D
E
46 of 62
Original program
47 of 62
48 of 62
Rung 2
Internal
relay
contact
49 of 62
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.
50 of 62
PB1
CR
PL
CR1
PL
Hardwired Circuit
When the pushbutton is open in the hardwired circuit, relay coil CR is deenergized 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.
51 of 62
XIO
Examine If Open
Logic 0
False
True
False
Logic 1
True
False
True
If the data
table bit is:
OTE
Output Energize
52 of 62
Time
XIC
XIO
OTE
Goes true
False
Goes false
False
Remains false
XIC
XIO
t1 (initial)
False
True
t2
True
True
t3
True
False
t4
Input instructions
XIC
XIO
Bit status
Output
OTE
False
Output instruction
OTE
53 of 62
54 of 62
55 of 62
56 of 62
You simply
scroll down
the list until
you find the
processor you
are using and
select it.
57 of 62
58 of 62
59 of 62
60 of 62
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.
61 of 62
62 of 62