The text of a manual · part 21 of 39
Series 90-30/20/Micro PLC CPU Instruction Set Reference Manual: Chapter 10 - Table Functions
Pages 167 to 176 of 337, from Series 90-30/20/Micro PLC CPU Instruction Set Reference Manual
The original document is the PDF (4.4 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 GE Fanuc IC692CPU211D / IC692MDR541C, Fanuc IC692CPU211D / IC692MDR541C, GE IC692CPU211D / IC692MDR541C and GE Fanuc IC693CPU311X
Page 167
Chapter
Table Functions
10 Table instructions are used to perform the following functions: Abbreviation
Function
Description
Page
Copy a specified number of data elements from a source array to a destination array. Search for all array values equal to a specified value.
10-2
ARRAY_MOVE
Array Move
SRCH_EQ
Search Equal
SRCH_NE SRCH_GT
Search Not Equal Search for all array values not equal to a specified value. Search Greater Search for all array values greater than a specified value. Than
10-7 10-7
SRCH_GE
Search Greater Than or Equal
Search for all array values greater than or equal to a specified value.
10-7
SRCH_LT SRCH_LE
Search Less Than Search for all array values less than a specified value. Search Less Than Search for all array values less than or equal to a or Equal specified value.
10-7 10-7
10-7
The maximum length allowed for these functions is 32,767 bytes or words, or 262,136 bits (bits are available for ARRAY_MOVE only). Table functions operate on these types of data: Data Type INT DINT BIT *
Description Signed integer. Double precision signed integer. Bit data type.
BYTE Byte data type. WORD Word data type. * Only available for ARRAY_MOVE.
The default data type is signed integer. The data type can be changed after selecting the specific data table function in the ladder logic software. To compare data of other types or of two different types, first use the appropriate conversion function (described in chapter 11, “Conversion Functions”) to change the data to one of the data types listed above.
GFK-0467M
10-1
Page 168
10
ARRAY_MOVE (INT, DINT, BIT, BYTE, WORD) Arrays and Data Elements Defined For the purpose of this discussion, an array is a grouping of contiguous addressable PLC memory, such as %R0100 through %R0120. A data element is the data held in one unit of array memory. For example, if an array is a Bit type, then each data element is held in a single bit of memory, such as %M0001 (or it could be a single bit in register-type memory). Or, if an array is a Word type, then each data element is held in a 16-bit word of memory, such as %R0100 (or it could be 16 consecutive %I bits). See the “Valid Memory Types” table for more information on this.
Index Numbers Each data element of an array has a reference number called an index number, which is automatically assigned by the PLC. The index number indicates the data element’s position in the array. The data elements are numbered in ascending order, starting with the lowest memory address in the array, which is assigned index number one. For example, the following Word-type array has a starting address of %R0105. It has ten data elements, whose index numbers are 1 through 10. Address
Index No.
%R0105
1
%R0106
2
%R0107
3
%R0108
4
%R0109
5
%R0110
6
%R0111
7
%R0112
8
%R0113
9
%R0114
10
The Array Move Instruction Use the Array Move function to copy a specified number of data elements from a source array to a destination array. Each array referenced by an Array Move instruction has an equal number of data elements. The Array Move allows the relative locations involved in the move to be different between the source and destination arrays. For example, three data elements, starting at index 5 in the source array, may be copied to three data elements in the destination array starting at index 7.
10-2
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 169
10 The ARRAY_MOVE function has five input parameters and two output parameters. When the function is enabled, the number of data elements in the count indicator (N) are copied from the input array starting with the indexed location specified at the SNX input. The data elements are written to the output array starting with the indexed location specified at DNX The LEN operand specifies the number of elements that make up each array. For ARRAY_MOVE_BIT, when word-oriented memory is selected for the parameters of the source array and/or destination array starting address, the least significant bit of the specified word is the first bit of the array. The value displayed on the Logicmaster screen contains 16 bits, regardless of the length of the array. The indices in an ARRAY_MOVE instruction are 1-based. In using an ARRAY_MOVE, no element outside either the source or destination arrays (as specified by their starting address and length) may be referenced. The ok output will receive power flow, unless one of the following conditions occurs: •
Enable is OFF.
•
(N + SNX – 1) is greater than LEN. This formula is used by the PLC to ensure that no element outside the source array is referenced.
•
(N + DNX – 1) is greater than LEN. This formula is used by the PLC to ensure that no element outside the destination array is referenced.
•
SNX or DXN = 0. _____ | | (enable), |ARRAY| - (ok) | | |MOVE_| | | | BIT | | | (source array address), |SR DS| - (destination array address) | LEN | |00001| (source array index), |SNX | | | | | (destination array index), |DNX | | | | | (elements to transfer ), |N | |_____|
GFK-0467M
Chapter 10 Table Functions
10-3
Page 170
10
Parameters Parameter
Description enable
When the enable input is on, the Array Move operation is performed.
SR
SR contains the starting address of the source array. For ARRAY_MOVE_ BIT, any reference may be used; it does not need to be byte aligned. However, 16 bits, beginning with the reference address specified, are displayed on the Logicmaster screen.
SNX
SNX contains the index number in the source array of the first data element to be copied.
DNX
DNX contains the index number in the destination array of the first element to be copied to.
N
The number of data elements to be copied.
ok
The ok output is energized whenever enable is energized.
DS
DS contains the starting address of the destination array. For ARRAY_MOVE_ BIT, any reference may be used; it does not need to be byte aligned. However, 16 bits, beginning with the reference address specified, are displayed online.
LEN
LEN specifies the number of data elements, starting at SR and DS, that make up each array.
Valid Memory Types Parameter flow enable
•
10-4
%M
%T
%S
%G
Ơ
%R
%AI
%AQ const
SR o o o o o
•
•
•
•
•
•
•
•
•
•
•
•
DNX
•
•
•
•
•
•
•
•
•
N
•
•
•
•
•
•
•
•
•
DS o ∆ †
%Q
SNX ok •
%I
• none
• o o o o
† o
•
•
•
Valid reference or place where power may flow through the function. For ARRAY_MOVE_BIT, discrete user references %I, %Q, %M, and %T need not be byte aligned. Valid reference for INT, BIT, BYTE, or WORD data only; not valid for DINT. Valid data type for BIT, BYTE, or WORD data only; not valid for INT or DINT. %SA, %SB, %SC only; %S cannot be used.
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 171
10 Example 1 In this example, both arrays are INT types that are10 elements (integers) long, specified by LEN=10. Their starting addresses are specified at SR and DS. When enable contact %M0201 is on, five data elements (specified by N=5) are copied from the source array to the destination array. The five copied data elements of the source array start with index number 3, since SNX=3. The locations copied to in the destination array start with index number 5, since DNX=5. So %R0003 through %R0007 of the source array are read and then copied into %R0104 through %R0108 of the destination array. %M0201
%M0202 ARRAY MOVE_ INT
%R0001
SR
DS
%R0100
LEN 00010 CONST +00003
SNX
CONST +00005
DNX
CONST +00005
N
Source Array
Destination Array
%R0001 %R0002 %R0003 %R0004 %R0005 %R0006 %R0007 %R0008 %R0009 %R0010
%R0100 %R0101 %R0102 %R0103 %R0104 %R0105 %R0106 %R0107 %R0108 %R0109
Example 2 In this example, both arrays are BIT types that are10 elements (bits) long, specified by LEN=10. Their starting addresses are specified at SR and DS. When enable contact %M0201 is on, four data elements (specified by N=4) are copied from the source array to the destination array. The four copied data elements of the source array start with index number 4, since SNX=4. The locations copied to in the destination array start with index number 2, since DNX=2. So %M0012 through %M0015 of the source array are read and then copied into %Q0023 through %Q0026 of the destination array. %M0201
%M0202 ARRAY MOVE_ BIT
%M0009
SR
DS
LEN 00010
GFK-0467M
CONST +00004
SNX
CONST +00002
DNX
CONST +00004
N
Chapter 10 Table Functions
%Q0022
Source Array
Destination Array
%M0009 %M0010 %M0011 %M0012 %M0013 %M0014 %M0015 %M0016 %M0017 %M0018
%Q0022 %Q0023 %Q0024 %Q0025 %Q0026 %Q0027 %Q0028 %Q0029 %Q0030 %Q0031
10-5
Page 172
10
Example 3 In this example, both arrays are BIT types that are 20 elements (bits) long, specified by LEN=20. Their starting addresses are specified at SR and DS. When enable contact %M0201 is on, 12 data elements (specified by N=12) are copied from the source array to the destination array. The 12 copied data elements of the source array start with index number 6, since SNX=6. The locations copied to in the destination array start with index number 8, since DNX=8. So %R0001, bit 6 through %R0002, bit 1 of the source array are read and then copied into %R0100, bit 8 through %R0101, bit 3 of the destination array. %M0201
%M0202 ARRAY MOVE_ BIT
%R0001
SR
DS
LEN 00020
10-6
CONST 00006
SNX
CONST 00008
DNX
CONST 00012
N
%R0100
Source Array
Destination Array
%R0001, bit 1 %R0001, bit 2 %R0001, bit 3 %R0001, bit 4 %R0001, bit 5 %R0001, bit 6 %R0001, bit 7 %R0001, bit 8 %R0001, bit 9 %R0001, bit 10 %R0001, bit 11 %R0001, bit 12 %R0001, bit 13 %R0001, bit 14 %R0001, bit 15 %R0001, bit 16 %R0002, bit 1 %R0002, bit 2 %R0003, bit 3 %R0003, bit 4
%R0100, bit 1 %R0100, bit 2 %R0100, bit 3 %R0100, bit 4 %R0100, bit 5 %R0100, bit 6 %R0100, bit 7 %R0100, bit 8 %R0100, bit 9 %R0100, bit 10 %R0100, bit 11 %R0100, bit 12 %R0100, bit 13 %R0100, bit 14 %R0100, bit 15 %R0100, bit 16 %R0101, bit 1 %R0101, bit 2 %R0101, bit 3 %R0101, bit 4
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 173
10
Search Functions Use the appropriate Search function listed below to search for all array values for that particular operation. Abbreviation
Function
Description
SRCH_EQ
Search Equal
SRCH_NE
Search Not Equal
Search for all array values equal to a specified value. Search for all array values not equal to a specified value.
SRCH_GT
Search Greater Than
Search for all array values greater than a specified value.
SRCH_GE
Search Greater Than or Equal
Search for all array values greater than or equal to a specified value.
SRCH_LT
Search Less Than
Search for all array values less than a specified value.
SRCH_LE
Search Less Than or Equal
Search for all array values less than or equal to a specified value.
Each function has four input parameters and two output parameters. When the function receives power, the array is searched starting at (AR + input NX). This is the starting address of the array (AR) plus the index into this array (input NX). The search continues until the array element of the search object (IN) is found or until the end of the array is reached. If an array element is found, output parameter (FD) is set ON and output parameter (output NX) is set to the relative position of this element within the array. If no array element is found before the end of the array is reached, then output parameter (FD) is set OFF and output parameter (output NX) is set to zero. The valid values for input NX are 0 to LEN, 1. NX should be set to zero to begin searching at the first element. This value increments by one at the time of execution. Therefore, the values of output NX are 1 to LEN. If the value of input NX is out-of-range, (< 0 or ≥ LEN), its value is set to the default value of zero. _____ | | (enable), |SRCH_| | | | EQ_ | | | | WORD| | | (starting address), |AR FD| - | LEN | |00001| (input index), |NX NX| - (output index) | | | | (object of search), |IN | |_____|
GFK-0467M
Chapter 10 Table Functions
10-7
Page 174
10
Parameters Parameter enable
Description When the enable input is on, the operation is performed.
AR
AR contains the starting address of the array to be searched (the target array).
Input NX
Input NX contains an index number (in the target array) where the search is to begin.
IN
IN contains the object to be searched for.
Output NX
If the object of the search is found, its location in the array (its index number) will be written here.
FD
This output turns on to indicate that the searched for object has been found in the array.
LEN
LEN specifies the number of elements starting at AR that make up the array to be searched. It may be 1 to 32,767 bytes or words.
Valid Memory Types Parameter flow enable
•
%Q
%M
%T
%S
%G
∆ o
AR o o o o
NX in
•
•
•
•
IN o o o o
NX out
•
•
•
•
FD • o ∆
10-8
%I
∆
%R
%AI
%AQ
•
•
•
•
•
•
•
• o
•
•
•
•
•
•
•
•
• const none
•
Valid reference or place where power may flow through the function. Valid reference for INT, BYTE, or WORD data only; not valid for DINT. Valid reference for BYTE or WORD data only; not valid for INT or DINT.
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 175
10
Example 1 The SRCH_EQ function (INT type) in this example searches the block of memory that starts at %R0001 (specified at AR) and continues through %R0010 (LEN=10). The value to be searched for, defined at IN, is +16566. Input NX, with a value of 3, indicates that the search is to begin at the fourth data element in the array since the NX value is incremented by 1 when the function executes. When enable contact %M0201 is on, the SRCH_EQ function searches the specified array, starting at index number 4, for a value equal to the value at IN, +16566. It finds this value in %R0007, which has an index number of 7, so it writes the number 7 into the output NX at %R0100. It also turns on output FD, which indicates that it found the search object in the array. Note that although address %R0002 also contains the searched-for value of +16566, this data element was not included in the search because the input NX parameter value of 3 specified that the search start with the fourth data element, which is %R0004. %M0201
%M0202 SRCH_ EQ_ INT
%R0001
TARGET ARRAY Index No. Address Value
AR FD LEN 00010
GFK-0467M
CONST 00003
NX NX
%R0100 +16566
IN
Chapter 10 Table Functions
%R0100 00007
1 2 3 4 5 6 7 8 9 10
%R0001 %R0002 %R0003 %R0004 %R0005 %R0006 %R0007 %R0008 %R0009 %R0010
00000 +16566 +12345 +32000 +07870 -00550 +16566 -12343 +00058 +19238
10-9
Page 176
10 Example 2 The array in this example starts at %AI0001 (specified at AR) and continues through %AI0016 (LEN=16). The value to be searched for, defined at IN, is +16566. The input NX, with a starting value of 0, indicates that the search is to begin at the first data element in the array since the NX value increments by 1 when the function executes. When %M0200 closes for the first time, the function executes its first search, starting with data element 1, for a value equal to the value at IN, 00000. It finds this value in %AI0003, which has an index number of 3, so it writes the number 3 into the output NX and input NX, which both have the reference address of %R0001. It also turns on output FD, which indicates that it found the search object in the array. When %M0200 closes the second time, the input NX value, which is now set to 3, increments by 1, so the second search begins at the fourth array element, %AI0004. The target value of 00000 is now found in %AI0007, the seventh data element, so the number 7 is written to %R0001. Each succeeding search follows this pattern, until the fifth search, in which no target is found. Since no target is found, a 0 is written to %R0001, which will ensure that the search will start at the beginning of the array the next time the search is initiated.
Search No.
Search Starts at Data Element
Search Results (in %R0001)
1 2 3 4 5
1 4 8 12 16
3 7 11 15 0
%M0200
%M0201
%M0201
%M0202 SRCH_ EQ_ INT
%AI0001
AR FD LEN 00016
10-10
%R0001 00000
NX NX
CONST 00000
IN
%R0001 00000
TARGET ARRAY Index No. Address Value %AI0001 00100 1 %AI0002 +16566 2 %AI0003 00000 3 %AI0004 +32000 4 %AI0005 +07870 5 %AI0006 -00550 6 %AI0007 00000 7 %AI0008 -12343 8 %AI0009 +00058 9 %AI0010 +19238 10 %AI0011 00000 11 %AI0012 +16566 12 %AI0013 +12345 13 %AI0014 +32000 14 %AI0015 00000 15 %AI0016 -00550 16
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M