Value assignment
The Assign Value command allows you to pre-supply a variable with a specific value. The value specified at the IN input is copied to the address specified at the OUT output. ENO has the same signal state as EN.
Using the MOVE block, the Assign Value command can copy all data types with a length of 8, 16, or 32 bits. User-defined data types, such as arrays or structures, must be copied using the built-in Direct Word Move system function [direct word forwarding].
The assign value command is affected by the Master Control Relay (MCR).
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 |
| IN | All data types are 8, 16, and 32 bits long. | I, Q, M, D, L or constant | Baseline value |
| Out | All data types are 8, 16, and 32 bits long. | I, Q, M, D, L | Destination Address |
Example and bits of the status word of the value assignment command
| The command is executed if the signal state of input I 0.0 is 1. The contents of the memory word MW10 are copied into the data word 12 of the open DB. If the operation is completed, the output of Q 4.0 is 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | - | - | - | one | one | x |
Example and bits of the status word of the value assignment command
Binary to decimal to integer conversion
The Binary to Decimal to Integer command reads the contents of the IN input parameter as a three-digit binary-decimal number (BCD, ± 999) and converts the number to an integer value. The output parameter OUT provides the result. ENO and EN always have the same signal state. If the bit-decimal bit is in the invalid range from 10 to 15, then a BCDF error occurs during the conversion attempt.
- The CPU goes to STOP mode. A message “BCD Conversion Error” with the event identification number 2521 is written to the diagnostic buffer.
- Called OB121 if programmed.
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 |
| IN | WORD | I, Q, M, D, L | Binary Decimal |
| Out | Int | I, Q, M, D, L | Binary decimal integer value |
Example and bits of the state word of the conversion of a binary decimal to integer
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the word memory MW10 are read as a three-digit binary decimal and converted to integer. The result is stored in the word memory MW12. If the conversion is not performed, then the Q 4.0 output signal state is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | - | - | 0 | one | one | x |
Example and bits of the state word of the conversion of a binary decimal to integer
Convert integer to binary decimal
The Convert an integer to binary-decimal command reads the contents of the input parameter IN as an integer value and converts this value into a three-digit number binary-decimal (BCD, ± 999). The output parameter OUT provides the result. If overflow occurs, then 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 |
| IN | Int | I, Q, M, D, L | Integer |
| Out | WORD | I, Q, M, D, L | Result in binary coded decimal format |
Example and bits of the word state of the conversion of an integer to binary decimal
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the word memory MW10 are read as an integer and converted to a three-digit binary-decimal number. The result is stored in the word memory MW12. If an overflow has occurred, the signal state Q 4.0 is 1. If the state of the signal at the EN input is 0 (that is, no conversion is performed), then the signal state of the Q 4.0 output is also equal to 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | x | x | 0 | one | x | x |
Example and bits of the word state of the conversion of an integer to binary decimal
Convert an integer to a double integer
The command Convert an integer to a double integer reads the contents of the input parameter IN as an integer and converts the integer into a double integer. The output parameter OUT provides the result. ENO and EN always have the same signal state.
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 |
| IN | Int | I, Q, M, D, L | Convertible value |
| Out | Dint | I, Q, M, D, L | Result |
Example and bits of the state word of converting an integer number to a double integer
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the word memory MW10 are read as an integer and converted to a double integer. The result is stored in the double word of memory MD12. If the conversion is not performed, the n signal status of the Q 4.0 output is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | - | - | 0 | one | one | x |
Example and bits of the state word of converting an integer number to a double integer
Binary to decimal conversion to double integer
The command to convert a binary-decimal number to a double integer reads the contents of the input parameter IN as a seven-digit binary decimal number (BCD, ± 9 999 999) and converts this number into a double integer. The output parameter OUT provides the result. ENO and EN always have the same signal state.
If the bit-decimal bit is in the invalid range from 10 to 15, then a BCDF error occurs during the conversion attempt.
- The CPU goes to STOP mode. A message “BCD Conversion Error” with the event identification number 2521 is written to the diagnostic buffer.
- Called OB121 if programmed.
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 |
| IN | DWORD | I, Q, M, D, L | Binary Decimal |
| Out | Dint | I, Q, M, D, L | Binary decimal value double integer numbers numbers |
An example and bits of a binary to decimal to double integer state word
| If the signal state of input I 0.0 is 1, then the conversion is performed. The content of the MD8 double word is read as Binary decimal and converted to double integer. the result is stored in the double word of memory MD12. If the conversion is not performed, then the Q 4.0 output signal state is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | - | - | 0 | one | one | x |
An example and bits of a binary to decimal to double integer state word
Convert double integer to binary decimal
This command reads the contents of the input parameter IN as a double integer and
converts this value to a seven-digit binary decimal number (± 9,999,999). The output parameter OUT provides the result. If overflow occurs, then 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 |
| IN | Dint | I, Q, M, D, L | Double integer |
| Out | DWORD | I, Q, M, D, L | Result in binary decimal |
Example and bits of the word state of converting double integer to binary decimal
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the MD8 memory double word are read as a double integer and converted to a seven-digit binary-decimal number. The result is stored in the double word of memory MD12. If an overflow occurs, the signal state of the output, Q 4.0 is 1. If the state of the signal at the EN input is 0 (that is, no conversion is performed), then the signal state of the Q 4.0 output is also equal to 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | x | x | x | one | x | x |
Example and bits of the word state of converting double integer to binary decimal
Converting a double integer to a floating point number
The command reads the contents of the input parameter IN as a double integer and converts this value into a real number. The output parameter OUT provides the result. ENO and EN always have the same signal state.
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 |
| IN | Dint | I, Q, M, D, L | Double integer |
| Out | REAL | I, Q, M, D, L | Result in real number format |
Example and bits of the state word converting a double integer to a floating point number
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the MD8 double word are read as a double integer and converted to a real number. The result is stored in the double word of memory MD12. If the conversion is not performed, then the Q 4.0 output signal state is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | one | - | - | - | - | 0 | one | one | x |
Example and bits of the state word converting a double integer to a floating point number
Supplement an integer to one
The command Add a single integer to one reads the contents of the input parameter IN and executes the bitwise command of the Boolean logic Bitwise exclusive OR on the words and the FFFFH mask (see section 10.5), so that each bit of the word changes its value to the opposite. The output parameter OUT provides the result. ENO and EN always have the same signal state.
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 |
| IN | Int | I, Q, M, D, L | Input value |
| Out | Int | I, Q, M, D, L | The addition of an integer to units |
Example and bits of the complement state word of unity to one
| If the signal state of input I 0.0 is 1, then the conversion is performed. Every bit in MW8 is inverted. MW8 = 00000000 00000000 -> MW10 = 11111111 11111111 If the conversion is not performed, then the Q 4.0 output signal state is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | - | - | x | one | x | x |
Example and bits of the complement state word of unity to one
Addition of double integer to one
The command Add a double integer to one reads the contents of the input parameter IN and executes the bitwise command of the Boolean logic Bitwise exclusive OR on double words over the word and mask FFFF FFFFH (see section 10.6), so that each bit of the word changes its value to the opposite. The output parameter OUT provides the result. ENO and EN always have the same
signal state.
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 |
| IN | Dint | I, Q, M, D, L | Input value |
| Out | Dint | I, Q, M, D, L | Addition of double integer to one |
Example and bits of the state word of the complement of a double integer to one
| If the signal state of input I 0.0 is 1, then the conversion is performed. Each bit of the double word MD8 varies: MD8 = FFFF FFFF -> MD10 = 0000 0000. If the conversion is not performed, the state of the Q 4.0 output signal is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | - | - | x | one | x | x |
Example and bits of the state word of the complement of a double integer to one
Supplement up to two integers
This command reads the contents of the input parameter IN and changes its sign (for example, from a positive value to a negative). The output parameter OUT provides the result. If the state of the EN signal is 0, then the state of the ENO signal is 0. If the state of the EN signal is 1 and an overflow occurs, the state of the ENO signal 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 |
| IN | Int | I, Q, M, D, L | Input value |
| Out | Int | I, Q, M, D, L | Supplement up to two integers |
Example and state word bits complement an integer up to two
| If the signal state of input I 0.0 is 1, then the conversion is performed. The value of the word MW8 is transmitted through OUT with the opposite sign to the word of memory MW10, as shown in the following example: MW8 = +10 -> MW10 = - 10. If the state of the EN signal is 1 and an overflow occurs, the state of the ENO signal is 0 and the state The output signal of Q 4.0 is 1. If the conversion is not performed, then the state of the output signal Q 4.0 is 1 (ENO = EN). |
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 state word bits complement an integer up to two
Addition of double integer to two
The command is identical to the previous one, the only difference is that the operation is performed on double numbers.
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 |
| IN | Dint | I, Q, M, D, L | Input value |
| Out | Dint | I, Q, M, D, L | Supplement of double integer numbers up to two |
Example and bits of the state word of the complement of a double integer up to two
| If the signal state of input I 0.0 is 1, then the conversion is performed. The value of the word MW8 is transmitted through OUT with the opposite sign to the word of memory MW10, as shown in the following example: MW8 = +10 -> MW10 = - 10. If the state of the EN signal is 1 and an overflow occurs, the state of the ENO signal is 0 and the state The output signal of Q 4.0 is 1. If the conversion is not performed, then the state of the output signal Q 4.0 is 1 (ENO = EN). |
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 complement of a double integer up to two
Changing the sign of a floating point number
This command changes the sign bit of a number (for example, from 0 for plus to 1 for minus). Bits order and mantissa remain unchanged. The output parameter OUT provides the result. ENO and EN always have the same signal state.
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 |
| IN | REAL | I, Q, M, D, L | Input value |
| Out | REAL | I, Q, M, D, L | Result representing input value with the opposite sign. |
Example and bits of the floating point state change word word
| If the signal state of input I 0.0 is 1, then the conversion is performed. The double word value of the MD8 memory is transmitted via OUT with the opposite sign to the double word of memory MD12, as shown in the following example: MD8 = +6.234 x 10-3 -> MD12 = -6.234 x 10-3 If the conversion is not performed, the signal state of the output Q 4.0 is 1 (ENO = EN). |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | - | - | 0 | x | x | one |
Example and bits of the floating point state change word word
Round to double integer
The Round to double integer command reads the contents of the input parameter IN as a real number and converts this number to a double integer, rounding it to the nearest integer. The result is the nearest integer component of a real number (that is, the nearest integer).
The output parameter OUT provides the result. If overflow occurs, then 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 |
| IN | REAL | I, Q, M, D, L | Rounding value |
| Out | Dint | I, Q, M, D, L | IN value, rounded to the nearest integer. |
Example and word bits of rounding state to double integer
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the MD8 double word are read as a real number and converted to a double integer. The result of this rounding function to the nearest double integer is stored in memory double word MD12. If an overflow occurs, the signal state of the output Q 4.0 is 1. If the state of the signal at the EN input is 0 (that is, no conversion is performed), then the signal state of the output Q 4.0 is also equal to 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | x | x | x | one | x | x |
Example and word bits of rounding state to double integer
The selection of the integer part
The Select integer part of a number command reads the contents of the input parameter IN as a real number and converts this number into a double integer, rounding it to the nearest integer less than or equal to it. The result is the integer component of a given real number (that is, the integer part of a real number). The output parameter OUT provides the result. If overflow occurs, then 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 |
| IN | REAL | I, Q, M, D, L | Rounding value |
| Out | Dint | I, Q, M, D, L | The integer part of the IN value |
Example and bits of the integer state highlight word
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the MD8 double word are read as a real number and converted to a double integer. The whole part is the result and is stored in the double word of memory MD12. If an overflow occurs, the signal state of the output Q 4.0 is 1. If the state of the signal at the EN input is 0 (that is, no conversion is performed), then the signal state of the output Q 4.0 is also 1 |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | x | x | x | one | x | x |
Example and bits of the integer state highlight word
Round to the nearest larger integer
The Round to the nearest larger integer command reads the contents of the input parameter IN as a real number and converts this number into a double integer. The result is the smallest integer that is greater than or equal to a given real number. The output parameter OUT provides the result. If overflow occurs, then 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 |
| IN | REAL | I, Q, M, D, L | Convertible value |
| Out | Dint | I, Q, M, D, L | Result |
Example and word bits of the rounding state to the nearest larger integer
| If the signal state of input I 0.0 is 1, then the conversion is performed. The contents of the double word of memory MD8 are read as a real number and converted to a double integer with rounding to the nearest greater (or equal) integer. The result is stored in the double word of memory MD12. If an overflow occurs, the signal state of the output Q 4.0 is 1. If the state of the signal at the EN input is 0 (that is, no conversion is performed), then the signal state of the output Q 4.0 is also equal to 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | x | x | x | one | x | x |
Example and word bits of the rounding state to the nearest larger integer
\
Округление до ближайшего меньшего целого числа
Команда Округлить до ближайшего меньшего целого числа считывает содержимое входного параметра IN как вещественное число и преобразует это число в двойное целое число. Результатом является наибольшее целое число, которое меньше заданного вещественного числа или равно ему. Выходной параметр OUT предоставляет результат. Если происходит переполнение, то ENO равен 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 |
| IN | REAL | I, Q, M, D, L | Преобразуемое значение |
| Out | Dint | I, Q, M, D, L | Result |
Пример и биты слова состояния округления до ближайшего меньшего целого числа
| Если состояние сигнала входа I 0.0 равно 1, то преобразование выполняется. Содержимое двойного слова памяти MD8 считывается как вещественное число и преобразуется в двойное целое число с округлением до ближайшего меньшего (или равного) целого числа. Результат сохраняется в двойном слове памяти MD12. Если происходит переполнение, то состояние сигнала выхода Q 4.0 равно 1. Если состояние сигнала на входе EN равно 0 (то есть преобразование не выполняется), то состояние сигнала выхода Q 4.0 также равно 1. |
Status word bits |
| BR | CC 1 | CC 0 | Ov | OS | OR | Sta | Rlo | FC |
Record | x | - | - | x | x | x | one | x | x |
Пример и биты слова состояния округления до ближайшего меньшего целого числа
Comments
To leave a comment
Industrial programming. programming of controllers
Terms: Industrial programming. programming of controllers