0% found this document useful (0 votes)
54 views20 pages

Basic Instructions for Programmable Controllers

The document provides an overview of basic instructions for programming a programmable controller, including LD, LDI, OUT, SET, RST and END instructions. It explains the function of each instruction, provides examples of ladder diagrams and logic sequences, and timing charts to illustrate instruction usage.

Uploaded by

Apply Softtech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views20 pages

Basic Instructions for Programmable Controllers

The document provides an overview of basic instructions for programming a programmable controller, including LD, LDI, OUT, SET, RST and END instructions. It explains the function of each instruction, provides examples of ladder diagrams and logic sequences, and timing charts to illustrate instruction usage.

Uploaded by

Apply Softtech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHAPTER 2 OVERVIEW OF INSTRUCTIONS TO BE USED IN EXAMINATION

A programmable controller is assemblies of relays, timers, and counters. The internal sequences can be
wired by programming for a programmable controller.
Rules according to the contact, connection type of coil, or the coil type are required for the wiring, and
this rule is called instruction.
Some instructions contain instruction words and device numbers, others have only instruction words to
operate.
This chapter introduces basic instructions for the programming of the programmable controller.
Remember the meaning of each instruction.

2.1 Basic Instruction

2.1.1 Instruction

Symbol/Name Function Drawing JIS symbol


LD Starting to operate a normally
open contact – – – |***| – – –
Load
LDI Starting to operate a normally ***
closed contact –––|/|–––
Load inverse
AND Series connection of normally
And open contacts

ANI Series connection of normally


And inverse closed contacts
OR Parallel connection of
Or normally open contacts

ORI Parallel connection of


Or inverse normally closed contacts

ANB
Series connection of blocks
And block
ORB
Parallel connection of blocks
Or block
OUT ***
Coil drive instruction –––( )–––
Out
SET Operation hold output ***
instruction
SET – – – (S) – – –
Set
RST Operation hold cancel ***
instruction
RET – – – (R) – – –
Reset
PLS Turns on the specified device ***
for one scan at rising edge of PLS –––|P|–––
Pulse an input condition
PLF Turns on the specified device ***
for one scan at falling edge of PLF –––|N|–––
Pulf an input condition
END End of the program and return to
Program end
End step 0

* JIS symbols are based on JIS B 3503.

2-1
2.1.2 LD, LDI, OUT, and END instructions

LD Load : Operation start instruction for normally open contact


LDI Load inverse : Operation start instruction for normally closed contact
OUT Out : Coil drive instruction
END End : Instruction for the end of a program

[Example of ladder diagram] [List program]

Step Instruction
This line is called a "bus". 0 LD X0
OUT (Note 2)
LD (Note 1) 1 OUT Y10
X0
0 Y10 2 LDI X0

X0 3 OUT Y11
2 Y11 4 END
LDI (Note 1)
[Step number]
4 END
• The step number indicates the order of the
program and the program size.
• When the instructions are programmed
according to the order of the list program,
[Timing chart] the programmable controller assigns the
step number automatically.
ON (Note 1) Use LD (Load) as the first normally
Contact X0 OFF open contact and LDI (Load
ON inverse) as the first normally closed
contact.
Coil Y10 OFF The contact instructions such as LD
and LDI are used for devices such
Coil Y11 as the input relay X, the output relay
Y, the timer T, the counter C, and
OFF the auxiliary relay M.

(Note 2) Coil drive instructions such as OUT


are used for devices other than the
[Sequence]
input relay X.
When the input X0 is turned on, the output Y10 turns on.
When the input X0 is turned off, the output Y11 turns on. (Note 3) The assignment of the step number
may vary depending on the
programmable controller model
used.
In this textbook, the step numbers
are described based on step
numbers of the Q-series
programmable controller.

2-2
2.1.3 SET and RST instructions

SET Set : Operation hold output instruction


RST Reset : Operation hold cancel instruction

[Example of ladder diagram] [List program]

Step Instruction

X0 0 LD X0
0 SET Y10 1 SET Y10

X1 2 LD X1
2 RST Y10 3 RST Y10
4 END
4 END
• These instructions drive the coil as
well
as the OUT instruction.
[Timing chart] • With the OUT instruction, when the
contact to drive the coil turns off from
on, the coil programmed with the OUT
ON instruction turns off as well. With the
Contact X0 SET (Set) instruction, even when the
contact turns off from on, the coil
ON
remains on and the operation is held.
Contact X1 Use the RST (Reset) instruction to turn
ON off the coil driven by the SET (Set)
i i
Coil Y10

[Sequence]
Turning on the input X0 turns on the output Y10.
Even when the input X0 is turned off from on, Y10 remains on and the status is held.
Turning on the input X1 turns off the output Y10.

2-3
2.1.4 AND and ANI instructions

AND And : Series connection instruction for normally open contact


ANI And inverse : Series connection instruction for normally closed contact

[Example of ladder diagram] [List program]

Step Instruction
AND ANI 0 LD X0
1 AND X1
X0 X1 X2
2 ANI X2
0 Y10
3 OUT Y10
X3
Y11 4 AND X3
AND (Note 1) 5 OUT Y11
6 END
6 END

• Use the AND (And) instruction for the


normally open contact or the ANI (And
[Timing chart]
inverse) instruction for the normally closed
contact connected to LD or LDI in series.
ON • Y10 and Y11 are on when all contacts
which drive these contacts connected in
Contact X0
series are on.
ON
Contact X1 (Note 1) Note that the contact instruction
here is always AND or ANI.
Contact X2
OFF
ON
Contact X3
ON
Coil Y10
ON
Coil Y11

[Sequence]
When the input X0 and X1 are on and X2 is off, the output Y10 is on.
When the input X0, X1, and X3 are on and X2 is off, the output Y11 turns on.

2-4
2.1.5 OR and ORI instructions

OR Or : Parallel connection instruction for normally open contact


ORI Or inverse : Parallel connection instruction for normally closed contact

[Example of ladder diagram] [List program]

Step Instruction
0 LD X0
X0
1 OR X1
0 Y10
X1 2 ORI X2
3 OUT Y10
X2
4 END

4 END
• Use the OR (Or) instruction for the
normally open contact or the ORI (Or
inverse) instruction for the normally
closed contact connected to LD or LDI
[Timing chart] in parallel.
• In the left figure, the output Y10 turns on
when one of the contacts connected to
ON Y10 in parallel is on.
Contact X0
ON
Contact X1
Contact X2
OFF
ON
Coil Y10

[Sequence]
Even when one of the conditions (the input X0 is on, X1 is on, or X2 is off) is met, the output Y10 turns on.

2-5
2.1.6 ANB instruction

ANB And block : Series connection instruction for parallel ladder block

[Example of ladder diagram] [List program]

Use the LD instruction for start of a branch. Step Instruction


0 LD X0
X0 X2
ANB 1 OR X1
0 Y10
2 LD X2
3 OR X3
X1 X3
4 ANB
Parallel ladder
block 5 OUT Y10
OR instruction before 6 END
6 END
the ANB instruction
• To connect ladder blocks where
contacts are connected in parallel in
[Timing chart] series as shown left, use the ANB (And
block) instruction.
• A device number is not assigned to the
ON
ANB instruction.
Contact X0 In this type of program, the LD
ON instruction is used for the contact X2.
The OR instruction is used since X1 and
Contact X1
X3 are connected to X0 and X2, for
ON which the LD instruction is used, in
Contact X2 parallel.

ON
Contact X3
ON ON
Coil Y10

[Sequence]
Y10 turns on when either of the input X0 or X1 and X2 or X3 are turned on simultaneously.

POINT
In the programmable controller-related works, programs are monitored or edited in
the ladder diagram style in most cases. In the practical test (written test), questions
about the knowledge of list programs may be asked, and thus it is recommended to
read this section.

2-6
2.1.7 ORB instruction

ORB Or block : Parallel connection instruction for series ladder block

[Example of ladder diagram] [List program]

Step Instruction

X0 X1 0 LD X0
0 Y10 1 AND X1
2 LD X2

X2 X3 3 AND X3
ORB
4 ORB
Series ladder block 5 OUT Y10

6 END 6 END

• The OR and ORI instructions connect


one contact to the previous LD contact
[Timing chart]
in parallel.
To connect a ladder block where
ON contacts are connected in series in
parallel as shown left, use the ORB (Or
Contact X0
block) instruction.
ON • A device number is not assigned to the
Contact X1 ORB instruction.
In this type of program, the LD
ON
instruction is used for the contact X2.
Contact X2
ON
Contact X3
ON ON
Coil Y10

[Sequence]
The output Y10 turns on when the input X0 and X1 are turned on simultaneously or X2 and X3 are
turned on simultaneously.

POINT
In the programmable controller-related works, programs are monitored or edited in
the ladder diagram style in most cases. In the practical test (written test), questions
about the knowledge of list programs may be asked, and thus it is recommended to
read this section.

2-7
2.1.8 PLS and PLF instructions

PLS Pulse : Turns on the specified device for one scan at rising edge of an
input condition
PLF Pulf : Turns on the specified device for one scan at falling edge of an
input condition

[Example of ladder diagram] [List program]

X2 Step Instruction
0 PLS M0
0 LD X2
M0 X0
3 Y10 1 PLS M0
Y10 3 LD M0
4 OR Y10
X3
7 PLF M1 5 ANI X0
M1 X1
Y11 6 OUT Y10
10
Y11 7 LD X3
8 PLF M1
14 END
10 LD M1
11 OR Y11
[Timing chart] 12 ANI X1
13 OUT Y11
(PLS instruction) ON
14 END
Contact X2 • The PLS instruction turns on the
ON (One scan) specified device only for one scan when
the execution condition is turned on from
Coil M0
off.
ON • The PLF instruction turns on the
Coil Y10 specified device only for one scan when
the execution condition is turned off from
ON
on.
Contact X0
[Sequence]
(PLF instruction) Y10 turns on when X2 is turned on. Y10
ON
turns off when X0 is turned on.
Contact X3 To turn on Y10 again, turn X2 on from
ON (One scan) off.
Y11 turns on when X3 is turned on. Y11
Coil M1
turns off when X1 is turned on.
ON To turn on Y11 again, turn X3 off from
Coil Y11 on.

ON
Contact X1

2-8
2.1.9 Timer

T Timer : Time setting

• This section describes the programming of the digital timer of programmable controllers.

[Example of ladder diagram] [List program]

X0 Step Instruction
0 Y10 0 LD X0
K100
1 OUT Y10
T0
2 OUT T0 K100
T0
Y11 6 LD T0
6
7 OUT Y11
8 END
8 END

[Timing chart]

Contact X0
• The timer contact operates delaying by
a set time after the coil is energized.
Coil Y10, T0 (On-delay timer)
10sec. This set time is called set value, and
Contact T0 indicated by K.
• When X0 is turned off while the timer is
driving, the current value of the timer
Coil Y11 returns to 0 and the timer contact turns
off.
[Sequence]
Turning on the input X0 turns on Y10, and Y11 turns on in 10 seconds after Y10 has turned on.

2-9
2.1.10 Counter

C Counter : Counter setting

• This section describes the programming of typical counters of programmable controllers.

[Example of ladder diagram] [List program]

Step Instruction
X0
RST C0 0 LD X0
0
Reset input 1 RST C0
K10
X1 5 LD X1
5 C0
Count value input 6 OUT C0 K10
C0 10 LD C0
10 Y10
11 OUT Y10

12 END 12 END

[Timing chart]

X0 Reset input • The counter counts how


many times the contact
(X1) is turned on from off.
X1 Count value input The contact (X1) is called
the count value input, and
the value counted by the
10
counter is called current
9
8 value.
Current 7 The counter contact is
value of 6 turned on when the
counter 5 current value reaches the
4 specified number (set
3
value).
2
1 • After the count, the
0 current counter value
does not change and the
Y10 (C0 Contact output) output contact remains
on.
[Sequence]
The output Y10 turns on after the count value input X1 has been turned on for 10 times.
Turning on the reset input X0 sets the counter current value to 0 and the output Y10 to off.

2-10
2.2 Application Instruction

2.2.1 MOV instruction

MOV Move : Data transfer

[Example of ladder diagram]

• When the input condition is turned on, the data in


SM401 S1 D1 the device specified by S a re transferred to the
0 MOV K1X0 D0
Always device specified by D .
OFF S2 D2
• Use the MOV instruction when reading the
MOV D0 K1Y10
changing data for all the time.
• Use the MOVP instruction (P is a capital of
7 END
Pulse) to transfer data instantaneously such as
setting data or reading data at an error.

[Sequence]
CPU
(Input module) D0 (Output module)

X0 Y10
X1 Y11
K1 X0 K1 Y10
Number Start X2 Y12 Number Start
of digits number
X3 Y13 of digits number

MOV MOV
S1 D1 S2 D2
Sequential 4-bit data Sequential 4-bit data
from X0 from Y10

K1••• 4 bits
K2••• 8 bits
K3••• 12 bits
K4••• 16 bits The following shows a program which is
created without the MOV instruction.

X0
Y10
X1
Turning on the input X0 turns on Y10. Y11
Turning on the input X1 turns on Y11. X2
Y12
Turning on the input X2 turns on Y12. X3
Turning on the input X3 turns on Y13. Y13

END

2-12
2.2.2 BIN

BIN Binary : BCD BIN data conversion instruction

[Example of ladder diagram]

S D
X0
0 BIN K1X0 D0

• When the input condition is turned on, the data in the device specified in S is recognized as a
binary-coded decimal (BCD code), converted into binary (BIN code), and transferred to the device
specified in D .

8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1


S side BCD 9999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1

Thousand digits Hundred digits Ten digits Unit digits

Converted into BIN

16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1


D side BIN 9999 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1

Becomes 0.

Digital switch
• In programmable controllers, numeric values are converted into BIN
values.
• The ordinary digital switches generate BCD codes.
Therefore, the BCD BIN data conversion instruction is required for
5
writing data from the digital switches to the programmable controller. 8 4 2 1
K1X0

D0
4 BIN
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
+) 1
5

2-13
2.2.3 BCD

BCD Binary-coded decimal : BIN BCD data conversion instruction

[Example of ladder diagram]

X0 K99 • When the input condition is turned on, the data


0 C0 in the device specified in S is recognized as
X1 S D
a binary (BIN code), converted into a
5 BCD C0 K2Y10
binary-coded decimal (BCD code), and
X2
9 RST C0 transferred to the device specified in D .

14 END

16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1


S side BIN 9999 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1

Must be set to "0". Converted into BCD

8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1


D side BCD 9999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1

Thousand digits Hundred digits Ten digits Unit digits

• The ordinary 7-segment LED displays display numbers in the BCD code. Therefore, the BCD instruction is
required for displaying data of the programmable controller (current values of timers and counters, data
resister values of operation results).
[Sequence]
After the input X0 has been turned on for 75 times and X1 is turned on, the display of the 7-segment LED
display is as follows.

C0
0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
(BIN)
64
8
2
+) 1
75 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1
(BCD)

K2Y10
8 4 2 1 8 4 2 1
7-segment
LED display

2-14
2.2.4 Comparison operation instruction

= < > <= >= <> : Size comparison

[Example of ladder diagram]

X0 K30
0 C0
X1
5 BCD C0 K2Y10
S1 S2
9 > K10 C0 Y18

< K20 C0

16 = K30 C0 RST C0

23 END

• The comparison operation instruction compares the data of source 1 ( S1 ) and source 2 ( S2 ), and brings
the devices into conduction if the conditions are met.
• The instruction can be regarded as one normally open contact ( ) since it is conducted only when
the conditions are met.

> K10 C0 Y18 Y18

< K20 C0

= S1 S2 ... Becomes conducted when source 1 and source 2 match.

< S1 S2 ... Becomes conducted when source 1 is smaller than source 2.

> S1 S2 ... Becomes conducted when source 1 is larger than source 2.

<= S1 S2 ... Becomes conducted when source 1 and source 2 match or when source

>= S1 S2 ... Becomes conducted when source 1 and source 2 match or when source

<> S1 S2 ... Becomes conducted when source 1 and source 2 do not match.

2-15
2.2.5 Arithmetic operation instruction

+ (P) Plus : BIN 16-bit addition


(For FX-series programmable controllers, use the ADD instruction. Refer to the reference on the
next page.)

[Overview]
This instruction adds two values to obtain the result.

[Example of ladder diagram]

X0 S D
0 +P K5 D0 (Note 1)

X1 S1 S2 D
4 +P D0 K100 D1 (Note 2)

(Note 1) Every time the input condition is turned on, the content of the device specified in S is added to
the content of the device specified in D and the result is stored in the device specified in D .
D S D
D0 + (5) D0
(Input condition)
First ON 0 + 5 5
(example)
Second ON 5 + 5 10
Third ON 10 + 5 15
The content of
D0 is changed.

(Note 2) When the input condition is turned on, the content of the device specified in S1 is added to the
content of the device specified in S2 and the result is stored in the device specified in D .
S1 S2 D
D0 + (100) D1
(Input condition)
ON 15 + 100 115
(example)
The content of D0 is not changed.

NOTE
• +P or -P must be used for the addition or subtraction instructions.
• When + or - is used, an addition or subtraction operation is
executed every scanning. To use + or - , operands must be
converted into pulse in advance.
X0 X0
+P K5 D0 PLS M0
M0
+ K5 D0

2-16
Reference

ADD(P) Addition : BIN 16-bit addition


(Use this instruction only for FX-series programmable controllers.)

[Function and operation]


The contents of S 2 a re added to S 1 i n binary format, and the result is transferred to D .

Command
input
ADD S1 S2 D
S1 + S2 D

(* The operation is the same as [+ S1 S2 D] of the Q and L series.)

NOTE
• The same device number can be specified as source S 1 a nd destination D .
In this case, note that the addition result changes in every operation cycle if a continuous operation
type instruction (+ or ADD) is used.

X1
(D0) + 25 (D0)
+ D0 K25 D0

X001
(D0) + 25 (D0)
ADD D0 K25 D0

2-17
- (P) Minus : BIN 16-bit subtraction

(For FX-series programmable controllers, use the SUB instruction. Refer to the reference on the next
page.)

[Overview]
This instruction subtracts a value from another value to obtain the result.

[Example of ladder diagram]

X0
0 MOVP K1000 D2

X0 S D
3 -P K10 D2 (Note 1)

X1 S1 S2 D
7 -P D2 K50 D3 (Note 2)

(Note 1) Every time the input condition is turned on, the content of the device specified in S is
subtracted from the device specified in D and the result is stored in the device specified in
D .

D S D
D2 - (10) D2
(Input condition)
First ON 1000 - 10 990
(example)
Second ON 990 - 10 980
Third ON 980 - 10 970
The content of
D2 is changed.

(Note 2) When the input condition is turned on, the content of the device specified in S2 is
subtracted from the content of the device specified in S1 and the result is stored in the
device specified in D .

S1 S2 D
D2 - (50) D3
(Input condition)
ON 970 - 50 920
(example)

The content of D2 is not changed.

NOTE
• +P or -P must be used for the addition or subtraction instructions.
• When + or - is used, an addition or subtraction operation is
executed every scanning. To use + or - , operands must be
converted into pulse in advance.
X0 X0
+P K5 D0 PLS M0
M0
+ K5 D0

2-18
Reference

SUB(P) Subtraction : BIN 16-bit subtraction


(Use this instruction only for FX-series programmable controllers.)

[Function and operation]


The contents of S 2 a re subtracted from S1 i n binary format, and the result is transferred to D .
Command
input
SUB S1 S2 D
S1 - S2 D

(* The operation is the same as [- S1 S2 D] for the Q and L series.)

NOTE
• The same device number can be specified as source S 1 a nd destination D .
In this case, note that the addition result changes in every operation cycle if a continuous operation
type instruction (- or SUB) is used.

X1
- (D0) - 25 (D0)
D0 K25 D0

X001
(D0) - 25 (D0)
SUB D0 K25 D0

2-19
* (P) Asterisk : BIN 16-bit data multiplication
(For FX-series programmable controllers, use the MUL instruction. Refer to the reference on the next
page.)
/ (P) Slash : BIN 16-bit data division
(For FX-series programmable controllers, use the DIV instruction. Refer to the reference on the next
page.)

[Overview]
This instruction multiplies two values to obtain the result.
This instruction divides a value by another value to obtain the result.

[Example of ladder diagram]


X0
0 MOVP K2000 D0

X1 S1 S2 D
3 *P K30 D0 D10 (Note 1)

X2 S1 S2 D
7 /P D0 K600 D20 (Note 2)

(Note 1) When the input condition is turned on, the content of the device specified in S1 is multiplied by
the content of the device specified in S2 and the result is stored in the device specified in D .

S1 S2 D
K30 D0 D11 D10
30 2000 = 60000

To store the result of 16-bit data ~ 16-bit This device is regarded as a 32-bit register to
data, 16 bits (1 word) is not enough. hold the result. Left-most bit of D10 (B15) is not
Thus, D10 and D11, which is the next device a bit to determine positive and negative.
number, work as the holder of the result. It is regarded as a part of the data.

(Note 2) When the input condition is turned on, the content of the device specified in S1 is divided by
the content of the device specified in S2 and the result is stored in the device specified in D .

S1 S2 D
D0 K600 D21 D20
2000 600 = 200 3
Remainder
Quotient

The remainder is stored to D21, which and The quotient is stored to D20, which is specified
is the next device number. in the program.

• Values after the decimal point of the operation result are ignored.
• When a bit device is specified in D , the quotient is stored, but the remainder is not stored.

2-20
Reference

MUL(P) Multiplication : BIN 16-bit data multiplication


DIV(P) Division : BIN 16-bit data division
(Use this instruction only for FX-series programmable controllers.)

[Function and operation]


• MUL(P): The contents of S 1 a re multiplied by S2 i n binary format, and the multiplication result is
transferred to 32-bit [ D + 1, D ].
Command
input
MUL S1 S2 D ( S1 ) × ( S2 ) ( D +1, D )
16 bits 16 bits 32 bits

(* The operation is the same as [* S1 S2 D] for the Q and L series.)

• DIV(P): The contents of S 1 a re divided by S 2 i n binary format, and the quotient is transferred to D ,
and the remainder is transferred to D +1.
Dividend Divisor Quotient Remainder
DIV S1 S2 D ( S1 ) ÷ ( S2 ) ( D ) ... ( D +1 )
16 bits 16 bits 16 bits 16 bits

(* The operation is the same as [/ S1 S2 D] for the Q and L series.)

2-21

You might also like