Portada » TIA Portal T_COMP: Compare time tags (S7-1500)

TIA Portal T_COMP: Compare time tags (S7-1500)

by admin
56 views

This instruction is used to compare the contents of two tags of the “Timers” or “Date and time” data type in SIemens TIA Portal and PLC S7-1500.

The instruction supports the comparison of the following data types: DATE, TIME, LTIME, TOD (TIME_OF_DAY), LTOD (LTIME_OF_DAY), DT (DATE_AND_TIME), LDT (DATE_AND_LTIME), DTL, S5Time.

The data types must be the same length and format to carry out the comparison.

The comparison result is output at the OUT parameter as a return value. For this purpose, the parameter OUT is set to “1” if the condition used for the comparison is satisfied.

The following comparison options are available:

SymbolDescription
EQThe return value has the signal state “1″ if the time is the same at the parameters IN1 and IN2.
NEThe return value has the signal state “1″ if the time at the parameter IN1 is not the same as that at the parameter IN2.
GEThe return value has the signal state “1” if the time at parameter IN1 is greater (more recent) than or equal to the time at parameter IN2 .
LEThe return value has the signal state “1” if the time at parameter IN1 is smaller (less recent) than or equal to the time at parameter IN2.
GTThe return value has the signal state “1” if the time at parameter IN1 is greater (more recent) than the time at parameter IN2.
LTThe return value has the signal state “1” if the time at parameter IN1 is smaller (older) than the time at parameter IN2 .

Parameters

The following table shows the parameters of the “T_COMP” instruction:

ParameterDeclarationData typeMemory areaDescription
IN1InputDATE, TIME, LTIME, TOD, LTOD, DT, LDT, DTL, S5TimeI, Q, M, D, L, P or constantFirst value to be compared.
IN2InputDATE, TIME, LTIME, TOD, LTOD, DT, LDT, DTL, S5TimeI, Q, M, D, L, P or constantSecond value to be compared.
OUTOutputBOOLI, Q, M, D, L, PReturn value

Example

In the following example, you use the “Greater or equal” comparison option to compare two times with the LTIME data type.

Create three tags in a global data block for storing the data.

Interconnect the parameters of the instruction as follows. Select the “GE” comparison option.

Since the time of the first value to be compared (“timeValue1”) is greater than or equal to the second value (“timeValue2”), the return value (“value1GEvalue2”) shows the signal state “TRUE”.

Related News