The text of a manual · part 36 of 68
DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 313 to 322
Pages 313 to 322 of 608, from DL405 User Manual
The original document is the PDF (8.2 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 AutomationDirect D4-08B-1, AutomationDirect D4-08ND3S, AutomationDirect D4-16TA, PLC Direct D4-16TD2, AutomationDirect D4-32ND3-1, Konnect-It D4-08B-1, Koyo D4-08B-1, Konnect-It D4-08ND3S, and 6 more models
Page 313
5--141
Standard RLL Instructions Number Conversion Instructions
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. DirectSOFT
A
X1
V1401
LDD 9
V1400 Load the value in V1400 and V1401 into the accumulator
Original bit Positions
A
B
C
D
V1402 Load the value in V1402 and V1403 into the accumulator
Specified order
New bit Positions
SFLDGT
E
F
V1401 0
8
7
6
5
4
3
2
1
9
A
B
C
D
E
F
0
1
2
7
3
6
V1403
LDD
B V1400
8
0
Acc.
5
E
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
V1403 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
V1401
D
V1402
F
C V1400
0
0
4
9
Acc.
A
B
V1400 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
V1402
V1403
8
7
6
5
4
3
2
1
Acc.
0
0
4
3
0
0
2
1
Acc.
8 7 6 5 0 0 0 0
4 E
3 2 D A
1 9
0
E
D
9
2
Acc.
V1402
8
7
6
5
4
3
2
1
Acc.
4
3
2
1
4
3
2
1
8
7
6
5
4
3
2
1
Acc.
0
0
0
0
9
A
B
C
0
0
0
0
9
A
B
C
Acc.
Acc.
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 V1500
V1501
0
0
V1501
V1500
0
A
V1500
V1501
V1500
Copy the value in the accumulator to V1500 and V1501
Handheld Programmer Keystrokes X(IN)
1
LD
SHFT
D
SHFT
V
1
4
0
0
LD
SHFT
D
SHFT
V
1
4
0
2
SHFT
S
F
L
D
G
T
OUT
SHFT
D
SHFT
V
1
5
0
0
Standard RLL Instructions
STR
DL405 User Manual, 4th Edition
Page 314
5--142
Standard RLL Instructions Table Instructions
Table Instructions The Fill instruction fills a table of up to 255 V--memory locations with a value (Aaaa), which is either a V--memory 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.
Fill (FILL)
430 440 450
DS
HPP
FILL A aaa
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--FF. 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
DL430 Range
DL440 Range
DL450 Range
A aaa aaa aaa
V--memory
V
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Pointer
P
All (See p. 3--40)
All (See p. 3--41)
All (See p. 3--42)
Constant
K
0--FF
0--FF
0--FF
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
LDA
S S
V1400
Standard RLL Instructions
2
5
0
0
Fill the table with the value in V1400
FILL V1400
X
X
X V1576
X
X
X
X V1577
2
5
0
0 V1600
2
5
0
0 V1601
2
5
0
0 V1602
2
5
0
0 V1603
X
X
X
X V1604
X
X
X
X V1605
S S
Handheld Programmer Keystrokes STR
X(IN)
1
LD
K(CON)
4
LD
SHFT
A
OCT
1
6
0
0
SHFT
F
I
L
L
SHFT
V
1
DL405 User Manual, 4th Edition
X
4
0
0
Page 315
Standard RLL Instructions Table Instructions
Find (FIND)
430 440 450
DS
HPP
The Find instruction is used to search for a specified value in a V--memory table of up to 255 locations. The function parameters are loaded into the first and second levels of the accumulator stack and the accumulator by three additional instructions. Listed below are the steps necessary to program the Find function.
5--143
FIND A aaa
Step 1: - Load the length of the table (number of V--memory locations) into the second level of the accumulator stack. This parameter must be a HEX value, 0--FF. Step 2: - Load the starting V--memory location for the table into the first level of the accumulator stack. This parameter must be a HEX value. Step 3: - Load the offset from the starting location to begin the search. This parameter must be a HEX value. Step 4: - Insert the Find instruction which specifies the first value to be found in the table. Results: - The offset from the starting address to the first V--memory location which contains the search value is returned to the accumulator. SP53 will be set on if an address outside the table is specified in the offset or the value is not found. If the value is not found 0 will be returned in the accumulator. The result will be a HEX value. 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
DL440 Range
DL450 Range
A aaa aaa
V--memory
V
All (See p. 3--41)
All (See p. 3--42)
Constant
K
0--FFFF
0--FFFF
Discrete Bit Flags
Description
SP53
ON if there is no value in the table that is equal to the search value.
NOTE: Status flags are only valid until another instruction that uses the same flags is executed. The pointer for this instruction starts at 0 and resides in the accumulator.
DL405 User Manual, 4th Edition
Standard RLL Instructions
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 second stack location when the following Load Address and Load instruction is executed. The octal address 1400 (V1400) is the starting location for the table and is loaded into the accumulator. This value is placed in the first level of the accumulator stack when the following Load instruction is executed. The offset (K2) is loaded into the lower 16 bits of the accumulator using the Load instruction. The value to be found in the table is specified in the Find instruction. If a value is found equal to the search value, the offset (from the starting location of the table) where the value is located will reside in the accumulator.
Page 316
5--144
Standard RLL Instructions Table Instructions
DirectSOFT X1
S S
LD K6 Load the constant value 6 (HEX) into the lower 16 bits of the accumulator LDA O 1400 Convert octal 1400 to HEX 300 and load the value into the accumulator.
Offset Begin here
0
1
2
3 V1400
0
0
5
0
0 V1401
1
9
9
9
9 V1402
2
3
0
7
4 V1403
3
8
9
8
9 V1404
4
1
0
1
0 V1405
X
X
X
X V1406
X
X
X
X V1407
Table length
Accumulator 0
0
0
0
0
0
0
4
V1404 contains the location where the match was found. The value 8989 was the 4th location after the start of the specified table.
5
S S
LD K2 Load the constant value 2 into the lower 16 bits of the accumulator
HPP
X(IN)
1
LD
K(CON)
6
LD
SHFT
A
LD
K(CON)
2
Find the location in the table where the value 8989 resides
SHFT
F
SHFT
K(CON)
Find Greater Than (FDGT)
DS
STR
K8989
FIND
430 440 450
Handheld Programmer Keystrokes
OCT
1
I
N
D
8
9
8
The Find Greater Than instruction is used to search for the first occurrence of a value in a V--memory table that is greater than the specified value (Aaaa), which can be either a V--memory 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 Find Greater Than function.
4
0
0
9
FDGT A aaa
Standard RLL Instructions
NOTE: This instruction does not have an offset, such as the one required for the FIND instruction. Step 1: - Load the length of the table (up to 255 locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0--FF. 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 FDGT instructions which specifies the greater than search value. Results: - The offset from the starting address to the first V--memory location which contains the greater than search value is returned to the accumulator. SP53 will be set on if the value is not found and 0 will be returned in the accumulator. The result will be a HEX value. 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.
DL405 User Manual, 4th Edition
Page 317
5--145
Standard RLL Instructions Table Instructions
Operand Data Type
DL440 Range
DL450 Range
A aaa aaa
V--memory
V
All (See p. 3--41)
All (See p. 3--42)
Constant
K
0--FFFF
0--FFFF
Discrete Bit Flags
Description
SP53 on if there is no value in the table that is greater than the search value.
NOTE: Status flags are only valid until another instruction that uses the same flags is executed. The pointer for this instruction starts at 0 and resides in the accumulator. 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 1400 (V1400) is the starting location for the table and is loaded into the accumulator. The greater than search value is specified in the Find Greater Than instruction. If a value is found greater than the search value, the offset (from the starting location of the table) where the value is located will reside in the accumulator. If there is no value in the table that is greater than the search value, a zero is stored in the accumulator and SP53 will come ON. DirectSOFT X1
LD K6 Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
S S Begin here
LDA
0
1
2
3 V1400
0
Table length
0
5
0
0 V1401
1
O 1400
9
9
9
9 V1402
2
0
Convert octal 1400 to HEX 300 and load the value into the accumulator.
3
0
7
4 V1403
3
8
9
8
9 V1404
4
1
0
1
0 V1405
5
X
X
X
X V1406
V1402 contains the location where the first value greater than the search value was found. 9999 was the 2nd location after the start of the specified table.
X
X
X
X V1407
FDGT K8989
Accumulator 0
0
0
0
0
0
2
S S
Find the value in the table greater than the specified value
Handheld Programmer Keystrokes STR
X(IN)
1
LD
K(CON)
6
LD
SHFT
A
OCT
1
4
0
0
SHFT
F
D
G
T
SHFT
K(CON)
8
9
8
9
Standard RLL Instructions
DL405 User Manual, 4th Edition
Page 318
5--146
Standard RLL Instructions Table Instructions
The Move instruction moves up to 4095 values from a V--memory table to another V--memory table the same length. 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 Move function.
Move (MOV)
430 440 450
DS
HPP
MOV A aaa
Step 1: - Load the number of V--memory locations to be moved into the first level of the accumulator stack. This parameter must be a HEX value, 0--FFF. 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
DL440 Range
DL450 Range
A aaa aaa
V--memory
V
All (See p. 3--41)
All (See p. 3--42)
Pointer
P
All (See p. 3--41)
All (See p. 3--42)
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 1500 (V1500), the starting location for the source table is loaded into the accumulator. The destination table location (V1400) is specified in the Move instruction. DirectSOFT X1
K6
Convert octal 1500 to HEX 340 and load the value into the accumulator
LDA O 1500
Copy the specified table locations to a table beginning at location V1400
MOV V1400
Standard RLL Instructions
S S
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
LD
Handheld Programmer Keystrokes
X
X
X V1476
X
X
X
X V1477
0
1
2
3 V1500
0
1
2
3 V1400
0
5
0
0 V1501
0
5
0
0 V1401
9
9
9
9 V1502
9
9
9
9 V1402
3
0
7
4 V1503
3
0
7
4 V1403
8
9
8
9 V1504
8
9
8
9 V1404
1
0
1
0 V1505
1
0
1
0 V1405
X
X
X
X V1506
X
X
X
X V1406
X
X
X
X V1507
X
X
X
X V1407
S S
STR
X(IN)
1
LD
K(CON)
6
LD
SHFT
A
OCT
1
5
0
0
SHFT
M
O
V
SHFT
V
1
4
DL405 User Manual, 4th Edition
X
0
S S
S S
0
Page 319
Standard RLL Instructions Table Instructions
Table to Destination (TTD)
430 440 450
DS
HPP
The Table To Destination instruction moves a value from a V--memory table to a V-memory location and increments the table pointer by 1. The first V--memory location in the table contains the table pointer which indicates the next location in the table to be moved. The instruction will be executed once per scan provided the input remains on. The table pointer will reset to 1 when the value equals the last location in the table. 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 Table To Destination function.
5--147
TTD Aaaa
Step 1: - Load the length of the data table (number of V--memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. Step 2: - Load the starting V--memory location for the table into the accumulator. (Remember, the starting location of the table is used as the table pointer.) This parameter must be a HEX value. Step 3: - Insert the TTD instruction which specifies destination V--memory location (Vaaa). 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. Helpful Hint: - The instruction will be executed every scan if the input logic is on. If you do not want the instruction to execute for more than one scan, a one shot (PD) should be used in the input logic. Helpful Hint:, The pointer location should be set to the value where the table operation will begin. The special relay SP0 or a one shot (PD) should be used so the value will only be set in one scan and will not affect the instruction operation. Operand Data Type
V--memory
DL440 Range
DL450 Range
A aaa aaa
V
All (See p. 3--41)
All (See p. 3--42)
Discrete Bit Flags
Description
SP56
ON when the table pointer equals the table length.
The pointer for this instruction starts at 0 and resets when the table length is reached. At first glance it may appear that the pointer should reset to 0. However, it resets to 1, not 0.
DL405 User Manual, 4th Edition
Standard RLL Instructions
NOTE: Status flags (SPs) are only valid until:, another instruction that uses the same flag is executed, or, the end of the scan.
Page 320
5--148
Standard RLL Instructions Table Instructions 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 1400 (V1400) is the starting location for the source table and is loaded into the accumulator. Remember, V1400 is used as the pointer location, and is not actually part of the table data source. The destination location (V1500) is specified in the Table to Destination instruction. The table pointer (V1400 in this case) will be increased by “1” after each execution of the TTD instruction. DirectSOFT X1
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
LD K6
Convert octal 1400 to HEX 300 and load the value into the accumulator. This is the table pointer location.
LDA O 1400
Copy the specified value from the table to the specified destination (V1500)
TTD V1500
Standard RLL Instructions
Handheld Programmer Keystrokes STR
X(IN)
1
LD
K(CON)
6
LD
SHFT
A
OCT
1
4
0
0
SHFT
T
T
D
SHFT
V
1
5
It is important to understand how the table locations are numbered. If you examine the example table, you’ll notice that the first data location, V1401, will be used when the pointer is equal to zero, and again when the pointer is equal to six. Why? Because the pointer is only equal to zero before the very first execution. From then on, it increments from one to six, and then resets to one. Also, our example uses a normal input contact (X1) to control the execution. Since the CPU scan is extremely fast, and the pointer increments automatically, the table would cycle through the locations very quickly. If this is a problem, you have an option of using SP56 in conjunction with a one-shot (PD) and a latch (C1 for example) to allow the table to cycle through all locations one time and then stop. The logic shown here is not required, it’s just an optional method.
DL405 User Manual, 4th Edition
0
0
Table
Table Pointer
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
0
0
0
0 V1400
Destination X
X
X
X V1500
S S
DirectSOFT (optional latch example using SP56) X1 C1
C0 PD LD K6 Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
C0
C1 SET
SP56
C1 RST Since Special Relays are reset at the end of the scan, this latch must follow the TTD instruction in the program.
Page 321
Standard RLL Instructions Table Instructions
5--149
The following diagram shows the scan-by-scan results of the execution for our example program. Notice how the pointer automatically cycles from 0 -- 6, and then starts over at 1 instead of 0. Also, notice how SP56 is only on until the end of the scan. Example of Execution Scan N
Before TTD Execution Table
After TTD Execution Table Pointer
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
0
0
0
Table
0 V1400
Destination X
X
X
X V1500
SP56 SP56 = OFF
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
S S
Scan N+1
Table Pointer (Automatically Incremented)
V1401
0
0
0
1 V1400
Destination 0
5
0
0
V1500
SP56 SP56 = OFF
S S
Before TTD Execution Table
After TTD Execution Table Pointer
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
0
0
0
Table
1 V1400
Destination 0
5
0
0 V1500
SP56 SP56 = OFF
Table Pointer (Automatically Incremented)
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
S S
0
0
0
2 V1400
Destination 9
9
9
9 V1500
SP56 SP56 = OFF
S S S S S
Scan N+5
Table
Scan N+6
After TTD Execution
Before TTD Execution Table Pointer
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
0
0
0
Destination 1
0
1
Table Pointer (Automatically Incremented)
Table
5 V1400
0 V1500
SP56 SP56 = OFF
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4
V1406
2
0
4
6
5
V1407
X
X
X
X
S S
Before TTD Execution
After TTD Execution
Table
Table Pointer
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4 5
V1406
2
0
4
6
V1407
X
X
X
X
S S
0
0
0
Destination 2
0
4
6 V1500
SP56 SP56 = OFF
6 V1400
Destination 2
0
4
6 V1500
SP56
Table Pointer (Resets to 1, not 0)
Table
6 V1400
0
V1401
0
5
0
0
0 6
V1402
9
9
9
9
1
V1403
3
0
7
4
2
V1404
8
9
8
9
3
V1405
1
0
1
0
4 5
V1406
2
0
4
6
V1407
X
X
X
X
0
0
0
1 V1400
Destination 0
5
0
0 V1500
SP56 SP56 = OFF
S S
DL405 User Manual, 4th Edition
Standard RLL Instructions
0
0
SP56 = ON until end of scan or next instruction that uses SP56
S S
V1401
0
Page 322
5--150
Standard RLL Instructions Table Instructions
Remove from Bottom (RFB)
430 440 450
DS
HPP
The Remove From Bottom instruction moves a value from the bottom of a V--memory table to a V--memory location RFB and decrements a table pointer by 1. The Aaaa first V--memory location in the table contains the table pointer which indicates the next location in the table to be moved. The instruction will be executed once per scan provided the input remains on. The instruction will stop operation when the pointer equals 0. 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 Remove From Bottom function. 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. Step 2: - Load the starting V--memory location for the table into the accumulator. (Remember, the starting location of the table blank is used as the table pointer.) This parameter must be a HEX value. Step 3: - Insert the RFB instructions which specifies destination V--memory location (Vaaa). 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. Helpful Hint: - The instruction will be executed every scan if the input logic is on. If you do not want the instruction to execute for more than one scan, a one shot (PD) should be used in the input logic. Helpful Hint:, The pointer location should be set to the value where the table operation will begin. The special relay SP0 or a one shot (PD) should be used so the value will only be set in one scan and will not affect the instruction operation. Operand Data Type
Standard RLL Instructions
V--memory
DL440 Range
DL450 Range
A aaa aaa
V
All (See p. 3--41)
All (See p. 3--42)
Discrete Bit Flags
Description
SP56 on when the table pointer equals 0
NOTE: Status flags (SPs) are only valid until:, another instruction that uses the same flag is executed, or, the end of the scan. The pointer for this instruction can be set to start anywhere in the table. It is not set automatically. You have to load a value into the pointer somewhere in your program.
DL405 User Manual, 4th Edition