Table of Contents

Time conversion

Block name

B100_TIME_CONVERSION

ST call

PROGRAM B100_TEST
VAR 
  XSEC, XMIN, XHOUR: UDINT;
   YSEC ,YMIN, YHOUR: UDINT;
   FB: LIB.CORE.V1_0.B100_TIME_CONVERSION;
END_VAR
 
  FB(SEC := XSEC MIN := XMIN, HOUR := XHOUR, YSEC => YSEC, YMIN => YMIN, YHOUR => YHOUR);
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The block is used for conversions of time and date values to the required formats.

Inputs

InputType Description Default value
SEC UDINTany number of seconds0
MIN UDINTany number of minutes0
HOUR UDINTany number of hours 0
DAY UDINTany number of days 0
MON UDINTany number of months 0
YEAR UDINTany number of years 0

Outputs

OutputType Description
YSEC UDINTnumber of seconds
YMIN UDINTnumber of minutes
YHOUR UDINTnumber of hours
YDAY UDINTnumber of days
YMON UDINTnumber of months
YYEAR UDINTnumber of years

Function

The input signals may have any value greater or equal zero. The output returns date and time in the equivalent correct format. A month is considered to have 30 days. A year is considered to have 365,25 days.

Application example

The function adds inputs 85 s, 75 min and 5 hours. The result is a sensible value of 6 hours,16 mins and 25 s.