The text of a manual · part 39 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 363 to 372
Pages 363 to 372 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 363
Chapter 5: Standard RLL Instructions - Number Conversion
Gray Code (GRAY)
1 2 will directly convert a gray code number to a BCD number for 3 devices having a resolution of 512 or 1024 counts per revolution. If a device having a resolution of 360 counts per 4 revolution is to be used you must subtract a BCD value of 76 from the converted value to obtain the proper result. For a device having a resolution of 720 counts per revolution you 5 must subtract a BCD value of 152. In the following example, when X1 is ON the binary value represented by X10–X27 is loaded 6 into the accumulator using the Load Formatted instruction. The gray code value in the accumulator is converted to BCD using the Gray Code instruction. The value in the lower 16 7 bits of the accumulator is copied to V2010. 8 9 10 11 12 13 14 A B C D
Gray code instruction converts a 16-bit gray code value to 230 The a BCD value. The BCD conversion requires 10 bits of the 240 accumulator. The upper 22 bits are set to “0”. This instruction 250-1 is designed for use with devices (typically encoders) that use 260 the grey code numbering scheme. The Gray Code instruction DS Used HPP Used
DirectSOFT X1
LDF
K16
GRAY
X27 X26 X25
X12 X11 X10
OFF OFF OFF
ON OFF ON
X10
Load the value represented by X10–X27 into the lower 16 bits of the accumulator
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
GRAY
Convert the 16 bit grey code value in the accumulator to a BCD value
Acc.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
0
0
0
0
0
0
1
1
0
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
OUT
V2010
Copy the value in the lower 16 bits of the accumulator to V2010
Handheld Programmer Keystrokes $
B
STR SHFT SHFT GX OUT
1
L ANDST G 6
D
ENT
F
B
5
3
R ORN
A
SHFT
V AND
0
A
0
1
Y MLS
ENT
C
A
2
B
B
0
1
A
1
G
0
ENT
6
ENT
Gray Code
BCD
0000000000
0000
0000000001
0001
0000000011
0002
0000000010
0003
0000000110
0004
0000000111
0005
0000000101
0006
0000000100
0007
• •
• •
•
•
1000000001
1022
1000000000
1023
V2010
DL205 User Manual, 4th Edition, Rev. A
5–141
Page 364
Chapter 5: Standard RLL Instructions - Number Conversion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Shuffle Digits (SFLDGT) Shuffle Digits instruction shuffles a maximum of 8 digits 230 The rearranging them in a specified order. This function requires 240 parameters to be loaded into the first level of the accumulator 250-1 stack and the accumulator with two additional instructions. 260 Listed below are the steps necessary to use the shuffle digit
SFLDGT function. The example on the following page shows a program for the Shuffle Digits function.
DS Used HPP Used
5–142
Step 1: Load the value (digits) to be shuffled into the first level of the accumulator stack. Step 2: Load the order that the digits will be shuffled to into the accumulator. Step 3: Insert the SFLDGT instruction. NOTE: If the number used to specify the order contains a 0 or 9–F, the corresponding position will be set to 0.
See example on the next page. NOTE: If the number used to specify the order contains duplicate numbers, the most significant duplicate number is valid. The result resides in the accumulator.
Shuffle Digits Block Diagram
Digits to be shuffled (first stack location)
There are a maximum of 8 digits that can be shuffled. The bit positions in the first level of the accumulator stack defines the digits to be shuffled. They correspond to the bit positions in the accumulator that define the order the digits will be shuffled. The digits are shuffled and the result resides in the accumulator.
9
A
B
C D
E
F
0
1
2
8
7
6
5
4
3
Specified order (accumulator)
Bit Positions
8
7
6
5
4
3
2
1
B
C
E
F
0
D
A
9
Result (accumulator)
DL205 User Manual, 4th Edition, Rev. A
Page 365
Chapter 5: Standard RLL Instructions - Number Conversion In the following example when X1 is on, The value in the first level of the accumulator stack will be reorganized in the order specified by the value in the accumulator. Example A shows how the shuffle digits works when 0 or 9 –F is not used when specifying the order the digits are to be shuffled. Also, there are no duplicate numbers in the specified order. Example B shows how the shuffle digits works when a 0 or 9–F is used when specifying the order the digits are to be shuffled. Notice when the Shuffle Digits instruction is executed, the bit positions in the first stack location that had a corresponding 0 or 9–F in the accumulator (order specified) are set to “0”. Example C shows how the shuffle digits works when duplicate numbers are used specifying the order the digits are to be shuffled. Notice when the Shuffle Digits instruction is executed, the most significant duplicate number in the order specified is used in the result.
Direct SOFT X1
A V2001
LDD 9
Load the value in V2000 and V2001 into the accumulator
B
Original 8 7 6 5 bit Positions 9 A B C
4
3
2
1
D
E
F
0
3
6
V2007 1
V2006
SFLDGT
Specified order
New bit Positions
2
8
E
F
0
0
Acc.
F
5
E
V2000 C
B
A
9
8 7 6 5 0 F E D
4 C
3 B
2 A
1 9
3
0
0
2
1
V2007 4
8
7
6
5
4
3
2
1
1
2
8
7
3
6
5
4
8
7
6
5
4
3
2
1
B
C
E
F
0
D
A
9
B
C
E
F
0
D
A
9
V2001
D
V2006 7
C
V2001
D
LDD
Load the value in V2006 and V2007 into the accumulator
B V2000
C
V2000
A
0
0
4
9
Acc.
A
B
V2000 C
D
E
F
0
8
7
6
5
4
3
2
1
9
A
B
C
D
E
F
0
4
3
1
4
3
2
1
V2006
V2007 2
V2006
8
7
6
5
4
3
2
1
8
7
6
5
4
3
2
1
Acc.
0
0
4
3
0
0
2
1
Acc.
4
3
2
1
4
3
2
1
8 7 6 5 0 0 0 0
4 E
3 D
2 A
1 9
8
7
6
5
4
3
2
1
Acc.
Acc.
0
0
0
0
9
A
B
C
0
E
D
A
9
0
0
0
0
9
A
B
C
Shuffle the digits in the first level of the accumulator stack based on the pattern in the accumulator. The result is in the accumulator. OUTD
0
0
0
V2010 V2010
V2011
V2011
V2011
V2010
V2010
Copy the value in the accumulator to V2010 and V2011
Handheld Programmer Keystrokes $
B 1
STR SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
S RST
SHFT
GX OUT
SHFT
D
ENT D
3
C 3
3
3
A
C 3
F 5
A 2
L ANDST
D
C
A 2
A 0
2
D
0
6
6
T MLR
ENT
A
ENT
B 0
0 G
0 G
3
A 0
A
1
0
Acc.
ENT ENT
DL205 User Manual, 4th Edition, Rev. A
Acc.
Acc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–143
Page 366
Chapter 5: Standard RLL Instructions - Table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Table Instructions Move (MOV) The Move instruction moves the values from a V-memory
230 table to another V-memory table the same length. The 240 function parameters are loaded into the first level of the 250-1 accumulator stack and the accumulator by two additional Listed below are the steps necessary to program 260 instructions. the Move function. DS Used HPP Used
MOV V aaa
Step 1: Load the number of V-memory locations to be moved into the first level of the accumulator stack. This parameter is a HEX value (KFFF max, 7777 octal). Step 2: Load the starting V-memory location for the locations to be moved into the accumulator. This parameter must be a HEX value. Step 3: Insert the MOVE instruction which specifies starting V-memory location (Vaaa) for the destination table.
Helpful hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. Operand Data Type
DL230 Range aaa aaa aaa aaa
V-memory
All (See page 3 - 53)
All (See page 3 - 54)
All (See page 3 - 55)
All (See page 3 - 56)
5–144
V
DL240 Range
DL250-1 Range
DL260 Range
In the following example, when X1 is on, the constant value (K6) is loaded into the accumulator using the Load instruction. This value specifies the length of the table and is placed in the first stack location after the Load Address instruction is executed. The octal address 2000 (V2000), the starting location for the source table is loaded into the accumulator. The destination table location (V2030) is specified in the Move instruction. X1
LD K6
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
O 2000
Convert octal 2000 to HEX 400 and load the value into the accumulator
LDA
Copy the specified table locations to a table beginning at location V2030
MOV V2030 Handheld Programmer Keystrokes $
B STR
1
ENT
SHFT
L ANDST
D
SHFT
L ANDST
D 3
0
SHFT
M ORST
O INST#
V AND
SHFT
3 A
K JMP
G
C
A
6
2 C
A 0
A 2
ENT A 0 D
0
0 A
3
DL205 User Manual, 4th Edition, Rev. A
0
ENT ENT
X
X
X
X V1776
X
X
X
X V2026
X
X
X
X V1777
X
X
X
X V2027
0
1
2
3 V2000
0
1
2
3 V2030
0
5
0
0 V2001
0
5
0
0 V2031
9
9
9
9 V2002
9
9
9
9 V2032
3
0
7
4 V2003
3
0
7
4 V2033
8
9
8
9 V2004
8
9
8
9 V2034
1
0
1
0 V2005
1
0
1
0 V2035
X
X
X
X V2006
X
X
X
X V2036
X
X
X
X V2007
X
X
X
X V2037
Page 367
Chapter 5: Standard RLL Instructions - Table
Move Memory Cartridge (MOVMC) Load Label (LDLBL)
1 The Move Memory Cartridge instruction is used to copy data MOVMC between V-memory and program ladder memory. The Load 2
V aaa Label instruction is only used with the MOVMC instruction when copying data from program ladder memory to V-memory.
3 To copy data between V-memory and program ladder memory, the function parameters are loaded into the first two levels of LDLBL 4 the accumulator stack and the accumulator by two additional K aaa instructions. Listed below are the steps necessary to program the Move Memory Cartridge and Load Label functions. 5 Step 1: Load the number of words to be copied into the second level of the accumulator stack. Step 2: Load the offset for the data label area in the program ladder memory and the beginning of the 6 V-memory block into the first level of the accumulator stack. Step 3: Load the source data label (LDLBL Kaaa) into the accumulator when copying data from 7 ladder memory to V-memory. Load the source address into the accumulator when copying data from V-memory to ladder memory. This is where the value will be copied from. If the source address is a V-memory location, the value must be entered in HEX. 8 Step 4: Insert the MOVMC instruction which specifies destination (Aaaa). This is where the value will be copied to. 9 Operand Data Type DL230 Range DL240 Range DL250-1 Range DL260 Range 10 aaa aaa aaa aaa 11 WARNING: The offset for this usage of the instruction starts at 0, but may be any number that does not 12 result in data outside of the source data area being copied into the destination table. When an offset is outside of the source information boundaries, then unknown data values will be transferred into the 13 destination table. 14 A B C D 230 240
250-1 260
DS Used HPP Used
V-memory Constant
V K
All (See page 3 - 53) K1-KFFFF
All (See page 3 - 54) K1-KFFFF
All (See page 3 - 55) K1-KFFFF
All (See page 3 - 56) K1-KFFFF
DL205 User Manual, 4th Edition, Rev. A
5–145
Page 368
Chapter 5: Standard RLL Instructions - Table
Copy Data From a Data Label Area to V-Memory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
230 240 250-1 260 DS Used HPP Used
5–146
In the following example, data is copied from a Data Label Area to V-memory. When X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the table and is placed in the second stack location after the next Load and Load Label (LDLBL) instructions are executed. The constant value (K0) is loaded into the accumulator using the Load instruction. This value specifies the offset for the source and destination data, and is placed in the first stack location after the LDLBL instruction is executed. The source address where data is being copied from is loaded into the accumulator using the LDLBL instruction. The MOVMC instruction specifies the destination starting location and executes the copying of data from the Data Label Area to V-memory. DirectSOFT X1
Data Label Area Programmed After the END Instruction
LD K4
X
X
X
X V1777
1
2
3
4
V2000
4
5
3
2
V2001
6
1
5
1
V2002
8
8
4
5
V2003
X
X
X
X V2004
DLBL K1
Load the value 4 into the accumulator specifying the number of locations to be copied. LD K0 Load the value 0 into the accumulator specifying the offset for source and destination locations LDLBL
N
C O N
K
1
N
C O N
K
4
N
C O N
K
6
N
C O N
K
8
2
3
5
3
1
5
8
4
4
2
1
5
K1 Load the value 1 into the accumulator specifying the Data Label Area K1 as the starting address of the data to be copied. MOVMC V2000 V2000 is the destination starting address for the data to be copied. Handheld Programmer Keystrokes $
B STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
M ORST
ENT SHFT
K JMP
E
SHFT
K JMP
A
B
L ANDST
B
3
L ANDST
O INST#
V AND
M ORST
C
C
3 3
1
2
4 0
ENT ENT
1
ENT A
2
A 0
A 0
0
ENT
WARNING: The offset for this usage of the instruction starts at 0, but may be any number that does not result in data outside of the source data area being copied into the destination table. When an offset is outside of the source information boundaries, then unknown data values will be transferred into the destination table.
DL205 User Manual, 4th Edition, Rev. A
Page 369
Chapter 5: Standard RLL Instructions - Table
Copy Data From V-Memory to a Data Label Area
230 240 250-1 260 DS Used HPP Used
In the following example, data is copied from V-memory to a data label area. When X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the table and is placed in the second stack location after the next Load and Load Address instructions are executed. The constant value (K2) is loaded into the accumulator using the Load instruction. This value specifies the offset for the source and destination data, and is placed in the first stack location after the Load Address instruction is executed. The source address where data is being copied from is loaded into the accumulator using the Load Address instruction. The MOVMC instruction specifies the destination starting location and executes the copying of data from V-memory to the data label area. DirectSOFT X1
Data Label Area Programmed After the END Instruction
LD K4 Load the value 4 into the accumulator specifying the number of locations to be copied. LD K2
X
X
X
X V1777
DLBL K1
1
2
3
4
N
V2000
Offset
C O N
K
7
N
C O N
0
4
K
4
N
C O N
1 Offset
4
Load the value 2 into the accumulator specifying the offset for source and destination locations.
6
5
3
1
5
2
1
V2001
V2002
LDA O 2000 Convert octal 2000 to HEX 400 and load the value into the accumulator. This specifies the source location where the data will be copied from MOVMC
6
1
4
K
6
C O N
5
8
8
4
5
V2003
N K
8
2
5
0
0
V2004
N
C O N
K
2
6
8
3
5
V2005
N
C O N
K
6
X
X
X
X V2006
8
5
8
4
0
3
8
1
5
0
5
K1 K1 is the data label destination area where the data will be copied to
Handheld Programmer Keystrokes B
$
1
STR
ENT
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
L ANDST
D 3
0
SHFT
M ORST
O INST#
V AND
3 3
SHFT
K JMP
E
SHFT
K JMP
C
C
A
A
2 M ORST
C 2
4 2
ENT ENT A
0
A 0
0
SHFT
K JMP
ENT B 1
ENT
WARNING: The offset for this usage of the instruction starts at 0. If the offset (or the specified data table range) is large enough to cause data to be copied from V-memory to beyond the end of the DLBL area, then anything after the specified DLBL area will be replaced with invalid instructions.
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–147
Page 370
Chapter 5: Standard RLL Instructions - Table
Set Bit (SETBIT)
The Set Bit instruction sets a single bit to one within a range SETBIT 1 of V-memory locations. V aaa
2 3 Reset Bit (RSTBIT) The Reset Bit instruction resets a single bit to zero within a 4 RSTBIT range of V-memory locations.
V aaa 5
6 The following description applies to both the Set Bit and Reset Bit table instructions. Step 1: Load the length of the table (number of V-memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. 7 Step 2: Load the starting V-memory location for the table into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. 8 Step 3: Insert the Set Bit or Reset Bit instruction. This specifies the reference for the bit number of the bit you want to set or reset. The bit number is in octal, and the first bit in the table is 9 number “0”. Helpful hint:, Remember that each V-memory location contains 16 bits. So, the bits of the first word of the table are numbered from 0 to 17 octal. For example, if the table length is 6 10 words, then 6 words = (6 x 16) bits, = 96 bits (decimal), or 140 octal. The permissible range of bit reference numbers would be 0 to 137 octal. Flag 53 will be set if the bit specified is 11 outside the range of the table. Operand Data Type DL260 Range 12 aaa 13 Discrete Bit Flags Description 14 A NOTE: Status flags are only valid until the end of the scan or another instruction that uses the same flag is executed. B C D 230 240
250-1 260
230 240
250-1 260
DS Used HPP Used
V-memory
SP53
5–148
V
All (See page 3 - 56)
On when the bit number which is referred in the Set Bit or Reset Bit exceeds the range of the table.
DL205 User Manual, 4th Edition, Rev. A
Page 371
Chapter 5: Standard RLL Instructions - Table For example, supppose we have a table starting at V3000 that is two words long, as shown to the right. Each word in the table contains 16 bits, or 0 to 17 in octal. To set bit 12 in the second word, we use its octal reference (bit 14). Then we compute the bit’s octal address from the start of the table, so 17 + 14 = 34 octal. The following program shows how to set the bit as shown to a “1”.
V3000 MSB
LSB
1 2 3 In this ladder example, we will use input X0 to trigger the Set Bit operation. First, we will 4 load the table length (2 words) into the accumulator stack. Next, we load the starting address into the accumulator. Since V3000 is an octal number we have to convert it to hex by using 5 the LDA command. Finally, we use the Set Bit (or Reset Bit) instruction and specify the octal address of the bit (bit 34), referenced from the table beginning. 6 7 8 9 10 11 12 13 14 A B C D 16 bits
V3001
MSB
LSB
1 1 1 1 11 1 1 7 6 5 4 3 2 1 0 7 6 5 4 32 1 0
DirectSOFT X0
Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator.
LD
K2
Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning.
LDA
O 3000
Set bit 34 (octal) in the table to a ”1”.
SETBIT
O 34
Handheld Programmer Keystrokes $
A
ENT
0
STR
SHFT
L ANDST
D
SHFT
L ANDST
D
X SET
SHFT
PREV
3
A
3
B
2
D
8
ENT
A
3
0
I
1
C
T MLR
NEXT
A
0
D
A
0
E
3
4
0
ENT
ENT
DL205 User Manual, 4th Edition, Rev. A
5–149
Page 372
Chapter 5: Standard RLL Instructions - Table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Fill (FILL)
240 250-1 260 230
DS Used HPP Used
5–150
The Fill instruction fills a table of up to 255 V-memory FILL locations with a value (Aaaa), which is either a V-memory A aaa location or a 4-digit constant. The function parameters are loaded into the first level of the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program the Fill function. Step 1: Load the number of V-memory locations to be filled into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FFFF. Step 2: Load the starting V-memory location for the table into the accumulator. This parameter must be a HEX value. Step 3: Insert the Fill instructions which specifies the value to fill the table with.
Helpful hint:, For parameters that require HEX values when referencing memory locations, the LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. Operand Data Type
DL260 Range A
V-memory Pointer Constant aaa
V All (See page 3 - 56) P All V mem (See page 3 - 56) K 0-FFFF
Discrete Bit Flag
Description
SP53
On if V-memory address is out of range
In the following example, when X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the table and is placed on the first level of the accumulator stack when the Load Address instruction is executed. The octal address 1600 (V1600) is the starting location for the table and is loaded into the accumulator using the Load Address instruction. The value to fill the table with (V1400) is specified in the Fill instruction. DirectSOFT X1
K4
Load the constant value 4 (HEX) into the lower 16 bits of the accumulator
O 1600
Convert the octal address 1600 to HEX 380 and load the value into the accumulator
LD
V1576 LDA
V1577 V1400 2
5
0
0
Fill the table with the value in V1400
FILL V1400
2
5
0
0 V1600
2
5
0
0 V1601
2
5
0
0 V1602
2
5
0
0 V1603 V1604 V1605
Handheld Programmer Keystrokes $
B STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
F
I 5
ENT PREV
3
8
4 B
A 3
E
0 L L ANDST ANDST
ENT G
1
A
A 6
B 1
0
0 E
A 4
DL205 User Manual, 4th Edition, Rev. A
ENT A
0
0
ENT