The text of a manual · part 35 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 323 to 332
Pages 323 to 332 of 592, from DL205 PLC User Manual, Volume 1 of 2
The original document is the PDF (13 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the PLC Direct D2-08ND3 and Koyo D2-08ND3
Page 323
Chapter 5: Standard RLL Instructions - Math
Add Binary (ADDB) The Add Binary instruction adds a 16-bit number (Aaaa) to
230 the value stored in the accumulator. The number in the ADDB 240 accumulator can be up to 32 bits long. The source of the A aaa 250-1 16-bit operand can be a constant or a data value located in Add Binary performs the addition operation on 260 V-memory. the full binary representation of the operands, which distinguishes it from the Add DS Used HPP Used instruction (see page 5-88), which treats the operands as BCD numbers. Although the addition operation is performed on the underlying binary values, the native display format is hexadecimal. For that reason you will need to load constants in hex. The sum of the Add Binary operation occupies the full 32-bit accumulator and requires an Out Double to move the sum to V-memory. If the value in the accumulator occupies fewer than 32 bits, leading zeros are loaded in the left-most empty bit positions. Operand Data Type
DL250-1 Range
V-memory Pointer Constant.
DL260 Range
A aaa aaa
V P K
All (See page 3 - 55) All V mem (See page 3 - 55) 0-FFFF
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFF
Discrete Bit Flags
Description
SP63 SP66 SP67 SP70 SP73
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit addition instruction results in a carry. On when the 32-bit addition instruction results in a carry. On anytime the value in the accumulator is negative On when a signed addition or subtraction results in an incorrect sign bit.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X1 is on, the value in V1400 will be loaded into the accumulator using the Load instruction. The binary value in V1420 is added to the binary value in the accumulator using the Add Binary instruction. The value in the accumulator is copied to V1500 - V1501 using the Out Double instruction. Use either V-memory
DirectSOFT
OR
Constant V1400
X1
0
LD
LD
A
0
5
K2565
V1400 Load the value in V1400 into the lower 16 bits of the accumulator
The unused accumulator bits are set to zero 0 0 0 0 0
BIN
+
ADDB V1420
Acc.
A
0
5
(Accumulator)
A05 (Hex) = 2565 (decimal)
1
2
C
4
(V1420)
12C4 (Hex) = 4804 (decimal)
1
C
C
9
(Accumulator) 1CC9 (Hex) = 7369 (decimal)
C
C
9
The binary value in the accumulator is added to the binary value in V1420 OUTD V1500
1
V1500
Copy the value in the lower 16bits of the accumulator to V1500 and V1501
Handheld Programmer Keystrokes STR
1
E NT
SHFT
L
D
1
4
SHFT
A
D
D
B
OUT
SHFT
D
1
0
5
0
ENT
1
4
2
0
0
ENT
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
ENT
DL205 User Manual, 4th Edition, Rev. A
5–101
Page 324
Chapter 5: Standard RLL Instructions - Math
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Add Binary Double (ADDBD) Binary Double is a 32-bit instruction that adds the binary 230 Add value in the accumulator with the value (Aaaa), which is either 240 two consecutive V-memory locations or an 8-digit (max.) binary 250-1 constant. The result resides in the accumulator. 260 Operand Data Type
DS Used HPP Used
V-memory Pointer Constant.
DL260 Range
A aaa
V P K
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFFFFFF
Discrete Bit Flags
Description
SP63 SP66 SP67 SP70 SP73
5–102
ADDBD A aaa
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit addition instruction results in a carry. On when the 32-bit addition instruction results in a carry. On anytime the value in the accumulator is negative On when a signed addition or subtraction results in an incorrect sign bit.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The binary value in the accumulator is added with the binary value in V1420 and V1421 using the Add Binary Double instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. Use either V-memory
DirectSOFT X1
OR
Constant V1401
LDD
LDD K2561
V1400 Load the value in V1400 and V1401 into the accumulator
BIN
ADDBD
V1400
0
0
0
0
0
A
0
1
0
0
0
0
0
A
0
1
(Accumulator)
+ 1
0
0
0
C
0
1
0
(V1421 and V1420)
1
0
0
0
C
A
1
1
1
0
0
0
C
A
1
1
Acc.
V1420 The binary value in the accumulator is added with the value in V1420 and V1421 OUTD V1501
V1500
V1500
Copy the value in the accumulator to V1500 and V1501 Handheld Programmer Keystrokes STR
1
LD
SHFT
D
SHFT
1
4
0
0
ADD
SHFT
B
D
SHFT
1
4
2
OUT
SHFT
D
SHFT
1
5
0
0
DL205 User Manual, 4th Edition, Rev. A
0
Page 325
Chapter 5: Standard RLL Instructions - Math
Subtract Binary (SUBB)
SUBB
1 2 instruction (see page 5-91), which treats the operands as BCD numbers. Although the 3 subtraction operation is performed on the underlying binary values, the native display format is hexadecimal. For that reason you will need to load constants in hex. 4 The difference (result) of the Subtract Binary operation occupies the full 32 bits of the accumulator and requires an Out Double to move the value to V-memory. If the value in the 5 accumulator occupies fewer than 32 bits, leading zeros are loaded in the left-most empty bit positions of the accumulator. 6 Operand Data Type DL250-1 Range DL260 Range A aaa aaa 7 8 Discrete Bit Flags Description 9 10 NOTE: Status flags are valid only until another instruction uses the same flag. 11 In the following example, when X1 is on, the value in V1400 will be loaded into the accumulator using the Load instruction. The binary value in V1420 is subtracted from the 12 binary value in the accumulator using the Subtract Binary instruction. The value in the accumulator is copied to V1500 - V1501 using the Out Double instruction. 13 14 A B C D
Subtract Binary instruction subtracts a 16-bit number (Aaaa) A aaa 230 The from the value stored in the accumulator. The number in the 240 accumulator can be up to 32 bits long. The source of the 16-bit operand can be a constant or 250-1 a data value located in V-memory. Subtract Binary performs the subtraction operation on the 260 full binary representation of the operands, which distinguishes it from the Subtract DS Used HPP Used
V-memory Pointer Constant
SP63 SP64 SP65 SP70
V P K
All (See page 3 - 55) All V mem (See page 3 - 55) 0-FFFF
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFF
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit subtraction instruction results in a borrow. On when the 32-bit subtraction instruction results in a borrow. On anytime the value in the accumulator is negative.
DirectSOFT
Use either V-memory
X1
OR
Constant
LD
LD
K1024
V1400
Load the value in V1400 into the lower 16 bits of the accumulator
1
BIN
SUBB
The unused accumulator bits are set to zero 0 0 0 0 1
V1420
The binary value in V1420 is subtracted from the value in the accumulator
-
Acc.
V1400 0 2
4
0
2
4
(Accumulator) 1024 (Hex) = 4132 (decimal)
0
A 0
B
(V1420)
0
6
1
9
(Accumulator) 619 (Hex) = 1561 (decimal)
0
6
1
9
A0B (Hex) = 2571 (decimal)
OUT
V1500
Copy the value in the lower 16 bits of the accumulator to V1500
V1500
Handheld Programmer Keystrokes STR
1
ENT
SHFT
L
D
1
4
0
SHFT
S
SHFT
U
B
B
1
4
2
0
ENT
OUT
SHFT
1
5
0
0
ENT
0
ENT
DL205 User Manual, 4th Edition, Rev. A
5–103
Page 326
Chapter 5: Standard RLL Instructions - Math
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Subtract Binary Double (SUBBD) Binary Double is a 32-bit instruction that subtracts 230 Subtract the binary value (Aaaa), which is either two consecutive 240 V-memory locations or an 8-digit (max.) binary constant, 250-1 from the binary value in the accumulator. The result resides in 260 the accumulator. Operand Data Type
DS Used HPP Used
DL260 Range
V-memory Pointer Constant
A aaa
V P K
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFFFFFF
Discrete Bit Flags
Description
SP63 SP64 SP65 SP70
5–104
SUBBD A aaa
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit subtraction instruction results in a borrow. On when the 32-bit subtraction instruction results in a borrow. On anytime the value in the accumulator is negative.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X1 is on, the value in V1400 and V1401 will be loaded into the accumulator using the Load Double instruction. The binary value in V1420 and V1421 is subtracted from the binary value in the accumulator using the Subtract Binary Double instruction. The value in the accumulator is copied to V1500 and V1501 using the Out Double instruction. Use either V-memory
DirectSOFT
X1
OR
Constant
LDD K393471
LDD V1400 Load the value in V1400 and V1401 into the accumulator
0
V1401 0 0 6
0
V1400 0 F F
BIN
SUBBD V1420
0
0
0
6
0
0
F
F
(Accumulator)
-
0
0
0
0
1
A
0
1
(V1421 and V1420)
Acc.
0
0
0
5
E 6
F
E
0
0
0
5
E 6
F
E
The binary value in V1420 and V1421 is subtracted from the binary value in the accumulator OUTD V1500
V1500
V1501
Copy the value in the accumulator to V1500 and V1501 Handheld Programmer Keystrokes 1
ENT
SHFT
STR L
D
D
SHFT
S
SHFT
U
B
1
4
2
0
ENT
OUT
SHFT
D
1
DL205 User Manual, 4th Edition, Rev. A
1
4
B
D
5
0
0
0
0
ENT
ENT
Page 327
Chapter 5: Standard RLL Instructions - Math
Multiply Binary (MULB)
1 2 representation of the operands, which distinguishes it from the Multiply instruction (see page 3 5-94), which treats the operands as BCD numbers. Although the multiplication operation is performed on the underlying binary values, the native display format is hexadecimal. For that 4 reason you will need to load constants in hex. The product of the Multiply Binary operation occupies the full 32-bit accumulator and 5 requires an Out Double to move the product to V-memory. If the value in the accumulator occupies fewer than 32 bits, leading zeros are loaded in the left-most empty bit positions. 6 Operand Data Type DL250-1 Range DL260 Range A aaa aaa 7 8 Discrete Bit Flags Description 9 NOTE: Status flags are valid only until another instruction uses the same flag. 10 In the following example, when X1 is on, the value in V1400 will be loaded into the 11 accumulator using the Load instruction. The binary value in V1420 is multiplied by the binary value in the accumulator using the Multiply Binary instruction. The value in the accumulator is copied to V1500 - V1501 using the Out Double instruction. 12 13 14 A B C D
Multiply Binary instruction multiplies a 16-bit number MULB 230 The A(aaa) by the value stored in the accumulator. The number A aaa 240 in the accumulator can be up to 32 bits long. The source of 250-1 the 16-bit operand can be a constant or a data value located 260 in V-memory. Multiply Binary performs the multiplication operation on the full binary DS Used HPP Used
V-memory Pointer Constant
SP63 SP70
V P K
All (See page 3 - 55) All V mem (See page 3 - 55) 0-FFFF
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFF
On when the result of the instruction causes the value in the accumulator to be zero. On anytime the value in the accumulator is negative.
Use either V-memory
DirectSOFT X1
OR
Constant
V1400
LD
LD
V1400
0
A
0
1
0
A 0
1
(Accumulator)
A01 (Hex) = 2561 (decimal)
0
0
2
E
(V1420)
2E (Hex) = 46 (decimal)
K2561
Load the value in V1400 into the lower 16 bits of the accumulator
BIN
The unused accumulator bits are set to zero 0 0 0 0
MULB x
V1420
Acc.
The binary value in V1420 is multiplied by the binary value in the accumulator OUTD V1500
0
0
0
1
C
C
2
E
(Accumulator) 1CC2E (Hex) = 117806 (decimal)
0
0
0
1
C
C
2
E
(V1500 - V1501 value = 117806 decimal)
Copy the value of the accumulator to V1500 and V1501
V1501
V1500
Handheld Programmer Keystrokes STR
1
ENT
SHFT
L
D
1
4
SHFT
M
U
L
B
OUT
SHFT
D
1
0
5
0
ENT
1
4
2
0
0
ENT
0
ENT
DL205 User Manual, 4th Edition, Rev. A
5–105
Page 328
Chapter 5: Standard RLL Instructions - Math
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Divide Binary (DIVB) Divide Binary instruction divides a 16-bit number DIVB 230 The (Aaaa) into the value stored in the accumulator. The A aaa 240 number in the accumulator can be up to 32 bits long. The 250-1 source of the 16-bit divisor can be a constant or a data 260 value located in V-memory. Divide Binary performs the division operation on the full binary DS Used HPP Used representation of the operands, which distinguishes it from the Divide instruction (see page 5-97), which treats the operands as BCD numbers. Although the division operation is performed on the underlying binary values, the native display format is hexadecimal. For that reason you will need to load constants in hex. At the completion of the division operation, the quotient resides in the accumulator and the remainder resides in the first stack location. The quotient occupies the full 32-bit accumulator and requires an Out Double to move the quotient to V-memory. If the value in the accumulator occupies fewer than 32 bits, leading zeros are loaded in the left-most empty bit positions. Operand Data Type DL250-1 Range DL260 Range
V-memory Pointer Constant
A aaa aaa
V P K
All (See page 3 - 55) All V mem (See page 3 - 55) 0-FFFF
All (See page 3 - 56) All V mem (See page 3 - 56) 0-FFFF
Discrete Bit Flags
Description
SP53 SP63 SP70
5–106
On when the value of the operand is larger than the accumulator can work with. On when the result of the instruction causes the value in the accumulator to be zero. On anytime the value in the accumulator is negative.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X1 is on, the value in V1400 will be loaded into the accumulator using the Load instruction. The binary value in the accumulator is divided by the binary value in V1420 using the Divide Binary instruction. The value in the accumulator is copied to V1500 using the Out Double instruction. Use either V-memory
DirectSOFT
X1
OR
Constant
V1400 LD V1400 Load the value in V1400 into the lower 16 bits of the accumulator
LDD K64001
F
A
0
1
F
A 0
1
(Accumulator) FA01 (Hex) = 64001 (decimal)
0
0
5
0
(V1420)
50 (Hex) = 80 (decimal)
0
3
2
0
(Accumulator)
320 (Hex) = 800 (decimal)
The unused accumulator bits are set to zero
BIN
0
0
0
0
_.. DIVB 0
V1420
0
0
0
0
The binary value in the accumulator is divided by the binary value in V1420
0
0
0
0
0
0
1
1 (Hex) = 1 (decimal)
Top of stack holds remainder 0
OUT
0
0
0
0
V1501
3
2
0
V1500
V1500 Copy the value in the lower 16 bits of the accumulator to V1500
Handheld Programmer Keystrokes STR
1
ENT
SHFT
L
D
1
4
SHFT
D
I
V
B
OUT
SHFT
V
1
DL205 User Manual, 4th Edition, Rev. A
0
5
0
ENT
1
4
2
0
0
ENT
0
ENT
Page 329
Chapter 5: Standard RLL Instructions - Math
Increment Binary (INCB) Increment Binary instruction increments a binary value 230 The in a specified V-memory location by “1” each time the 240 instruction is executed. 250-1 260
INCB A aaa
DS Used HPP Used
Operand Data Type
DL230 Range
DL240 Range
DL250-1 Range
A aaa aaa aaa aaa
V-memory
V
All (See page 3 - 53)
Pointer
P
-
All (See page 3 - 54) All V-memory (See page 3 - 54)
All (See page 3 - 55) All V-memory (See page 3 - 55)
All (See page 3 - 56) All V-memory (See page 3 - 56)
Discrete Bit Flags SP63
DL260 Range
Description On when the result of the instruction causes the value in the accumulator to be zero.
NOTE: The status flags are only valid until another instruction that uses the same flags is executed.
In the following example when C5 is on, the binary value in V2000 is increased by 1.
DirectSOFT C5
V2000 4
INCB
A
3
Handheld Programmer Keystrokes C
$ STR
V2000
SHFT
Increment the binary value in V2000 by “1”
I 8
SHFT
C
N TMR
C
F 2
5 B
2
ENT C
1
A 2
A 0
A 0
V2000 4
A
3
D
DL205 User Manual, 4th Edition, Rev. A
0
ENT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–107
Page 330
Chapter 5: Standard RLL Instructions - Math
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Decrement Binary (DECB) Decrement Binary instruction decrements a binary 230 The value in a specified V-memory location by “1” each time the 240 instruction is executed. 250-1 260
DECB A aaa
DS Used HPP Used
Operand Data Type
DL230 Range
DL240 Range
DL250-1 Range
A aaa aaa aaa aaa
V-memory
V
All (See page 3 - 53)
Pointer
P
-
All (See page 3 - 54) All V-memory (See page 3 - 54)
All (See page 3 - 55) All V-memory (See page 3 - 55)
All (See page 3 - 56) All V-memory (See page 3 - 56)
Discrete Bit Flags SP63
DL260 Range
Description On when the result of the instruction causes the value in the accumulator to be zero.
NOTE: The status flags are only valid until another instruction that uses the same flag is executed.
In the following example when C5 is on, the value in V2000 is decreased by 1.
DirectSOFT
5–108
C5
V2000 4
A
? 3
Handheld Programmer Keystrokes C $
DECB
STR
V2000
SHFT
Decrement the binary value in V2000 by “1”
V2000 4
A
? 3
SHFT
P
D
E 3
B
DL205 User Manual, 4th Edition, Rev. A
D CV C 4
SHFT
3 B 2
C
F 2
C 1
5 A
2
ENT A
0
A 0
0
ENT
Page 331
Chapter 5: Standard RLL Instructions - Math
Add Formatted (ADDF) Formatted is a 32-bit instruction that adds the BCD value 230 Add in the accumulator with the BCD value (Aaaa) which is a range 240 of discrete bits. The specified range (Kbbb) can be 1 to 32 250-1 consecutive bits. The result resides in the accumulator. 260 Operand Data Type
DS Used HPP Used
Inputs Outputs Control Relays Stage Bits Timer Bits Counter Bits Special Relays Global I/O Constant
A aaa ADDF K bbb
DL260 Range A aaa bbb
X Y C S T CT SP GX/GY K
0-1777 0-1777 0-3777 0-1777 0-377 0-377 0-777 0-3777 -
1-32
Discrete Bit Flags
Description
SP63 SP66 SP67 SP70 SP75
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit addition instruction results in a carry. On when the 32-bit addition instruction results in a carry. On anytime the value in the accumulator is negative. On when a BCD instruction is executed and a NON-BCD number was encountered.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X6 is on, the value formed by discrete locations X0–X3 is loaded into the accumulator using the Load Formatted instruction. The value formed by discrete locations C0–C3 is added to the value in the accumulator using the Add Formatted instruction. The value in the lower four bits of the accumulator is copied to Y10–Y13 using the Out Formatted instruction. DirectSOFT X6
LDF
X0
Load the BCD value represented by discrete locations X0–X3 into the accumulator
C0
Add the BCD value in the accumulator with the value represented by discrete location C0–C3
K4
X3 X2 X1 X0 ON OFF OFF OFF
The unused accumulator bits are set to zero ADDF K4
OUTF
Y10 K4
0
0
0
0
0
0
0
+ Acc.
0
0
0
1
0
0
0
8
(Accumulator)
C3
3
(C0-C3)
OFF OFF ON ON
C2
1
Copy the lower 4 bits of the accumulator to discrete locations Y10–Y13
Handheld Programmer Keystrokes $
G STR
6
SHFT
L ANDST
D
SHFT
A
D
GX OUT
SHFT
OFF OFF OFF ON
F 3
A
F
F 3
4 NEXT
5 B
5
E 0
5 D
3
0
Y13 Y12 Y11 Y10
ENT
A 1
0
ENT
NEXT
NEXT
E
ENT
4
NEXT
A
E 0
4
ENT
DL205 User Manual, 4th Edition, Rev. A
C1
C0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–109
Page 332
Chapter 5: Standard RLL Instructions - Math
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Subtract Formatted (SUBF) Subtract Formatted is a 32-bit instruction that subtracts the BCD value (Aaaa), which is a range of discrete bits, from the BCD value in the accumulator. The specified range (Kbbb) can be 1 to 32 consecutive bits. The result resides in the accumulator.
230 240 250-1 260 DS Used HPP Used
Operand Data Type Inputs Outputs Control Relays Stage Bits Timer Bits Counter Bits Special Relays Global I/O Constant
DL260 Range A aaa bbb
X Y C S T CT SP GX/GY K
0-1777 0-1777 0-3777 0-1777 0-377 0-377 0-777 0-3777 -
1-32
Discrete Bit Flags
Description
SP63 SP64 SP65 SP70 SP75
5–110
SUBF A aaa K bbb
On when the result of the instruction causes the value in the accumulator to be zero. On when the 16-bit subtraction instruction results in a borrow. On when the 32-bit subtraction instruction results in a borrow. On anytime the value in the accumulator is negative. On when a BCD instruction is executed and a NON-BCD number was encountered.
NOTE: Status flags are valid only until another instruction uses the same flag.
In the following example, when X6 is on, the value formed by discrete locations X0–X3 is loaded into the accumulator using the Load Formatted instruction. The value formed by discrete location C0–C3 is subtracted from the value in the accumulator using the Subtract Formatted instruction. The value in the lower four bits of the accumulator is copied to Y10–Y13 using the Out Formatted instruction. DirectSOFT X3 X6
LDF
X0 K4
SUBF
C0 K4
Load the BCD value represented by discrete locations X0-X3 into the accumulator
Y10 K4
X1
X0
The unused accumulator bits are set to zero
Subtract the BCD value represented by C0-C3 from the value in the accumulator
0
0
0
0
0
0
0
_ ACC. 0
OUTF
X2
ON OFF OFF ON
0
0
0
0
0
0
9
(Accumulator)
C3
8
(C0- C3)
ON OFF OFF OFF
1
Copy the lower 4 bits of the accumulator to discrete locations Y10- Y13
Handheld Programmer Keystrokes Y13 Y12 Y11 Y10 $
G STR
6
SHFT
L ANDST
D
SHFT
S RST
SHFT
GX OUT
SHFT
F
ENT
OFF OFF OFF ON
F 3
A B
F 1
ISG B
5
4
0
5 U
E
5 A
1
0
ENT
NEXT
NEXT
E
ENT
4
DL205 User Manual, 4th Edition, Rev. A
NEXT
NEXT
A
E 0
4
ENT
C2
C1
C0