PLC Programming Comparison Instructions – GRT | Greater Than
Introduction
The GRT, also known as the Greater Than, is an instruction which compares two operands and evaluates if the value stored in “Source A” is greater than the value stored in “Source B”. If that’s the case, the instruction will evaluate to TRUE and allow the rest of the rung to execute. The GRT instruction may take integers, floats or constants as operands.
A typical use for this instruction would be a lower limit of a temperature sensor. Should the limit value be greater than the current temperature, the programmer will know immediately that there’s an issue.
This instruction is very commonly used within a ladder logic environment as it’s one of the simplest ways to compare two distinct values against each other.
Example & Usage of GRT
Here’s a real-world scenario of a GRT instruction:
- A Micrologix 1100 Allen Bradley PLC is used to control a process.
- A GRT instruction is used to compare a Float F8:12 to a Float F8:13.
- The Float F8:12 is currently set to “0” and the Float F8:13 is set to “0”.
- This GRT instruction evaluates to FALSE since the value of F8:12 is NOT Greater Than the value in F8:13.
- Note: The logic displays the boolean B3:1/0 as energized due to the fact that it’s used elsewhere in the logic. It is not being energized by this rung.
- A GRT instruction is used to compare an Integer N7:0 to the Integer N7:1.
- The Integer N7:0 is currently set to “564” while the Integer N7:1 is set to “6”.
- This GRT instruction evaluates to TRUE since N7:0 is Greater Than N7:1.
- A TON instruction is used to run a continuous timer T4:3 loop 2 seconds (200 x 0.01 = 2000 msec.)
- A GRT instruction is used to compare the value of the accumulated (.ACC) value of Timer T4:3 to the integer N7:3.
- The GRT instruction will evaluate to FALSE during the first half of the timer because N7:3 is set to 100 (100 x 0.01 = 1000 = 1/2 of the timer).
- The GRT instruction will evaluate to TRUE during the second half of the timer because N7:3 is set to 100 (100 x 0.01 = 1000 = 1/2 of the timer).
Programming example in RSLogix 500:
Outcome:
We have two GRT instructions used on a set of floats and integers in the first two examples. The first instruction will look at the two operands and evaluate to FALSE because one is not greater than the other. It’s important to point out that the GRT instruction will evaluate to FLASE should the operands be equal to one another. The second instruction is similar to the first one but is used on a set of two integers. These are exactly the same integers and values we’ve observed in the LES Instruction tutorial. The instruction will evaluate to true since the value stored in “Source A” is Greater Than the value stored in “Source B”.
Just like in the tutorial on LES, we have a timer TON instruction which is counting from 0 to 2000 milliseconds. Based on this timer, we are toggling the bit B3:1/2. This is accomplished by comparing the Timer T4:3.ACC value to the integer N7:3. Since the integer is set to 100, the boolean B3:1/2 will be OFF during the first second and ON during the last second of the timer.
Data Types Allowed for GRT
The GRT can be used to compare two values of identical types. These value can be INTs, DINTs, or FLOATs.
- Integer – You may specify each operand to be of “Integer” type.
- Float – You may specify each operand to be of “Float” or “Real” type.
Important Notes
- Note 1 – Both operands will be evaluated within the GRT instruction is being scanned. In an instance where the value is changed in other locations for only a brief duration, the GRT comparison may result in unforeseen outcomes.
- Note 2 – When working with constants, RSLogix 500 will not allow the user to use the constant in the “Operand A” field. The constant must be specified within “Operand B”. This limitation is not present in all software packages.
- Note 3 – The user may not specify a comparison of two constants within RSLogix 500. In other words, you may not use the GRT instruction with “Operand A” set to 7 and “Operand B” set to 20. This case will always evaluate to FALSE which should not be used.