Chapter 4 - PLC Programming
Chapter 4 - PLC Programming
PLC
PROGRAMMING
CLO 1: Explain clearly blocks, parts, components and instructions
found in the
automation systems. (C2)
CLO2: Construct simple automation sequential control of hardwired or
PLC system
based on IEC 61131 and NEMA standards. (C4)
CLO3: handle the troubleshooting and maintenance of hardwired or
PLC automation
Programming language
There are 6 programming languages
available:
1.
2.
3.
4.
5.
6.
Ladder Diagram
Mnemonic Code
Instruction Set
Sequential Function Chart (SFC)
Function Block Diagram (FBD)
Windows Based program
1. Ladder Diagram
A way of representing electrical sequences of
operations.
To represent hardwired logic circuits used to
control machines or equipment.
It is a language which composes program using
relay symbols as a base in an image similar to a
hard-wired relay sequence.
In order to achieve an efficient data-processing
program, ladder diagram which are combinations
of relay symbols and function blocks are used.
It indicative control circuit, display operation
function and combination of sequence operation
for each branch in horizontal line separately (refer
Figure 1).
Ladder Diagram
Electrical Diagram
Ladder Diagram
2. Mnemonic Code
Consists of
Address
Instruction
Operand
Address
00000
00001
00002
00003
00004
00005
Instruction
LD
FUN 02
LD
OUT
FUN 03
FUN 01
Operand
00000
00001
10000
-
3. Instruction Set
Store input X1
AND X2
Input X2 in
series with X1
Output Y
OUT Y
Step
1
Transition
Step 1
2
Transition
Step 2
3
MOTOR
(START)
Action
MOTOR
(END)
SWITCH
SWITCH
1
2
LAMP
ON
OR
AN
D
CYLIND
ER OUT
LADDER DIAGRAM
Instruction
lines
Bus
bar
Conditions
Bus
bar
Ladder Diagram
Input
Output
Operand
bits
NO
ON
OFF
ON
OFF
NC
ON
OFF
OFF
ON
Operand
bits
Instruction
executed
when LD
00000 is ON
Instruction
executed
when LD
00000 is OFF
Execution Conditions
Operand Bits
Operand bits for every instruction can
consists of any bits from memory areas
IR, SR, HR, TC or TR.
Its mean conditions in ladder diagram
can be set by I/O bits, flags, work bits,
timers/counters and others.
DATA AREA
Input
IR area
Output
Work
SR area
BITS
IR00000 - IR01515
FUNCTION
As input bits
IR10000 IR11515
As output bits
IR21600 IR21915
SR24400 SR25507
TR area
TR 0 TR 7
HR area
HR 0000 HR 9915
Timer/Counter area
TC 000 TC 511
INSTRUCTIONS IN PLC
1. LD- INSTRUCTION LOAD
It was to start something programmed
line.
It are used at first contactor in the
normally open (NO) .
Ladder diagram
Implementation State (Execution
Conditions) for instruction in right will ON
when IR 00000 is OFF
5. OR - INSTRUCTION OR
Connects an NO condition in parallel
with the previous condition.
8. END END(01)
LD NOT
00000
00001
OUT
10000
00002
FUN(01)
9. NO OPERATION NOP ( 00 )
This instruction has no ladder diagram
symbol and it will not be doing any
operation.
When memory CLEAR, this instruction
will be displayed on the PLC console
screen.
OR LD and AND LD
EXAMPLE
Q: WRITE THE MNEMONIC CODE
Q1:
A1:
EXAMPLE
Q: DRAW THE MNEMONIC CODE
Q2:
A2:
QUESTIONS
1. Explain instruction function
following
i. LOAD
ii. OR
iii. AND
QUESTIONS
2. Write mnemonic code for figure (i)
and figure (ii) below
ANSWER
1. i) LOAD- Instruction to start
something program line.
ii) OR - Instruction are used at
second contactor in a situation
parallel to previous contactor.
iii) AND - Instruction are used at
second contactor in a situation
parallel to previous contactor.
INTERLOCK [ IL ( 02 ) ] AND
INTERLOCK CLEAR [ ILC ( 03 ) ]
Allow specific section to be control either to
execute or not.
Pair: Interlock and Interlock Clear
For PLC 's set OMRON type - SYSMAC CQM1H:
INTERLOCK: FUN 02
INTERLOCK CLEAR: FUN 03
Address
00000
00001
00002
00003
00004
00005
Instruction
LD
FUN 02
LD
OUT
FUN 03
FUN 01
Operand
00000
00001
10000
-
Instruction LD 00000
IL(02)
Instruction LD 00001
(input)
ON
ON
ON
OFF
OFF
ON
OFF
OFF
OFF
OFF
skippe
d
Address
00000
00001
00002
00003
00004
00005
Instruction
LD
FUN (04)
LD
OUT
FUN (05)
FUN (01)
Operand
00000
01
00001
10000
01
-
Instruction LD 00000
JMP(04)
Instruction LD 00001
(input)
Instruction OUT
10000 (output)
ON
ON
OFF
skipped
ON
OFF
skipped
OFF
QUESTION 1
Instruction
Operand
LD
FUN (04)
LD
OUT
FUN (05)
LD
OUT
FUN (01)
00002
01
00003
10004
01
00004
10005
-
Table 1
QUESTION 2
By referring to Table 2, complete Table 3.
Table 2
Table 3
Instruction
LD 00000
IL (02)
ON
OFF
Address
00000
00001
00002
00003
00004
00005
00006
00007
Instruction
LD 00002
(input)
ON
OFF
ON
OFF
Instruction
LD
FUN (02)
LD
OUT
LD
OUT
FUN (03)
FUN (01)
Instruction
LD 00003
(input)
ON
OFF
ON
OFF
Operand
00000
00002
10004
00003
10005
-
Instruction Instruction
OUT 10004 OUT 10005
(output)
(output)
Address
00000
00001
00002
00003
00004
00005
Instruction
LD
LD
FUN (11)
LD
OUT
FUN (01)
Instruction
LD 00004
Reset
OFF
ON
Operand
00002
00004
HR 0000
HR 0000
10004
Instruction
LD 00002
Set
ON
OFF
ON
OFF
Instruction
OUT 10004
OUTPUT
ON
ON
OFF
OFF
RESET:
turn OFF the operand bit when the execution condition turn OFF
Address
00000
00001
00002
00003
Instruction
LD
SET
LD
RESET
Operand
00000
10000
00001
10000
INPUT
DIF U
DIF D
Address
00000
00001
00002
00003
Instruction
LD
FUN (13)
LD
OUT
Operand
00000
01000
01000
10000
DIFFERENTIATE DOWN
Address
00000
00001
00002
00003
Instruction
LD
FUN (14)
LD
OUT
Operand
00000
01000
01000
10000
[ DIFD (14) ]
MOVE - MOV ( 21 )
A function to move or transfer or to
copy data from source channel (S) to
destination channel (D).
For PLC 's set OMRON type - SYSMAC
CQM1H:
MOV (21) = FUN 21
MOV
(21)
S
D
S : Source Channel
D : Destination
Channel
LD
00000
00001
FUN (21)
00002
000
00003
100
00004
FUN 01
S
D
S : Start Channel
SFT
(10)
E : End Channel
S
DI : Input Data
S
E
ADD
(30)
Au
Ad
R
Address
00000
00001
00002
00003
00004
00005
00006
Instruction Operand
LD
00000
OR
21600
OUT
21600
LD
21600
FUN ( 41 )
FUN ( 30 )
# 0001
# 0001
100
FUN ( 01 )
Au
+ Ad + Cy = Cy
Addition process
Mi
Su
R
Address Instruction
00000
LD
00001
OUT
00002
LD
00003 FUN ( 41 )
00004
Operand
00000
21600
21600
FUN ( 30 )
00005
# 0010
# 0005
100
00006
FUN ( 01 )
IR 100 will store
the result
Mi
Su
Cy
Subtraction
= Cy
Flag
Address C1 C2 C1 = C2 C1 C2
GR
OFF
OFF
ON
(Greater) 25505
EQ
25506
OFF
ON
OFF
(Equal)
LE
25507
ON
OFF
OFF
(Less)
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
LD
AND
OUT
LD
AND
OUT
LD
AND
OUT
FUN (01)
Operand
00000
TR 0
# 0010
# 0005
TR 0
25505
10000
TR 0
25506
10001
TR 0
25507
10002
TIMER - TIM
A device that switches its output ON or OFF at a preset time intervals.
When the input signal is received, the timer waits the specified delay
time set in the set value, before switching ON or OFF the output signal.
The timer is RESET (output or relay is set back to its initial value) by
turning OFF the input signal
Operand/Definer
Symbol
TIM
N
#SV
Set
value
http://www.plcs.net/chapters/timeran.htm
Example 1
Address Instruction Operand
00000
LD
00000
00001
TIM
000
# 0050
00002
LD
TIM 000
00003
OUT
10000
00004
FUN 01
ON
INPUT
(00000)
OFF
5 sec
OUTPUT
Figure: Timing
Example 2
Address
00000
00001
00002
00003
00004
00005
00006
Instruction
LD
TIM
LD
OUT
LD NOT
OUT
FUN 01
Operand
00000
000
# 0050
TIM 000
10000
TIM 000
10001
ON
INPUT
(00000)
10000
10001
OFF
5 sec
Example 3
Address
00000
00001
Instruction
LD
TIM
Operand
00000
000
# 0050
00002
00003
00004
00005
00006
LD
AND NOT
OUT
LD
TIM
TIM 000
TIM 001
10000
10000
001
#0030
00008
FUN 01
ON
INPUT
(00000)
OUTPUT
OFF
5 sec
3
sec
Figure :
Timing
Diagram
Question
Based on the Ladder diagram below,
How long is the delay time that had been set in
TIM 001?
Write the mnemonic code.
Draw the timing diagram.
COUNTER - CNT
A component used to count electrical pulses and store the results of the
counting procedure.
Each time the count pulse (CP) goes from ON to OFF, it store on pulse and
count until it reaches the set value (SV).
Once the SV is reach, the output will turn ON, and remain ON even if the
CP is turn OFF.
To turn OFF the output, the Reset signal is given (zeroing the counter).
Can be counter up or down.
Operand/Definer
Input switch
CNT
Symbol
(CP)
Reset (R)
#SV
Set
value
Example
Address Instruction Operand
00000
LD
00000
00001
LD
00001
00002
CNT
000
#0010
00003
LD
CNT 001
00004
OUT
10000
00005
FUN 01
-
http://www.plcs.net/chapters/countan.htm
LD
OUT
LD
TIM
00009
LD
OUT
FUN 01
00010
00011
Operand
00000
00001
000
#0005
CNT 000
10000
10000
001
#0050
TIM 001
10001
-
END