Set time

This function block can set single subcomponents of a time for the data type connected to the input IO. The value of that component will be set via the input InX.

Depending on the actual data type, the following subcomponents can be set: hour, minute, second, millisecond, and day (only for TIME). The data type TIME represents a duration, but will be interpreted as a structured data type with subcomponents, which can be set.

If the value on the input InX is negative, the selected component of the data type will not change.

The new time will be a valid time, even if the value of the component to set is out of range. In this case a correct time will be calculated by adjusting the other components. If this adjustment results in a point in time of another day, the corresponding date part will be changed, too:

Time Input Result
13:25:20 60 minutes 14:00:20
10.07.2009 13:25:30 25 hours 11.07.2009 01:25:20

If the value of the component input does not result directly in a valid time, the output Err will be set to HIGH.

Parameters

The parameter dialog can be used to select a data type and the component which has to be set.

Signals

Name I/O Type(s) Function
IO I/O TOD, DT, OLEDATETIME, TIME Time value
InX I WORD Subcomponent
Err O BIT Error indication

Visualization

The current data type and the component to set will be depicted at the function block.

Comments

The data type can also be changed by connecting the input IO.

Because the TIME data type is a LONG based duration in milliseconds, the largest duration is 49 days, 17 hours, 2 minutes, 47 seconds, and 295 milliseconds. The highest possible value to set for a day is therefore 49.

If the setting of a time for the OLEDATETIME data type will result in a date beyond/under the defined maximum/minimum, the output will be set to that limit.

An unconnected input InX in equivalent to the value 0, which is a valid value for all components, so it will be set.