Chapter 4 PLC Programming
Chapter 4 PLC Programming
PLC
PROGRAMMING
Specific Objectives:
After completed this chapter, student will know the major
component
Notes:
Normally open condition is ON if the bit operation is ON and
will be OFF if the bit operation is OFF .
Normally closed condition is ON if the bit operation is OFF and
will be OFF if bit operation is ON.
RELAY WIRING
LADDER DIAGRAM
ADDRESS
INSTRUCTION
DATA
00000
LD
00000
00001
OR
00001
00002
AND
00003
00003
AND LD
00004
OUT
01000
00005
TIM
000
#0050
00006
CNT
002
#0010
00007
FUN 01
Example 1
We have Motor that will be controlled manually by 2 push
buttons (Start Push Button, and Stop Push Button).
When the Start Push Button is pushed then the Motor will
be turned ON.
When the Stop Push Button is Pushed then we want to stop
the Motor. (Security logic has been taken off this logic, for
the purpose of demonstration.)
Example 2:
00000
00003
01000
instruction
00001
ADDRESS
INSTRUCTION
DATA
00000
LD
00000
00001
OR
00001
00002
AND
00003
00003
OUT
01000
00004
FUN 01
Example 3:
00000
00002
01000
instruction
00001
00003
ADDRESS
INSTRUCTION
OPERAND / DATA
00000
LD
00000
00001
OR
00001
00002
LD
00002
00003
OR NOT
00003
00004
AND LD
------
00005
OUT
01000
00007
FUN 01
Basic Terms
1. Execution Conditions
Logical combination of the ON and OFF states gathered to
establish an instruction to be implemented. This condition is
called Execution Condition. Refer to figure below.
DATA AREAS
2. Operand Bits
IR area
Output
area
Input
area
Work
area
BITS
IR00000 IR00915
IR01000
IR01915
FUNCTIONS
Used as input bit
Used as output bit
IR02000
IR04915
IR20000
IR23115
Freely used in a
program. No specific
function.
SR area
SR22800
SR25515
TR area
TR 0 TR 7
HR area
HR 0000
HR 1915
TC 000 TC
255
Area for
Timer/Counter
3. Logic Block
The respond to an instruction is determined by the
relationship between the conditions on the instruction line
that connects them.
Any group of conditions that formed to produce a logical
result is called a logical block.
4. Instruction Block
A block of instruction is composed of all the instructions
contained in a block.
Block is obtained by drawing a horizontal line without
cutting a vertical line and vice versa.
1. SCANNING
Scanning is the process of CPU
OUTPUT
Address
Instruction
Operand/Data
00000
LD
00000
00001
OUT
01000
Explanation:
The Execution Conditions of the instruction on the right
will be ON when IR 00000 is ON.
01000
output
address
Instruction
Operand/Data
00000
LD NOT
00000
00001
OUT
01000
Explanation
The Execution Conditions of the instruction on the right will
be ON when IR 00000 is OFF
b) And (AND):
These instructions are used in the second contact in a
normally open (NO) and a series with previous
contacts
Ladder Diagram
Code
00000
01000
00001
output
Mnemonic
Alamat
Arahan
Operand/Data
00000
LD
00000
00001
AND
00001
00002
OUT
01000
Explanation
The Execution Conditions of the instruction on the right will
be ON when IR 00000 and IR 00001 are ON
00001
output
Mnemonic
Address
instruction
Operand/Data
00000
LD
00000
00001
AND
00001
00002
OUT
01000
Explanation
The Execution Conditions of the instruction on the right will
be ON when IR 00000 ON and IR 00001 are OFF.
c) Or (OR):
These instructions are used in the second contact in a
normally open (NO) and in line (parallel) with
previous contacts.
Ladder Diagram
Code
00000
01000
00001
Mnemonic
address
instruction
Operand/Data
00000
LD
00000
00001
OR
00001
00002
OUT
01000
output
Explanation
The Execution Conditions of the instruction on the right
will be ON when either IR 00000 or IR 00001 are ON.
00001
01000
OUTPUT
Mnemonic
Address
instruction
Operand/Data
00000
LD
00000
00001
OR NOT
00001
00002
OUT
01000
Explanation
The Execution Conditions of the instruction on the right will be
ON when either IR 00000 is ON or IR 00001 is OFF or IR 00000
ON, IR 00001 OFF simultaneously
d) Out (OUT):
These instructions are used for the coil output.
Ladder Diagram
Code
00000
01000
Mnemonic
address
instruction
Operand/Data
00000
LD
00000
00001
OUT
10000
Ladder Diagram
Code
01000
00000
00001
END
Mnemonic
address
instruction
Operand/Data
00000
LD
00000
00001
AND NOT
00001
00002
OUT
01000
00003
FUN 01
Mnemonic
Mnemonic
Example OR LD:
o Remark If more than two blocks are to be connected in
parallel, they should be connected in a top to bottom
sequence.
o For example, block 1 and block 2 should be connected first,
then connect block 3 to it and so on.
h) No operation (NOP):
These instructions do not have a ladder diagram symbols
and will not do any operations.
When you remove the memory in this instruction will be
displayed on the console screen PLC programming.
De-composition of a network
The key process of de-composition of a network is to separate
the circuits that appear between two vertical lines into
independent elements and serial blocks, then coding those
elements and serial blocks according to the mnemonic coding
rules and then connect them (with ANDLD or ORLD instruction)
from left to right and top to bottom to form a parallel or a
serial-parallel blocks, and finally to form a complete network.
Sample diagram:
The sequence
S1 ; ON
Motor, M1 ; ON
S2 ; ON
Motor, M1 ; OFF
Descriptio
n
Output
Descriptio
n
00001
S1
01001
M1
00002
S2
00002
M1
M1
01001
END
Instructio
n
Data
00000
LD
00001
00001
OR
01001
00002
AND NOT
00002
00003
OUT
01001
00004
FUN(01)
Explanation
Operation table
00002
00003
HR000
01004
Timing diagram
b) Set/Reset (SET/RESET):
SET and RESET instruction will change the status of bit
operations only when the implementation is ON.
In the OFF condition, the instructions will not change the bit
operation status.
Mnemonic Code
Explanation
o Instructions JUMP and JUMP END can use the numbers from
the range of 00 to 99.
o To set the instruction for PLC type OMRON - SYSMAC CQM1H,
is FUN 04 for JUMP instruction and FUN 05 instruction is
the JUMP END instruction.
Mnemonic Code
Explanation
00000
00001
01000
Operation table
Timing diagram
All instruction that is between JMP (04) and JME (05) will be
ignored.
To set the INTERLOCK instruction for PLC type OMRON SYSMAC CQM1H is FUN 02 for INTERLOCK instruction
and FUN 03 is INTERLOCK CLEAR instruction.
0000
00001
1000
T1
Timing
T2
T3
diagram
T4
Mnemonic Code
Explanation
When the instruction input LD 00 000 is ON, the instruction
IL (02) will be ON.
Instruction output OUT 10 000 will depend on the
instruction input ON LD 00001 and LD 00000.
If the input instruction LD 00 001 ON, output OUT 10000
will be ON.
If the input instruction LD 00 001 OFF, output OUT 10000
will be OFF.
Mnemonic Code
01001
0000
01000
Mnemonic Code
01001
0000
01000
Ladder diagram:
Mnemonic code:
Data
being
delet
e
Ladder diagram:
Mnemonic code:
h) Arithmetic Function:
SET CARRY STC (40) FUN(40):
Symbol:
If the execution condition OFF, instruction STC ( 40 ) will not
function.
If execution condition ON, instruction STC ( 40 ) will ON carry
( Cy ).
SR25504 is carry flag that will ON if carry occur in execution
condition.
ADD process:
EXAMPLE 1:
EXAMPLE 2:
SUBTRACT process:
Ladder diagram:
Mnemonic code:
EXAMPLE 1:
Ladder diagram:
Mnemonic code:
Compare Result:
Explanation:
TR use to temporary store the status ON/OFF at the
instruction branch. Bit TR are from TR0 until TR 7.
When instruction LD 00000 ON, instruction CMP ( 20 ) will
execute.
Instruction COMPARE will compare the value in C1 with the
value in C2. Refer to the table above.
Example 1:
Operating Condition:
When the input (LD 00000) is ON, the timer contact will be
activated after 5 seconds.
Next, the output (OUT 10000) will be ON.
0000
5 sec
TIM000
Timing diagram
Example 2:
Operating Condition:
When the input (LD 00000) ON, the timer (TIM 000) will be
activated after 5 seconds and the output (OUT 10000) will be
ON.
While the output (OUT 10 001) will be ON as soon as the
supply is supplied and will be OFF after 5 seconds.
Timer will continue to be active as long as the input 00000
state is ON.
Example 3:
Operating Condition:
When the input (LD 00000) ON, the timer (TIM 000) will be activated
after 5 seconds. Next the output (OUT 10000) will be ON.
After 3 seconds the output (OUT 10000) ON, the timer (TIM 001) will
be activated the next output (OUT 10000) will be OFF and the timer
(TIM 001) will be OFF.
When the timer TM001 OFF, contact TIM 001 (NC) will be ON and the
output (OUT 10000) is ON state.
Output (OUT 10000) will continue ON and OFF until the input (LD
00000) in the OFF state.
Example 1:
Operating Condition
Counter set to count 10. When the input (LD 00,000) is the
pulse of ten, a counter will be activated and thus the output
(OUT 10000) will be ON.
When reset (LD 00,001) ON, a counter will be in original
condition
Timing Diagram:
0000
0001
CNT 001
1000
Timing Diagram:
0000
0001
CNT 000
TIM001
5 SEC
5 SEC
1000
1001
5 SEC
5 SEC
LS1
(s4)
LS2 (S5)
carrier
carrier
A
M1
M2
EXAMPLE 2:
Design a program that will monitor & control the conveyor
system for material testing while adhering the following
criteria:
The start button will be used to start the conveyor.
The stop button will be used to stop the conveyor if
emergency occur.
2 sensor which are inductive sensor and through beam
sensor.
The conveyor will halt at through beam sensor when
material available for 5 seconds.
If there is non-metal material, the conveyor will continue
to run.
If there is metal material, the conveyor will halt again at
inductive sensor for 10 seconds.