Modulo (MOD)
The MOD instruction divides Source A by Source B and places the remainder in the Destination.
Available Languages
- Ladder Diagram
- Function Block
- Structured Text
This instruction is not available in structured text. *
* There is no equivalent structured text instruction. Use the operator in an expression.
Operands
- Ladder Diagram
*Data Conversion: SINT and INT tags are sign-extended.
- Function Block
- Structured Text
Use MOD as an operator in an expression. This expression divides sourceA by sourceB and stores the remainder in dest.
dest := sourceA MOD sourceB;
Structure
Example
Divide dividend by divisor and place the remainder in remainder. In this example, 3 goes into 10 ten times, with a remainder of 1.
- Ladder Diagram
- Function Block
- Structured Text
remainder := dividend MOD divisor;
File name: PLC-21_IS_CMI-MOD.pdf
File size: 418.71 KB
Available Languages
- Ladder Diagram
- Function Block
- Structured Text
This instruction is not available in structured text. *
* There is no equivalent structured text instruction. Use the operator in an expression.
Operands
- Ladder Diagram
Operand | Type | Format | Description |
Source A* | SINT INT DINT REAL | Immediate tag | value of the dividend |
Source B* | SINT INT DINT REAL | immediate tag | value of the divisor |
Destination | SINT INT DINT REAL | tag | tag to store the result |
- Function Block
Operand | Type | Format | Description |
MOD tag | FBD_MATH | structure | MOD structure |
- Structured Text
Use MOD as an operator in an expression. This expression divides sourceA by sourceB and stores the remainder in dest.
dest := sourceA MOD sourceB;
Structure
Input Parameter | Data Type | Description |
EnableIn | BOOL | Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. |
SourceA | REAL | Value of the dividend. Valid = any float |
SourceB | REAL | Value of the divisor. Valid = any float |
Output Parameter | Data Type | Description |
EnableOut | BOOL | Enable output. |
Dest | REAL | Result of the math instruction. Arithmetic status flags are set for this output. |
Example
Divide dividend by divisor and place the remainder in remainder. In this example, 3 goes into 10 ten times, with a remainder of 1.
- Ladder Diagram
- Function Block
- Structured Text
remainder := dividend MOD divisor;
File name: PLC-21_IS_CMI-MOD.pdf
File size: 418.71 KB
0 comments :