0% found this document useful (1 vote)
829 views

Chapter 4 - PLC Programming

Ladder Diagram is a way of representing electrical sequences of operations. It is a language which composes program using relay symbols as a base in an image similar to a hard-wired relay sequence. Sequence function chart (sfc) graphically displays the sequential functions of an automated system as a series of steps an transitions from one state to the next.

Uploaded by

Yazid Ismail
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
829 views

Chapter 4 - PLC Programming

Ladder Diagram is a way of representing electrical sequences of operations. It is a language which composes program using relay symbols as a base in an image similar to a hard-wired relay sequence. Sequence function chart (sfc) graphically displays the sequential functions of an automated system as a series of steps an transitions from one state to the next.

Uploaded by

Yazid Ismail
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 75

Chapter 4

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

Ladder diagram could not be


read by Programming
Console.
Hence, ladder diagram need
to be convert to mnemonic
code.
Mnemonic code give same
information as ladder
diagram and can be typed
directly to the Programming
Console

Address
00000
00001
00002
00003
00004
00005

Instruction
LD
FUN 02
LD
OUT
FUN 03
FUN 01

Operand
00000
00001
10000
-

3. Instruction Set

A low-level computer language used to


construct the ladder logic diagram by
entering statements that specify the
various components, and relationships
for each rung of the ladder diagram.
Comment
Example: Command
STR X1

Store input X1

AND X2

Input X2 in
series with X1
Output Y

OUT Y

4. Sequential Function Chart (SFC)


SFC graphically displays the sequential functions
of an automated system as a series of steps an
transitions from one state of the system to the
next.
The three main components of an SFC are steps,
actions and transitions.
Steps: chunks of logic, i.e., a unit of programming
logic that accomplishes a particular control task.
Actions: the individual aspects of that task.
Transitions: the mechanisms used to move from one
task to another.

Control logic for each Step, Action and Transition


is programmed in one of the other languages
such as Ladder Diagram or Structured Text.

Step
1
Transition
Step 1
2
Transition
Step 2
3

MOTOR
(START)
Action
MOTOR
(END)

5. Function Block Diagram


Is a graphical language that allows the
user to program elements in blocks.
The blocks can then be wired together
like electrical circuits.

SWITCH
SWITCH
1
2
LAMP
ON

OR

AN
D

CYLIND
ER OUT

6. Windows Based Program


A type of software program for a specific
brand of PLC that is developed by a
company other than the manufacturer of
that PLC.
These software programs can generally be
used with most personal computers in
either a DOS or Windows environment.
It has Simulator which allows ladder
program to be simulated on a PC without
purchasing the PLC.

LADDER DIAGRAM

Basic of Ladder Diagram


The ladder diagram program is
constructed by units called rung. A rung
is defined as one network which is
connected each other.
It comprises of one vertical line on the
left and right called bus bar and also
horizontal line to the right called
instruction lines.
Along the instruction lines, there are
combination of logic conditions which
will determine when and how the
directions of the most right will be

Instruction
lines

Bus
bar

Conditions

Bus
bar

Ladder Diagram

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)
Conditio
ns

Operand
bits

NO

ON
OFF

ON
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 Conditions

Logic combination between ON and OFF


conditions, forming a set of instructions
to be executed

Instruction will be in Execution


Conditions ON when: LD 00000, LD
00001 OFF and LD 00002 ON

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.

Logic Blocks And Instruction Blocks

Logic Blocks : Any group of condition


formed to produce one logic outcome
Instruction Blocks : Consists of all
instructions exist within a block

DATA AREA
Input
IR area
Output
Work

SR area

BITS
IR00000 - IR01515

FUNCTION
As input bits

IR10000 IR11515

As output bits

IR21600 IR21915

Do not has any specific


function. Can be use freely
in a program
Has specific function such
as flags and control bits

SR24400 SR25507

TR area

TR 0 TR 7

HR area

HR 0000 HR 9915

Timer/Counter area

TC 000 TC 511

Use to store temporary


ON/OFF status at any
program rung
Use to store data and
maintain ON/OFF status
when power shut down.
The same number use for
timer and counter. TC000
to TC002 use for interval
timer

Table : Memory map which refers to PLC OMRON -SYSMAC


CQM1H type

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) .

2. LD NOT- INSTRUCTION LOAD NOT


It was to start something programmed line.
Used at first contactor in the normally
closed (NC) situation.

Ladder diagram
Implementation State (Execution
Conditions) for instruction in right will ON
when IR 00000 is OFF

3. AND - INSTRUCTION AND


Connects an NO condition in series with
the previous condition
Implementation State (Execution
Conditions) for instruction in right will
ON when IR 00000 and IR 00001 is ON.

4. AND NOT- INSTRUCTION AND NOT


Connects an NC condition in series with
the previous condition

Information Ladder diagram


Implementation State (Execution
Conditions) for instruction in right will ON
when IR 00000 is ON and IR 00001 is OFF.

5. OR - INSTRUCTION OR
Connects an NO condition in parallel
with the previous condition.

6. OR NOT - INSTRUCTION OR NOT


Connects an NC condition in parallel
with the previous condition.

7. OUT- INSTRUCTION OUT


Outputs the result of logic to a bit.

8. END END(01)

Act as the last instruction for every program.


No one instruction will be written after END
(01).
Written as FUN 01 in the mnemonic code.
If END (01) instruction is not written in the
programming, hence there is no instruction
will be implemented and NO END LIST will be
Address
Instruction Operand
stated in the PLC console
screen.
00000

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.

10. OR LD - INSTRUCTION BLOCK


LOGIC OR
- OR LD instruction no physical relays
device.
- Only one programming tool to resolve
complex OR 's function such as a LD
relay serial ( or LD NOT ) in parallel
position by one other sesentuh serial.

11. AND LD - INSTRUCTION BLOCK


LOGIC AND
- AND LD instruction no physical relays
device.
Only one programming tool to resolve
complex AND function such as linking a
few OR, OR NOT, OR LD in the event
serial.

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.

CONTROL INSTRUCTION SET BIT


At the end of this unit you should be able to understand the
sequence instruction set as per below:
INTERLOCK
JUMP
KEEP
SET/RESET
DIFFERENTIATE UP / DOWN
MOVE
SHIFT REGISTER
ARITHMETIC FUNCTION

Sequence instruction set such as RESET, KEEP,


DIFFERENTIATE UP, DIFFERENTIATE DOWN, serves to ON and
OFF the output bit at IR area.
It is also used to control other status bit in IR area or in other
areas.

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

When IL 02 is ON, all the output instructions


between IL 02 and ILC 03 will be executed
accordingly. But, if IL 02 is OFF, the output in
between is also OFF even though there is supply
to it.
ILC 03 is use to reset the program.

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)

Instruction OUT 10000


(output)

ON

ON

ON

OFF

OFF

ON

OFF

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.

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

Table : Instruction set

QUESTION 1

According to Table 1, which output will ON


when:
JMP(04) is ON.
JMP(04) is Address
OFF.
00000
00001
00002
00003
00004
00005
00006
00007

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)

KEEP - KEEP (11)

To maintain the bit status operation


based on two execution condition.
KEEP (11) operating such as Latching
Relay which set by S and reset by R.
When S is ON, certain instruction
operation will ON and remain ON
until reset regardless S is ON or OFF.
For PLC 's set OMRON type - SYSMAC
CQM1H:
KEEP = FUN 11.

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

Figure: Ladder diagram for instruction


KEEP

Instruction
LD 00002
Set
ON
OFF
ON
OFF

Instruction
OUT 10004
OUTPUT
ON
ON
OFF
OFF

Table : Instruction set for

SET AND RESET


SET and Reset instructions only change the status of their
operand bits for ON execution condition.
Neither instruction will effect 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

Will not turn ON when the 00000 goes ON and will


remain ON until 00001 goes ON, regardless of the
status of 00000
Please refer instruction set for KEEP.

Ladder diagram for instruction SET and RESET

Address
00000
00001
00002
00003

Instruction
LD
SET
LD
RESET

Operand
00000
10000
00001
10000

DIFFERENTIATE UP [ DIFU (13) ]


AND DIFFERENTIATE DOWN
[ DIFD (14) ]
DIFFERENTIATE UP : Turns ON a bit for
one cycle when the execution condition
goes from OFF to ON
DIFFERENTIATE DOWN: Turns ON a bit
for one cycle when the execution
condition goes from ON to OFF.
For PLC 's set OMRON type - SYSMAC
CQM1H:
DIFU (13) = FUN 13

INPUT
DIF U
DIF D

Figure : Time diagram for DIFU and


DIFD

DIFFERENTIATE UP [ DIFU (13) ]

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

Address Instruction Operand


00000

LD

00000

00001

FUN (21)

00002

000

00003

100

00004

FUN 01

S
D

When LD 00000 ON, all data in IR 000 will be


copy to IR 100. The original data in IR 000 will
remain.

SHIFT REGISTER- SFT


(10)
The shift register is a number of internal relays grouped
together (normally 8, 16 or 32) which allow stored bits to be
shifted from one relay to another.
Each internal relay is either effectively open (0) or closed (1).
The term bit is used for each such binary digit.
It requires three inputs,
one to load data into the first location of the register
one as the command to shift data along by one location (clock pulse)
one to reset or clear the register of data.
DI
CP
R

S : Start Channel
SFT
(10)

E : End Channel
S

DI : Input Data

CP: Clock Pulse


R : Reset

S and E must be in the same memory area


(i.e. IR , SR , AR , HR , LR).
If DI is ON, bit 1 is shifted into the register.
If DI is OFF, bit 0 is shifted into the register.
When DI is shifted into the register, all existing
bits in the register will be shifted to the left.
The utmost left bit overflow and will be lost
The reset (R) input will reset all the bits in SR
to 0.

Address Instruction Operand


00000
LD
00002
00001
LD
00004
00002
LD
00003
00003
SFT (10)
100
00004
100
00005
LD
00005
00006
OUT
10003
00007
FUN 01
-

S
E

ARITHMETIC FUNCTION - CLC (41)


Clear carry / CLC (41)
Clear carry is used to reset carry (CY)
that exist on the SR25504 to zero.
CLC
(41)

ARITHMETIC FUNCTION - ADD (30)


A function to add three pieces of parameters:
Augend Channel (Au), Addend Channel (Ad) and
carry (CY).
The results are placed on data 3 Result Channel
(R).
Carry will be set to 1 if the sum is greater than
9999.
Au and Ad are range from #0000 to #FFFF.
For PLC 's set OMRON type - SYSMAC CQM1H:
ADD (30) = FUN 30

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 )

CLC 41 will clear the


carry value to 0
IR 100 will store
the result

Au

+ Ad + Cy = Cy
Addition process

ARITHMETIC FUNCTION - SUB ( 31 )


A function to subtract three pieces of
parameters: Minuend (Mi), Subtrahend (Su)
and carry (CY).
The results are placed on Result (R).
If the result is negative then carry will be set
to 1.
Mi and Su are range from #0000 to #FFFF.
For PLC 's set OMRON type -SUB(30)
SYSMAC CQM1H:
SUB (31) = FUN 31

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

ARITHMETIC FUNCTION CMP ( 20)


Compare is an instruction to compare two
pieces of data, C1 and C2.
The results can be:
> (greater) that will activate special relay 25505
= (equals) that will activate special relay 25506
< (smaller) that will activate special relay 25507.

For PLC 's set OMRON type - SYSMAC CQM1H:


CMP (20) = FUN 20
CMP(20)
C1
C2

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)

TR: use to store temporary ON/OFF status in a


program rung.
Bit: from TR 0 TR 7
Address Instruction
00000
LD
00001
OUT
00002
FUN (20)

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

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

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

Figure 30: Timing


Diagram

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

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. CNT 000), it can be used any amount
of time as operator operand in other instruction other than counter.

Set value (SV): between 0000 to 9999


# 0010 = 10 pulse
# 0100 = 50 pulse

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

COUNTER AND TIMER

COUNTER AND TIMER operand number cannot


be the identical because both share the same
data area in PLC memory.
Address Instruction
00000
LD
00001
LD
00002
CNT
00003
00004
00005
00006

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

You might also like