DIV_TIME block

Short summary

Name

DIV_TIME

→POU type

→function

Category

IEC-block, Time, block with internal error diagnostic

Conform to →IEC-standard

(tick) no restrictions

Graphical interface

Available since

version 1.19.0 (for Neuron Power Engineer)

Functionality

The block divides the time value entered at input IN1 by a numerical value entered at input IN2 (=  IN1 / IN2). The block returns the result of this division in format TIME.

Unexpected calculation of values with a REAL value at input IN2 due to a higher calculation precision

If a REAL value is connected to input IN2, a LREAL value is used for the internal calculation (instead of a REAL value). Thus, a higher calculation precision is achieved than is actually required for REAL. The calculation of values with a lower calculation precision for REAL values is not supported.

Example: With a REAL value for IN2, the value TIME#3000d is calculated. This calculation is executed due to the higher calculation precision. If the same value is connected to IN2 but with data type LREAL, the same value TIME#3000d is calculated.
In comparison: In case of an internal calculation with REAL, the value TIME#2999d23h59m51s808ms would be returned.

Workaround: If you want to calculate precise values, connect the input IN2 of the DIV_TIME block with a LREAL value.

No check of invalid connections

For this block, invalid connections are not checked by Neuron Power Engineer (except for the checks listed under "Internal error diagnostic for block"). Therefore, enter code in your application to detect invalid connections (e.g. IF-statements). See "Examples for invalid Connections".

See "IEC-blocks for the application" for information what the consequences of an invalid connection might be.

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN1

TIME

time value

IN2

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM(1)

numerical value 

Return value:

TIME

 

(1) = DIV_TIME uses the highest possible accuracy for the calculations. That means: If a REAL value is connected to IN2Neuron Power Engineer uses a LREAL value for the calculation and a division by a REAL value might result in a not expected result. If you need large values or values with many decimal places, best practice is to use a LREAL value.

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Internal error diagnostic for block

The block checks for a division by 0 before it is executed.
In this error case, the output ENO of the block is set to value FALSE (or an equivalent).

Example for usage within ST-editor

The calculated values are evaluated by using the Assert block.

FUNCTION_BLOCK ExampleDivTime
  VAR
    result : TIME;
  END_VAR
 
  result := DIV_TIME(IN1 := T#1m40s, IN2 := 2.0);
 
  Assert(result = TIME#50s); 
END_FUNCTION_BLOCK

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.

Examples for invalid connections

An invalid connection due to →overflows or →underflows might occur during a calculation using DIV_TIME. As your used →target system might influence the usage of →time literals in Neuron Power Engineer (see "Properties and restrictions specific to the target system"), an overflow/underflow might occur for different return values when using different target systems.

Example for invalid connections
DIV_TIME(IN1 := TIME#89468321d19h, IN2 := REAL#3.0e-30); (* For the built-in PLC, this calculuation returns a negative value. *)