The text of a manual · part 15 of 39
Series 90-30/20/Micro PLC CPU Instruction Set Reference Manual: Chapter 7 - Relational Functions
Pages 122 to 127 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 122
Chapter
Relational Functions
7 Relational functions are used to determine the relationship of two values. This chapter describes the following relational functions: Abbreviation
GFK-0467M
Function
Description
Page
EQ
Equal
Test two numbers for equality.
7-2
NE
Not Equal
Test two numbers for non-equality.
7-2
GT
Greater Than
Test for one number greater than another.
7-2
GE
Greater Than or Equal
Test for one number greater than or equal to another.
7-2
LT
Less Than
Test for one number less than another.
7-2
LE
Less Than or Equal
Test for one number less than or equal to another.
7-2
RANGE
Range
Determine whether a number is within a specified range (available for Release 4.5 or higher CPUs).
7-4
7-1
Page 123
7
Standard Relational Functions (EQ, NE, GT, GE, LT, LE) When the function receives power flow, it compares input parameter I1 to input parameter I2, which must be of the same data type. Relational functions operate on these types of data: Data Type
Description
INT
Signed integer.
DINT
Double precision signed integer.
REAL
Floating Point (not available for the RANGE function)
Note The REAL data type is only available on the 35x and 36x series CPUs, Release 9 or later, and on all releases of CPU352 and CPU37x. The %S0020 system bit is set ON when a relational function using REAL data executes successfully. It is cleared when either input is NaN (Not a Number). The Range function block does not accept REAL type. The default data type is signed integer. To compare either signed integers, double precision signed integers, or real numbers select the new data type after selecting the relational function. 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 supported types. If input parameters I1 and I2 match the specified relationship, output Q receives power flow and is set ON (1); otherwise, it is set OFF (0). _____ | | (enable), | EQ_ | | | | INT | | | (input parameter I1), |I1 Q| - (output parameter Q) | | | | (input parameter I2), |I2 | |_____|
Parameters Parameter enable
Description When the function is enabled, the operation is performed.
I1
I1 contains a constant or reference for the first value to be compared. (I1 is on the left side of the relational equation, as in I1 < I2).
I2
I2 contains a constant or reference for the second value to be compared. (I2 is on the right side of the relational equation, as in I1 < I2).
Q
Output Q is energized when I1 and I2 match the specified relation.
Note I1 and I2 must be valid numbers, i.e., cannot be NaN (Not a Number).
7-2
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 124
7 Expanded Description Function
Description
Equal
When enabled, if the value at input I1 is equal to the value at input I2, output Q is energized.
Not Equal
When enabled, if the value at input I1 is NOT equal to the value at input I2, output Q is energized.
Greater Than
When enabled, if the value at input I1 is greater than the value at input I2, output Q is energized.
Greater Than or Equal
When enabled, if the value at input I1 is greater than or equal to the value at input I2, output Q is energized.
Less Than
When enabled, if the value at input I1 is less than the value at input I2, output Q is energized.
Less Than or Equal
When enabled, if the value at input I1 is less than or equal to the value at input I2, output Q is energized.
Valid Memory Types Parameter flow
%I
%Q
%M
%T enable
•
I1 o o o
I2 o o o
Q
•
%S
%G
%R
%AI %AQ const o o
•
•
•
•† o o
•
•
•
•† none
•
• Valid reference or place where power may flow through the function. o Valid reference for INT data only; not valid for DINT or REAL. † Constants are limited to integer values (+32,767 to –32,768) for double precision signed integer operations when programmed with Logicmaster PLC software. When programmed with VersaPro software, full double precision signed integer values are allowed.
Example In the following example, two double precision signed integers, %R00100/101 and %R00102/103, are compared whenever enable contact %I0001 is on. If the value at input I1 is less than or equal to the value at input I2, coil %Q00002 will be turned on. In the following example, coil %Q00002 is turned off, since I1 is greater than I2.
| _____ |%I0001 | | | - - | | - - - - - - - - - - | LE_ | | | | | | DINT| | %R00100 | | %Q00002 | +0000134689 - |I1 Q| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( ) - | | | | %R00102 | | | +0000134600 - |I2 | | |_____| |
GFK-0467M
Chapter 7 Relational Functions
7-3
Page 125
7
RANGE
(INT, DINT, WORD) The RANGE function is used to determine if a value is between the range of two numbers.
Note This function is available only to Release 4.41 or later CPUs. The RANGE function operates on these types of data (REAL type is not supported in the RANGE function): Data Type
Description
INT
Signed integer.
DINT
Double precision signed integer.
WORD
Word data type.
The default data type is signed integer; however, it can be changed after selecting the function. For more information on data types, please refer to chapter 2, section 2, “Program Organization and User References/Data.” When the function is enabled, the RANGE function block will compare the value in input parameter IN against the range specified by limit parameters L1 and L2. When the value is within the range specified by L1 and L2, inclusive, output parameter Q is set ON (1). Otherwise, Q is set OFF (0). _____ | | (enable) –|RANGE| | | | INT | | | (limit parameter L1) –|L1 Q|– (output parameter Q) | | (limit parameter L2) –|L2 | | | (value to be compared) –|IN | |_____|
Note Limit parameters L1 and L2 represent the end points of a range. There is no minimum/maximum or high/low connotation assigned to either parameter. Thus, a desired range of 0 to 100 could be specified by assigning 0 to L1 and 100 to L2 or 0 to L2 and 100 to L1.
7-4
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M
Page 126
7
Parameters Parameter
Description enable
When the function is enabled, the operation is performed.
L1
L1 contains the start point of the range.
L2
L2 contains the end point of the range.
IN
IN contains the value to be compared against the range specified by L1 and L2.
Q
Output Q is energized when the value in IN is within the range specified by L1 and L2, inclusive.
Valid Memory Types Parameter flow
%I
%Q
%M
%T enable
•
L1 o o o
L2 o o o
IN o o o
Q • o ‡
%S
%G
%R
%AI %AQ const o o
•
•
•
•‡ o o
•
•
•
•‡ o o
•
•
• none
•
•
Valid reference or place where power may flow through the function. Valid reference for INT or WORD data only; not valid for DINT. Constants are limited to integer values for double precision signed integer operations.
Example 1 In the following example, %AI0001 is checked to be within a range specified by two constants, 0 and 100. | _____ |%I0001 | | | - - | | - - - +RANGE| | | INT | | | | %Q0002 | 100, +L1 Q+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( ) - | | | | 0, +L2 | | | | |%AI0001 - +IN | | |_____| |
RANGE Truth Table for Example 1
GFK-0467M
Enable State %I0001
L1 Value Constant
L2 Value Constant
IN Value %AI0001
Q State %Q0001
ON
100
0
<0
OFF
ON
100
0
0, 100
ON
ON
100
0
> 100
OFF
OFF
100
0
Any value
OFF
Chapter 7 Relational Functions
7-5
Page 127
7 Example 2 In this example, %AI0001 is checked to be within a range specified by two register values. | _____ |%I0001 | | | - - | | - - - +RANGE| | | INT | | | | %Q0002 |%R0001, +L1 Q| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( ) - | | | |%R0002, +L2 | | | | |%AI0001 - +IN | | |_____| |
RANGE Truth Table for Example 2
7-6
Enable State %I0001
L1 Value %R0001
L2 Value %R0002
IN Value %AI0001
Q State %Q0001
ON
500
0
<0
OFF
ON
500
0
0, 500
ON
ON
500
0
> 500
OFF
OFF
500
0
Any value
OFF
Series 90™-30/20/Micro PLC CPU Instruction Set Reference Manual – May 2002
GFK-0467M