The text of a manual · part 38 of 60
DL205 PLC User Manual, Volume 1 of 2, pages 371 to 380
Pages 371 to 380 of 598
The original document is the PDF (12 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 D2-04TD1, AutomationDirect D2-08TD2, AutomationDirect D2-16ND3-2, AutomationDirect D2-32ND3, Konnect-It D2-04TD1, Koyo D2-04TD1, Konnect-It D2-08TD2, Koyo D2-08TD2, and 5 more models
Page 371
Chapter 5: Standard RLL Instructions
Copy Data From V-Memory to a Data Label Area
230 240 250-1 260 DS Used HPP Used
1 2 3 4 5 DLBL K1 6 7 8 9 10 11 12 13 14 A B WARNING: The offset for this usage of the instruction starts at 0. If the offset (or the specified data table C 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. D
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
1
2
3
4
V2000
N
Offset
4
Load the value 2 into the accumulator specifying the offset for source and destination locations.
6
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
5
3
1
5
2 1
V2001
V2002
C O N
K
7
N
C O N
0
K
4
N
C O N
6
1
4 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
1
Offset
8
1 5 0 5
K1
K1 is the data label destination area where the data will be copied to
Handheld Programmer Keystrokes $
B
STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
M ORST
O INST#
ENT
3
3
3
A
SHFT
K JMP
E
SHFT
K JMP
C
C
A
0
V AND
M ORST
C
2
2
4 2
0
ENT ENT
A
0
SHFT
A
0
K JMP
ENT
B
1
ENT
DL205 User Manual, 4th Edition, Rev. D
5-147
Page 372
Chapter 5: Standard RLL Instructions
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) RSTBIT 4 The Reset Bit instruction resets a single bit to zero within a 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: L oad 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: L oad 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: nsert 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 outside 11 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 B executed. 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. D B
Page 373
Chapter 5: Standard RLL Instructions For example, suppose 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.”
MSB
V3000
LSB
1 2 3 In this ladder example, we will use input X0 to trigger the Set Bit operation. First, we will load the table length (two words) into the accumulator stack. Next, we load the starting address 4 into the accumulator. Since V3000 is an octal number we have to convert it to hex by using the LDA command. Finally, we use the Set Bit (or Reset Bit) instruction and specify the octal 5 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
MSB
V3001
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
STR
SHFT
L ANDST
D
SHFT
L ANDST
D
X SET
SHFT
B
ENT
0
PREV
3 3
1
A I
D
0
8
C
T MLR
2
3
NEXT
ENT
A
D
0
3
A E
0
4
A
0
ENT
ENT
DL205 User Manual, 4th Edition, Rev. D
5-149
Page 374
Chapter 5: Standard RLL Instructions
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 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
A aaa
Step 1: L oad 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: L oad 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
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
F
I
5
1
ENT PREV
3 3 8
A
0
L L ANDST ANDST
E B
4 1
ENT G B
6 1
A E
0 4
DL205 User Manual, 4th Edition, Rev. D
A A
0 0
ENT A
0
ENT
Page 375
Chapter 5: Standard RLL Instructions
Find (FIND)
1 A aaa 2 the Find function. 3 Step 1: L oad 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 to FFFF. 4 Step 2: L oad 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: L oad the offset from the starting location to begin the search. This parameter must be a HEX 5 value. Step 4: nsert the Find instruction which specifies the first value to be found in the table. 6 Results: offset from the starting address to the first V-memory location which contains the search value is returned to the accumulator as a HEX value. 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, 7 0 will be returned in the accumulator. Helpful hint: For parameters that require HEX values when referencing memory locations, the 8 LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. 9 Operand Data Type DL260 Range 10 A aaa 11 12 Discrete Bit Flag Description 13 NOTE: Status flags are only valid until another instruction that uses the same flags is executed. The 14 pointer for this instruction starts at 0 and resides in the accumulator. In the example on the following page, when X1 is on, the constant value (K6) is loaded into A 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 B 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 C 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 D location of the table) where the value is located will reside in the accumulator.
Find instruction is used to search for a specified value 230 The in a V-memory table of up to 255 locations. The function 240 parameters are loaded into the first and second levels of the 250-1 accumulator stack and the accumulator by three additional 260 instructions. Listed below are the steps necessary to program DS Used HPP Used
V-memory Constant
SP53
V K
FIND
All (See page 3-56) 0-FFFF
On if there is no value in the table that is equal to the search value.
DL205 User Manual, 4th Edition, Rev. D
5-151
Page 376
Chapter 5: Standard RLL Instructions DirectSOFT
1 2 3 4 5 6 7 8 Find Greater Than (FDGT) 9 The Find Greater Than instruction is used to search for the first FDGT occurrence of a value in a V-memory table that is greater than the A aaa 10 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 11 two additional instructions. Listed below are the steps necessary to program the Find Greater Than function. 12 NOTE: This instruction does not have an offset, such as the one required for the FIND instruction. 13 Step 1: L oad 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 to FFFF. Step 2: L oad the starting V-memory location for the table into the accumulator. This parameter 14 must be a HEX value. Step 3: Insert the FDGT instruction which specifies the greater than search value. A offset from the starting address to the first V-memory location which contains the greater than search value is returned to the accumulator as a HEX value. SP53 will be set on B if the value is not found and 0 will be returned in the accumulator. Helpful hint: For parameters that require HEX values when referencing memory locations, the C LDA instruction can be used to convert an octal address to the HEX equivalent and load the value into the accumulator. D X1
LD
K6
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
Offset
Begin here
LDA
O 1400
Convert octal 1400 to HEX 300 and load the value into the accumulator
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
5
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.
LD
K2
Handheld Programmer Keystrokes
Load the constant value 2 into the lower 16 bits of the accumulator
FIND
K8989
Find the location in the table where the value 8989 resides
$
B
STR
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
F
I
5
1
PREV
3 3
3
230 240
250-1 260
DS Used HPP Used
5-152
ENT
DL205 User Manual, 4th Edition, Rev. D
8
A
G
B
0
PREV
C
N TMR
D
2
3
6
1
ENT
E
4
A
0
A
0
ENT
ENT
NEXT
I
8
J
9
I
8
J
9
ENT
Page 377
Chapter 5: Standard RLL Instructions Operand Data Type
DL260 Range
1 2 Discrete Bit Flags Description 3 4 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. 5 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) 6 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 7 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, 8 a zero is stored in the accumulator and SP53 will come ON. 9 10 11 12 13 14 A B C D A
V-memory Constant
SP53 aaa
V All (See page 3-56) K 0-FFFF
On if there is no value in the table that is equal to the search value.
DirectSOFT X1
LD
Begin here
K6
Load the constant value 6 (HEX) into the lower 16 bits of the accumulator
LDA
O1400
Convert octal 1400 to HEX 300 and load the value into the accumulator
Table length
0
1
2
3
V1400
0
0
5
0
0
V1401
1
9
9
9
9
V1402
2
0
3
0
7
4
V1403
3
8
9
8
9
V1404
4
1
0
1
0
V1405
5
X
X X
X V1406
X
X X
X V1407
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.
Accumulator
0
0
0
0
0
0
2
FDGT
K8989
Find the value in the table greater than the specified value
Handheld Programmer Keystrokes $
B
STR
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
F
D
5
1
ENT
PREV
3 3
3
A
G
B
0
6
G
T
MLR
6
1
ENT
E
4
NEXT
A I
0
8
A J
ENT
0
9
I
8
J
9
ENT
DL205 User Manual, 4th Edition, Rev. D
5-153
Page 378
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Table to Destination (TTD) Table To Destination instruction moves a value from a 230 The V-memory table to a V-memory location and increments the 240 table pointer by 1. The first V-memory location in the table 250-1 contains the table pointer which indicates the next location in 260 the table to be moved. The instruction will be executed once DS Used HPP Used
TTD
Vaaa 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. Step 1: L oad 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: L oad 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: nsert the TTD instruction that specifies the 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
DL260 Range
V-memory
All (See page 3 - 56)
aaa
Discrete Bit Flags SP53
5-154
V
Description On if there is no value in the table that is equal to the search value.
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 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.
DL205 User Manual, 4th Edition, Rev. D
Page 379
Chapter 5: 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 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 0 1400
Copy the specified value from the table to the specified destination (V1500)
TTD V1500
Handheld Programmer Keystrokes $
B
STR
1
SHFT
L ANDST
D
SHFT
L ANDST
D
SHFT
T MLR
T MLR
ENT PREV
3 3
A D
0 3
G B B
6 1 1
ENT E F
4 5
A A
0 0
A A
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 0, and again when the pointer is equal to 6. Why? Because the pointer is only equal to 0 before the very first execution. From then on, it increments from 1 to 6, and then resets to 1.
0 0
ENT ENT
Table Pointer
Table V1401
0
5
0
0
06
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
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.
0
0
0
0 V1400
Destination X
X X
X V1500
. . DirectSOFT
Display (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.
DL205 User Manual, 4th Edition, Rev. D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-155
Page 380
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-156
The following diagram shows the scan-by-scan results of the execution for our example program. Notice how the pointer automatically cycles from 0 to 6, and then starts over at 1 instead of 0. Also, notice how SP56 is only on until the end of the scan.
Scan N
Before TTD Execution
After TTD Execution
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
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
. .
Scan N+1
Table Pointer (Automatically Incremented)
V1401
0
0
0
1 V1400
Destination 0
5
0
0
V1500
SP56 SP56 = OFF
. .
Before TTD Execution
After TTD Execution
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
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
0
0
0
2 V1400
Destination 9
9
9
SP56
9 V1500
SP56 = OFF
. .
. . . . .
Scan N+5
After TTD Execution
Before TTD Execution 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
Table
5 V1400
Destination 1
0
1
0 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
. .
Scan N+6
Table Pointer (Automatically Incremented)
V1401
0
0
0
6 V1400
Destination 2
0
4
6 V1500
SP56 SP56 = ON until end of scan or next instruction that uses SP56
. . After TTD Execution
Before TTD Execution 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
Table
6 V1400
Destination 2
0
4
6 V1500
SP56 SP56 = OFF
. .
DL205 User Manual, 4th Edition, Rev. D
Table Pointer (Resets to 1, not 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
V1406
2
0
4
6
5
V1407
X
X
X
X
. .
0
0
0
1 V1400
Destination 0
5
0
0 V1500
SP56 SP56 = OFF