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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/0_b5e9b4f86ce43ca65bd79c894c4a924c.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/1_274a01ad7ad7ad7d73d5f0b399ae5db2.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/2_068ae40523a24c9ef54edefd375e542d.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/3_8f173d0eaffc4b90c0c0361b8f37cc17.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/4_6a0fe32c3736658bde52846b7df05e01.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/5_bde7cf9049e122a728d29f2213bb2b67.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/6_e746f170e2a60a973f6f1b2abdbfa5a7.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/7_40af9ca5d4af4f53bc05e0396f2436f0.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/8_3019f422209a6593f02fad5560f36b79.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/9_575eda61e93c7ad9d05928580213fd9b.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/10_b0b50d3fc83d45f294693120c22574ab.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/11_007b98d50fd1de35a654e100103ddac6.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/12_66974540156c425dcc8bdd09f8dd4821.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/13_eb4671cfc1e89a1e9b279c3afd578c28.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/14_84f7247f3b4764f31ec8201051b4ba7b.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/15_8558d3a641379e9d3e663b443adb34c1.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/16_246ed95454d12f21d9fc0259316b750d.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/17_0ed54260213d71c024f0140fc341b79b.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/18_23621f7b9ade353e3aeff9f9ee30d871.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/19_b4028a94b255f1e2b9bb6e172b05f60b.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/20_2e4dbae43873d9c4000502fac3c29d73.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/19_b4028a94b255f1e2b9bb6e172b05f60b.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/22_c59d14d6afca192d923f51038e62f112.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/23_aa694503e005b7e28b579defab48c1a7.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/24_aba3194620d9ac9fb1619e618b9258b3.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/25_bdbc45dfae94e3cfb72365a24e5dca34.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/26_a6f1db85f80a0f035ad7976f29286bc8.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/27_0356e33127b17baa9eca07b56fbee8fd.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/28_bab16c16a73c729adee0420d419a032e.png) | 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
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/29_e248177353bf8be506e6e3bf2be0fa48.png) | 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 |
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/30_e9936bbee4f8352e697f6909a9f0b23a.png) | 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 |
Пример и биты слова состояния округления до ближайшего меньшего целого числа
![transfer commands and conversions in the contact plan](/th/25/blogs/id5233/31_d78c38c05fc8067d472bce24b07c66fd.png) | Если состояние сигнала входа 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
Contact Programming / LAD
Terms: Contact Programming / LAD