0% found this document useful (0 votes)
422 views

Chapter 4 - Programming

The document discusses various programming languages that can be used with programmable logic controllers (PLCs) according to the IEC 1131-3 international standard. It lists the languages as ladder logic, sequential function charts, function block diagrams, structured text, and instruction list. It provides descriptions and examples of ladder logic, instruction list, structured text, sequential function charts, and function block diagrams. It also discusses PLC programming concepts such as mnemonic code, basic logic instructions, and sequential functions.

Uploaded by

MOHD SABREE
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
422 views

Chapter 4 - Programming

The document discusses various programming languages that can be used with programmable logic controllers (PLCs) according to the IEC 1131-3 international standard. It lists the languages as ladder logic, sequential function charts, function block diagrams, structured text, and instruction list. It provides descriptions and examples of ladder logic, instruction list, structured text, sequential function charts, and function block diagrams. It also discusses PLC programming concepts such as mnemonic code, basic logic instructions, and sequential functions.

Uploaded by

MOHD SABREE
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 58

CHAPTER 4

PROGRAMMING

DJM3072 - PROGRAMMABLE LOGIC


CONTROLLER (PLC)
PLC Programming Languages
IEC 1131-3 is the international standard for programmable controller
programming languages. The following is a list of programming
languages specified by this standard:

 Ladder diagram (LD)


 Sequential Function Charts (SFC)
 Function Block Diagram (FBD)
 Structured Text (ST)
 Instruction List (IL)

One of the primary benefits of the standard is that it allows multiple


languages to be used within the same programmable controller. This
allows the program developer to select the language best suited to
each particular task.
PROGRAMMING LANGUAGE

Ladder Diagram (Rajah Tangga)

Instruction List (Senarai Arahan)

Structured Text (Teks Struktur)

Sequential Function Chart (Carta Fungsi Turutan)

Function Block Diagram (Fungsi Rajah Blok)
1. LADDER DIAGRAM
A ladder diagram is a means of graphically
representing the logic required in a relay logic
system.


Ladder logic uses a
variety of programming
symbols

Power always flows
from left to right

Output devices are in
the ON state if power
flows through them
CONT..

Power flows through these contacts when they are closed.

The normally open (NO) is true when the input device is 1 (on).
The normally closed (NC) is true when the input device is 0 (off).
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.
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.
Start

End
Example:-
2. INSTRUCTION LIST (IL)
A low level language which has a structure similar to an
assembly language. Since it is simple, it is easy to learn and
ideally for small hand-held programming devices. Each line of
code can be divided into four fields: label, operator,
operand, and comment.

Simple example:-

LD A
AND B
ST C
Basic IL Instructions
Example :
3. STRUCTURED TEXT (ST)

Structured Text (ST) is a high level textual language that is a
Pascal like language. It is very flexible and intuitive for
writing control algorithms.

used to express the behavior of functions, function blocks
and programs

In IEC 1131-3 standard, it has a syntax very similar to
PASCAL

strongly typed language

Functions:
●assignments

●expressions

●statements

●operators

●function calls


flow control
Example:
Cylinder out = (Input A OR Input B) AND Output C
4.SEQUENTIAL FUNCTION CHART (SFC)
A graphics language used for depicting
sequential behavior. The IEC standard grew out
of the French standard Grafcet which in turn is
based on Petri-net.
SFC have been developed to accommodate the
programming of more advanced systems. These
are similar to flowcharts, but much more
powerful. This method is much different from
flowcharts because it does not have to follow a
single path through the flowchart.
SFC
Action Qualifiers:
N non-stored, executes while
the step is active
R resets a store action
S sets an action active
L time limited action,
terminates after a given period
D time delayed action.
P a pulse action, executes
once in a step
SD stored and time delayed
DS time delayed and stored
SL stored and time limited
EXAMPLE FOR SFC
A SFC is depicted as a series of
steps shown as rectangular boxes
connected by vertical lines. Each
step represent a state of the
system being controlled.
The horizontal bar indicates a
condition. It can be a switch
state, a timer, etc. A condition
statement is associated with each
condition bar. Each step can also
have a set of actions. Action
qualifier causes the action to
behave in certain ways. The
indicator variable is optional. It is
for annotation purposes
5.FUNCTION BLOCK DIAGRAM (FBD)
Functional Block Diagram (FB) is a well packaged element
of software that can be re-used in different parts of an
application or even in different projects. Functional blocks
are the basic building blocks of a control system and can
have algorithms written in any of the IEC languages.

The main concept is the


data flow that start
from inputs and passes
in block(s) and generate
the output.
AN UP COUNTER FUNCTION BLOCK
The algorithm in Structured Text:

FUNCTION BLOCK CTU


VAR_INPUT
CU : BOOL;
R : BOOL;
PV : INT;
END_VAR
VAR_OUTPUT
Q : BOOL;
CV : INT;
END_VAR
IF R THEN
CV := 0;
ELSEIF CU

CU : input to be counted AND (CV < PV) THEN


CV := CV + 1;
R : reset END_IF;

PV : preset value Q := (CV >= PV);


END_FUNCTION_BLOCK
Q : contact output
CV : counter value.
A PID CONTROL FUNCTION BLOCK

block diagram

SP set point
PV sensor feedback
KP proportional error gain
TR integral gain
TD derivative gain control algorithm
AUTO calculate
XOUT output to process
XO manual output adjustment
cycle time between execution
DIFFERENCES BETWEEN
LADDER AND FBD
MNEMONIC CODE

One of the earliest techniques involved mnemonic
instructions. These instructions can be derived directly
from the ladder logic diagrams and entered into the PLC
through a simple programming terminal.
EXAMPLE
Ladder diagram and mnemonic code to solve control system
For a process control, it is desired to have the process start (by turning
on a motor) five seconds after a part touched a limit switch. The
process is terminated automatically when the finished part touches a
second limit switch. An emergency switch will stop the process any
time when it is pushed.
BASIC LOGIC INSTRUCTION

Load/Load Not

And/And Not

Or/Or Not

AND load

OR load

Out

END

No Operation
LOAD
Load: The load (LD) instruction is
a normally open contact

A Load (contact) symbol


LOAD NOT
Load Bar: The Load Bar instruction is a normally
closed contact.

A Load Bar (normally closed contact)


symbol
AND

Each rung or network on a ladder program represents


a logic operation. In the rung above, BOTH inputs A and B
must be true (1) in order for the output C to be true (1).
AND NOT

Each rung or network on a ladder program represents


a logic operation. In the rung above, inputs A must be
true (1) and input B must be true (0) in order for the
output C to be true (1).
OR

In the rung above, it can be seen that either input A or B


is be true (1), or BOTH are true (1), then the output C
is true (1).
OR NOT

In the rung above, it can be seen that input A is be true


(1), or input B are true (0), then the output C is true (1).
AND LOAD
AND LD connects two blocks in series
AND LOAD
AND LD connects two blocks in series
OR LOAD
OR LD connects two blocks in parallel
OR LOAD
OR LD connects two blocks in parallel
OUT
Out :The Out instruction is sometimes also called an
Output Energize instruction. The output instruction is like
a relay coil

An OUT (coil) symbol

Out Bar: The out bar instruction is like a normally closed


relay coil

An OUT Bar (normally closed coil) symbol


END
● Acting as the last instruction for each program
(see Figure).
●No instruction will be written after END

instruction (01) implemented.


●If there is no END instruction (01) in the

program, then no instructions will be developed


and NO END LIST will be display the PLC
programming.
NOP
●These instructions do not have the symbol of the
ladder diagram and will not perform any operations.
●When you remove the memory, this instruction will
be displayed at the console screen PLC programming.
SEQUENCIAL FUNCTION
1. Keep
2. Set/Reset
3. Jump
4. Interlock
5. Differentiate Up/Down
6. Move
7. Shift Register
8. Arithmetic Function
1. KEEP (11)

KEEP instruction is used to maintain the status bit
operation based on two state implementation
(execution condition).

KEEP (11) operates like a relay latch (Latching
Relay), which is set by S and reset by R.

It maintains an ON or OFF state of a bit until one
of its two inputs sets or resets it.

In order to set OMRON PLC, the instruction is the
KEEP FUN 11.
2. 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
status bit operation.
Input

Set

Input

Reset
3. JUMP

Instructions JMP (04) is usually used in pairs with the
command JME (05) for the jump.

JMP (04) instructions for determining the starting point of
the jump and JME (05) is the direction of the jump.

When the instruction JMP (04) is ON, no jump will occur and
the program will be implemented as written.

When the instruction JMP (04) is OFF, a jump to the
instruction JME (05) having the same number will be done.
Further instruction after JME (05) will be implemented.

Instructions JUMP and JUMP END can use the numbers from
the range of 00 to 99.

To set jump instruction for OMRON PLC, the instruction FUN
04 is for the JUMP and instruction FUN 05 is for JUMP END
instruction.
Address Instruction Operand / Data
00000 LD 00000
00001 FUN (04) 01
00002 LD 00001
00003 OUT 10000
00004 FUN (05) 01
00005 FUN (01) -

LD 00000 LD 00001 OUT 10000


JMP(04) In Out
ON ON ON
OFF OFF
OFF No execute No execute
4. INTERLOCK

IL (02) and ILC (03) must be used together.

These instructions are used to solve the problem
of storing the execution condition at the branch
point.

When the INTERLOCK instruction is ON as shown
in figure, the implementation of the INTERLOCK
instruction will control the implementation of
instruction until the INTERLOCK CLEAR instruction.
When the INTERLOCK instruction is OFF, INTERLOCK
CLEAR instruction will reset the program operations.
Address Instruction Operand / Data
00000 LD 00000
00001 FUN 02 -
00002 LD 00001
00003 OUT 10000
00004 FUN 03 -
00005 FUN 01 -

LD 00000 LD 00001 OUT 10000


IL(02) In Out
ON ON ON
OFF OFF
OFF ON OFF
OFF OFF
5. DIFU (13) AND DIFD (14)
● Instructions DIFU (13) and DIFD (14) will ON state
output within a very short time.
●Instructions DIFU (13) will convert the output to ON

when the input signal changes from OFF to ON.


●Instructions DIFD (14) will convert the output to ON

when the input signal changes from ON to OFF.


●To set type of OMRON PLC - SYSMAC CQM1H, the

instruction is FUN 13 DIFFERENTIATE UP instruction and


the instruction is the instruction FUN 14 DIFFERENTIATE
DOWN
● When the input instruction LD 00 000 ON (there has been a
change from OFF to ON), 01 000-bit operations will ON, the
output will be ON OUT 10,000 within a very short time and then
OFF. We can not see the situation at the output.
●After the 01 000-bit operations will be OFF regardless of the

status of the input instruction LD 00000.


Address Instruction Operand / Data
00000 LD 00000
00001 FUN (14) 01000
00002 LD 01000
00003 OUT 10000


When the input instruction LD 00 000 OFF (there has been a
change from ON to OFF), 01 000-bit operations will ON, the
output will be ON OUT 10,000 within a very short time and
then OFF. We can not see the situation at the output.

After the 01 000-bit operations will be OFF regardless of the
status of the input instruction LD 00000.
6. MOVE (21)


MOVE instruction copy the from the source
channel to the destination source.

For OMRON PLC, FUN 21 is the instruction for
MOVE.

Symbol:
SOURCE SOURCE

Masukan Keluaran

Channel 000 Channel 100


7. SHIFT REGISTER (10)

Shift Register ( SFT ) will shift 16 bit, 1 or 0.


Each 1 or 0 can be use to represent something.
Symbol:
8. ARITHMETIC INSTRUCTION
A. TIMER INSTRUCTION SET

Timers are normally used for time delay. It
can be ON delay, OFF delay etc..
TIMER APPLICATION
TIMER APPLICATION
B. COUNTER INSTRUCTION SET

Counter are in the range of 000 until 015.

Use for the countdown from the set value (SV)
when the execution condition at count pulse
change from OFF to ON.

Symbol:
COUNTER APPLICATION

You might also like