2 DETAILS OF THE FB LIBRARY
2.5 M+ArrayHandling_Abs_R
31
2
Functional description (1) As i_bEN (execution command) turns on, this FB calculates the absolute values.
■Example 1
When the FB is executed for the input array data in word [signed], the output result is as follows.
■Example 2
When the FB is executed for the input array data in double word [signed], the output result is as follows.
(2) The target input array data for operation is read from the file register (ZR), starting from the address specified by
i_udInAryAddr (input array data start address). This FB reads input array data for the number of points specified by
i_udSize (number of data points).
(3) The operation results are stored in the file register (ZR) for the number of points specified by i_udSize (number of data
points), starting from the address specified by i_udOutAryAddr (output array data start address).
(4) Set the following so that the input array data areas and the output array data areas are not overlapped.
i_udInAryAddr (input array data start address)
i_udOutAryAddr (output array data start address)
i_udSize (number of data points)
If some areas of input array data and output array data are overlapped, o_bErr (error completion) turns on and the
processing of the FB is interrupted. In addition, 209H is stored in o_uErrId (error code). For the error code, refer to the
list of error codes. ( Page 33 List of error codes)
(5) When the input array data is -32768 and Word is specified as the data type, the output result is -32768. When the input
array data is -2147483648 and Double Word is specified as the data type, the output result is -2147483648.
(6) Specify Word [signed], Double Word [signed], or Single-precision real number as the data type of input array data and
output array data in i_uDataType (data type selection).
(7) Specify the number of data points for an array where the absolute values are calculated in i_udSize (number of data
points). When 1: Double Word [signed] or 2: Single-precision real number is specified by i_uDataType (data type
selection), file register (ZR) areas twice as many as the setting value of i_udSize (number of data points) are required.
(8) It takes multiple scans until the absolute value calculations are completed. When the input array data before the
operation is changed during the operation processing, the operation processing is executed with the changed data. The
number of points with the operation completed is output to o_udOutAryNum (number of output data points). When the
absolute value calculations are completed, o_bOK (normal completion) turns on.
(9) If a value out of the range is set in i_udSize (number of data points), o_bErr (error completion) turns on and the
processing of the FB is interrupted. In addition, 105H is stored in o_uErrId (error code). For the error code, refer to the
list of error codes. ( Page 33 List of error codes)
(10)If a value out of the range is set in i_uDataType (data type selection), o_bErr (error completion) turns on and the
processing of the FB is interrupted. In addition, 103H is stored in o_uErrId (error code). For the error code, refer to the
list of error codes. ( Page 33 List of error codes)
(11)When a single-precision real number is set in i_uDataType (data type selection) and the value stored in the file register
(ZR) is not a single-precision real number, o_bErr (error completion) turns on and the processing of the FB is
interrupted. In addition, 200H is stored in o_uErrId (error code). For the error code, refer to the list of error codes. (
Page 33 List of error codes)
(12)If i_bEN (execution command) is turned off before o_bOK (normal completion) or o_bErr (error completion) turns on,
o_bErr (error completion) turns on in one scan. In addition, 205H is stored in o_uErrId (error code) in one scan. For the
error code, refer to the list of error codes. ( Page 33 List of error codes)
The operation results of the absolute value calculations that have been completed before i_bEN (execution command)
is turned off remain stored in the file register (ZR).
FB compilation method Subroutine type
FB operation Pulse execution type (multiple scan execution type)
Item Description
ZR0
0
ZR1
-1
ZR998
32767
ZR997
-32766
ZR999
-32768
··
ZR10000
0
ZR10001
1
ZR10998
32767
ZR10997
32766
ZR10999
-32768
··
Stored value
Output result
Stored value
ZR0
0
ZR2
-1
ZR1996
2147483647
ZR1994
-2147483646
ZR1998
-2147483648
··
ZR10000
0
ZR10002
1
ZR11996
2147483647
ZR11994
2147483646
ZR11998
-2147483648
··
Stored value
Output result
Stored value