Addition of integers
The state of signal 1 at the enable input (EN) activates the addition of integers command. This command adds inputs IN1 and IN2. The result can be queried at the OUT output. If the result is outside the acceptable range for integers, then the OV and OS bits of the status word are 1, and ENO is 0.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Int | I, Q, M, D, L | First term |
| IN2 | Int | I, Q, M, D, L | Second term |
| Out | Int | I, Q, M, D, L | Amount |
Example and bits of the word of the addition state of integers
| The state of signal 1 at input I 0.0 activates the ADD_I block. The result of the addition of MW0 + MW2 is placed in the memory word MW10. If the result is outside the acceptable range for integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the word of the addition state of integers
Addition of double integers
This function acts just like the previous one, the only difference is that it adds double integers.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Dint | I, Q, M, D, L | First term |
| IN2 | Dint | I, Q, M, D, L | Second term |
| Out | Dint | I, Q, M, D, L | Amount |
Example and bits of the word of the addition state of double integers
| The state of signal 1 at input I 0.0 activates the ADD_DI block. The result of the addition of MD0 + MD4 is placed in the double word of memory MD10. If the result falls outside the acceptable range for double integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the word of the addition state of double integers
Subtract integers
The state of signal 1 at the enable input (EN) activates the command Subtract integers. This command subtracts input IN2 from IN1. The result can be queried at the OUT output. If the result is outside the allowable range for integers, then the OV and OS bits are 1, and ENO is 0.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Int | I, Q, M, D, L | Minuend |
| IN2 | Int | I, Q, M, D, L | Subtrahend |
| Out | Int | I, Q, M, D, L | Difference |
Example and bits of the word of the subtraction state of integers
| The state of signal 1 at input I 0.0 activates the SUB_I block. The result of the subtraction MW0 - MW2 is placed in the memory word MW10. If the result is outside the acceptable range for integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the word of the subtraction state of integers
Subtract double integers
This function acts just like the previous one, the only difference is that it subtracts double integers.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Dint | I, Q, M, D, L | Minuend |
| IN2 | Dint | I, Q, M, D, L | Subtrahend |
| Out | Dint | I, Q, M, D, L | Difference |
Example and bits of the state word of the subtraction of double integers
| The state of signal 1 at input I 0.0 activates the SUB_DI block. The result of the subtraction MD0 - MD4 is placed in the memory double word MD10. If the result falls outside the acceptable range for double integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the state word of the subtraction of double integers
Multiplication of integers
The state of signal 1 at the enable input (EN) activates the Multiply integers command. This command multiplies IN1 input by IN2. The result can be queried at the output OUT. If the result is outside the allowable range for integers, then the OV and OS bits are 1, and ENO is 0.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Int | I, Q, M, D, L | First factor |
| IN2 | Int | I, Q, M, D, L | Second factor |
| Out | Dint | I, Q, M, D, L | Composition |
Example and bits of the word of the multiplication state of integers
| The state of signal 1 at input I 0.0 activates the MUL_I block. The result of the multiplication MW0 x MW2 is placed in the memory double word MD10. If the result falls outside the acceptable range for double integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the word of the multiplication state of integers
Multiplication of double integers
This function acts just like the previous one, the only difference is that it multiplies double integers.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Dint | I, Q, M, D, L | First factor |
| IN2 | Dint | I, Q, M, D, L | Second factor |
| Out | Dint | I, Q, M, D, L | Composition |
Example and bits of the word of the multiplication state of double integers
| The state of signal 1 at input I 0.0 activates the MUL_DI block. The result of the multiplication MD0 x MD4 is placed in the memory double word MD10. If the result falls outside the acceptable range for double integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the word of the multiplication state of double integers
Division of integers
The state of signal 1 at the enable input (EN) activates the command Integer division . This command divides IN1 input to IN2. The quotient from this division (rounded to integer result) can be interrogated at the output OUT. The remainder of the division can not be polled. If the quotient is outside the allowable range for integers, then the OV and OS bits are 1, and ENO is 0.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Int | I, Q, M, D, L | Dividend |
| IN2 | Int | I, Q, M, D, L | Divider |
| Out | Int | I, Q, M, D, L | Private |
Example and bits of integer division state word
| The state of signal 1 at input I 0.0 activates DIV_I. The quotient from the division of MW0 into MW2 is placed in the memory word MW10. If the quotient is outside the acceptable range for integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of integer division state word
Division of double integers
This function acts exactly the same as the previous one, the only difference is that it divides double integers. The command Divide double integers saves the quotient as one 32-bit value in DINT format and does not form the remainder of the division.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Dint | I, Q, M, D, L | Dividend |
| IN2 | Dint | I, Q, M, D, L | Divider |
| Out | Dint | I, Q, M, D, L | Private |
Example and bits of the state word of division of double integers
| The state of signal 1 at input I 0.0 activates the DIV_DI block. The partial result of dividing MD0 by MD4 is placed in memory double word MD10. If the quotient is outside the allowable range for double integers or the state of the signal at input I 0.0 is 0, then the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the state word of division of double integers
Getting the remainder of dividing a double integer
The state of the signal “1” on the enable input (EN) activates the command Obtaining the remainder of dividing a double integer. This operation divides the input IN1 to IN2. The remainder of the division can be queried at the output OUT. If the result is outside the allowable range for double integers, then the OV and OS bits are 1, and ENO is 0.
LAD block | Options | Data type | Memory area | Description |
| En | Bool | I, Q, M, D, L | Permissive entry |
| ENO | Bool | I, Q, M, D, L | Permissive exit |
| IN1 | Dint | I, Q, M, D, L | Dividend |
| IN2 | Dint | I, Q, M, D, L | Divider |
| Out | Dint | I, Q, M, D, L | Remainder |
Example and bits of the state word of getting the remainder of dividing a double number
| The state of signal 1 at input I 0.0 activates the MOD block. The remainder of dividing MD0 by MD4 is stored in the memory double word MD10. If the result falls outside the allowable range for double integers or the state of the signal at input I 0.0 is 0, the output Q 4.0 is set. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | x | x | x | x | x | one | x | x |
Example and bits of the state word of getting the remainder of dividing a double number
Estimation of the bits of the status word after integer operations
The basic math commands affect the following bits of the status word:
A dash (-) in the table indicates that the result of the operation has no effect.
on this bit.
Signal state of the status word bits
Valid range for the result of an operation with integers (16 and 32 bits) | Status word bits |
| CC1 | CC0 | Ov | OS |
0 (zero) | 0 | 0 | 0 | - |
16 bits: –32 768. result <0 (negative number) 32 bits: –2 147 483 648. result <0 (negative number) | 0 | one | 0 | - |
16 bits: 32,767. result> 0 (positive number) 32 bits: 2,147,483,647. result> 0 (positive number) | one | 0 | 0 | - |
The state of the signal bits of the state word: the result is outside the permissible range
Invalid range for operation result with integers (16 and 32 bits) | Status word bits |
| CC1 | CC0 | Ov | OS |
16 bits: result> 32,767 (positive number) 32 bits: result> 2,147,483,647 (positive number) | one | 0 | one | one |
16 bits: result <–32 768 (negative number) 32 bits: result <–2 147 483 648 (negative number) | 0 | one | one | one |
The state signal bits of the status word: operations with integers
(32 bits) + D, / D and MOD
Team | Status word bits |
| CC1 | CC0 | Ov | OS |
+ D: result = –4 294 967 296 | 0 | 0 | one | one |
/ D or MOD: divide by 0 | one | one | one | one |
Comments
To leave a comment
Industrial programming. programming of controllers
Terms: Industrial programming. programming of controllers