DIV block
Short summary
Name |
DIV |
→POU type |
|
Category |
|
Conform to →IEC-standard |
|
Graphical interface |
|
Available since |
version 1.0.0 (for logi.CAD 3) |
Functionality
The mathematical function division is called: The block returns the quotient for IN1 / IN2.
Enter the value for the dividend at input IN1 and the value for the divisor at input IN2.
The result of the division of →integers is an integer of the same type with truncation toward zero (there is no rounding). Examples:
The division 7/3 returns the value{{2}}. The decimal part 0,333... is truncated
The division (-7)/3 returns the value -2. The decimal part 0,333... is truncated
No check of invalid connections
For this block, invalid connections are not checked by logi.CAD 3 (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 |
Description |
|
Inputs: |
IN1 |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
1st value (dividend) |
IN2 |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
2nd value (divisor) |
|
Return value: |
– |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
|
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:
"Blocks for safe logic" whether this block is supported for developing safety-relevant applications.
"Highlighting safe logic in the FBD-editor" for the effects when using the block as a block for safe logic .
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
PROGRAM Test
VAR
result : REAL;
END_VAR
result := DIV(IN1 :=
10.0
, IN2 :=
2.0
); (* The variable
'result'
evaluates to
'5.0'
. *)
END_PROGRAM
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.
DIV(IN1 := REAL#1.0e38, IN2 := REAL#3.0e-38);