TRANS_TIME: Conversion of a duration into DINT format
Original instructions
Function description
The function TRANS_TIME is used to convert a duration in DINT format (TIME using PL7) into a number.
The additional parameters EN and ENO can be configured.
Representation in FBD
Representation:
Representation in LD
Representation:
Representation in IL
Representation:
LD Time1
TRANS_TIME
ST Result_DINT
Representation in ST
Representation:
Result_DINT := TRANS_TIME(Time1);
Description of the parameters
The following table describes the input parameters:
Parameter
Type
Comment
Time1
Duration to convert. Time1 is expressed in tenths of seconds; the value used for the function is therefore rounded off to the second.
The following table describes the output parameters:
Parameter
Type
Comment
Result_DINT
Result_INT is a double integer that breaks down as follows:
  • the most significant word contains the hours in BCD format,
  • the least significant word contains the minutes and seconds:
    • the most significant byte contains the minutes in BCD format,
    • the least significant byte contains the seconds in BCD format.
Example: 16#00233740 corresponds to 23 hours, 37 minutes and 40 seconds.
Note: Result_DINT ranges between 0000:00:00 and 9999:59:59.
Runtime errors
The maximum possible value is therefore 9999 hours, 59 minutes and 59 seconds, or 359,999,990 tenths of a second.
If Time1 is ≥ 360,000,000, there is an overflow, the bit %S15 switches to 1 and Result_DINT = 16#00000000