MOD block
Short summary
Name |
MOD |
→POU type |
|
Category |
|
Conform to →IEC-standard |
no restrictions |
Graphical interface |
|
Available since |
version 1.0.0 (for logi.CAD 3) |
Functionality
The mathematical function modulo is called: The block returns the result for IN1 modulo IN2 (the remainder of the division IN1 / IN2).
Enter the value for the dividend at input IN1 and the value for the divisor at input IN2.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN1 |
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT) |
1st value (dividend) |
IN2 |
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT) |
2nd value (divisor) |
|
Return value: |
– |
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT) |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
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) and according to →IEC-standard the result will be set to 0.
Example for usage within ST-editor
PROGRAM Test
VAR
result : INT;
END_VAR
result := MOD(IN1 :=
10
, IN2 :=
3
); (* The variable
'result'
evaluates to
'1'
. *)
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.