Chapter 4 - PLC PROGRAMMING
Chapter 4 - PLC PROGRAMMING
PROGRAMMABLE LOGIC
CONTROLLER &
AUTOMATION
CHAPTER 4
PLC PROGRAMMING
LEARNING OUTCOME
Human Windows
Machine Based
Interface Program
PLC
Programming
Method Sequential
Mnemonic
Function
Code
Chart
Function
Instruction
Block
Set
Diagram
LADDER DIAGRAM
Consists of
Address Instruction Operand
Address
Instruction 00000 LD 00000
Operand 00001 FUN 02 -
Ladder diagram could not be 00002 LD 00001
read by Programming
Console. 00003 OUT 10000
Hence, ladder diagram need 00004 FUN 03 -
to be convert to mnemonic
code. 00005 FUN 01 -
Mnemonic code give same
information as ladder
diagram and can be typed
directly to the Programming
Console
INSTRUCTION SET
Command Comment
STR X1 Store input X1
AND X2 Input X2 in series
with X1
OUT Y Output Y
SEQUENTIAL FUNCTION CHART (SFC)
Transition 1 Action
Step 2 MOTOR
(END)
Transition 2
Step 3
FUNCTION BLOCK DIAGRAM (FBD)
SWITCH 1 OR
SWITCH 2 AND CYLINDER
OUT
LAMP ON
HUMAN MACHINE INTERFACE (HMI)
Instruction lines
Input Output
There are 2 types of conditions:
Normally Open (NO) - ladder logic symbol that allow logic flow if
input is logic is "1" (ON)
Normally Closed (NC) - ladder logic symbol that will allow logic flow
if input is logic "0" (OFF)
Conditions Operand
bits
NO ON ON
OFF OFF
NC ON OFF
OFF ON
• Numbers at every conditions determine the operand bits for its
instruction.
• Each instruction inside a ladder diagram, either ON or OFF, depends
on operand bit status prior set by the programmer.
Operand bits
Instruction
executed when LD
00000 is ON
Instruction
executed when LD
00000 is OFF
EXECUTION CONDITION
AND OR
AND
NOT
LOAD (LD)
Ladder diagram
Implementation State (Execution Conditions) for instruction in
right will ON when IR 00000 is OFF
AND
00002 FUN(01) -
NO OPERATION
Block 1
Block 2
AND LD
Block 1 Block 2
COMBINATION OR LD & AND LD
EXERCISE 1
Q1:
A1:
EXERCISE 2
Q2:
A2:
2. Write mnemonic code for figure ( i) and figure (ii) below
EXERCISE 4
ON ON ON
OFF OFF
OFF ON OFF
OFF OFF
Table: Instruction set
JUMP [JMP (04)] AND JUMP END [JME
(05)]
A specific section of a program can be skipped according to the
execution.
Pair:
JUMP (04): jump starting point
and JUMP END (05): jump direction
For PLC 's set OMRON type - SYSMAC CQM1H:
JUMP (04) : FUN 04
JUMP END (05) : FUN 05
• When JMP (04) is ON = no jump occurred and the programs will perform
accordingly.
• When JMP (04) is OFF = the instruction will jump to JME (05) (which has the
same number). The instructions after JME (05) will be executed.
• JUMP and JUMP END can use numbers range from 00 to 99.
skipped
SET and Reset instructions only change the status of their operand
bits for ON execution condition.
Neither instruction will ef fect the status of its operand bit when an
execution condition is OFF.
SET :
turn ON the operand bit when execution condition goes ON
Will not turn OFF the operand bit when the execution condition goes
OFF.
RESET:
turn OFF the operand bit when the execution condition turn OFF
LADDER DIAGRAM FOR INSTRUCTION SET
& RESET
DIF U
DIF D
Figure : Time diagram for DIFU and DIFD
DIFFERENTIATE UP [ DIFU (13) ]
TIM N Operand/Definer
#SV Set value
Operand/Definer: between 000 to 015
The number can not be used twice in a single program
When a timer number has been defined (e.g. TIM 000), it can
be used any amount of time as operator operand in other
instruction other than TIMER.
Set value (SV): between 0000 to 9999
# 0001 = 0.1 sec
# 0050 = 50 x 0.1 sec = 5 sec
# 0100 = 100 x 0.1 sec = 10 sec
EXAMPLE 1
INPUT OFF
(00000) 5 sec
Figure : Timing Diagram
10000
10001
EXAMPLE 3
INPUT OFF
(00000) 3 sec
Figure : Timing
5 sec
Diagram
OUTPUT
EXERCISE
L
K
**Relay
contact
Equivalent Relay Ladder Logic Circuit
LS L
END
24V
24V
S1 24V S2
24V
K1 K2 K3
L
24V K1 0V
S1
K2
S2
S1 S2 L
K1 K2 K3
END