Extended instructions
8.1 Date, time-of-day, and clock functions
Note
Using T_CONV to convert a larger data size to a smaller data size
Data values can be truncated when you convert a larger data type with more bytes to a
smaller data type with less bytes. If this error occurs, then ENO is set to 0.
Conversion to/from DTL data type
DTL (Date and Time Long) contains year, month, date, and time data. DTL data can be
converted to/from DATE and TOD data types.
However, DTL conversion with DATE data only affects the year, month, and day values. DTL
conversion with TOD data only affects the hour, minutes, and seconds values.
When T_CONV converts to DTL, the unaffected data elements in the DTL format are left
unchanged.
Table 8- 3
T_ADD (Add times) and T_SUB (Subtract times) instructions
LAD / FBD
SCL
out := T_ADD(
in1:=_variant_in,
in2:=_time_in);
out := T_SUB(
in1:=_variant_in,
in2:=_time_in);
For LAD and FBD: Click the "???" and select the data types from the drop-down menu.
1
Table 8- 4
Data types for the T_ADD and T_SUB parameters
Parameter and type
IN1
IN
1
IN2
IN
OUT
OUT
Select the IN1 data type from the drop-down list available below the instruction name. The IN1 data type selection also
1
sets the data type of parameter OUT.
284
Description
T_ADD adds the input IN1 value (DTL or Time data types) with the
input IN2 Time value. Parameter OUT provides the DTL or Time value
result. Two data type operations are possible:
Time + Time = Time
•
DTL + Time = DTL
•
T_SUB subtracts the IN2 Time value from IN1 (DTL or Time value).
Parameter OUT provides the difference value as a DTL or Time data
type. Two data type operations are possible:
Time - Time = Time
•
DTL - Time = DTL
•
Data type
Description
DTL, Time
DTL or Time value
Time
Time value to add or subtract
DTL, Time
DTL or Time sum or difference
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG