|
Type
| Function |
|
Description
| The overloaded function TO_DWORD converts an input value of various data types into an output value of the data type DWORD (see description of the input for the supported data types). |
|
Parameters
| Input
IN
| Data type: | The function is available for the following input data types:
- BOOL, BYTE, WORD, DWORD, LWORD
- Integers: SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT
- Floating point numbers: REAL
- STRING, WSTRING
|
Output
OUT
|
|
Conversion rules
|
STRING conversion
Note
Controller stop on string error: The controller can be automatically stopped when a string error occurs. This allows you to locate the error in your project. To enable the automatic stop of the controller in case of a string error, activate the button in the Cockpit toolbar of the controller. |
|
|
Error behavior
| Error behavior
The following table shows the errors which may occur while executing the function and the value returned by the function in the corresponding error case. As described, the value returned by the function in the error case depends on the value of the input (for example, if the input value is no valid bit literal, the function returns the value 0x00).
| Error case | Output value |
| Overflow: input byte size too large | Overflow value |
| REAL: NaN
Note: ENO stays true in the error case. | Byte representation |
| REAL: Inf+
Note: ENO stays true in the error case. | Byte representation |
| REAL: Inf-
Note: ENO stays true in the error case. | Byte representation |
| String no valid bit literal or int number literal (with whitespaces) | 0x00 |
| String: bit literal overflow | Overflow value |
|
|
Examples
| Examples in ST
out := TO_DWORD(LINT#4294967295); (* results in 16#FFFFFFFF *)
out := TO_DWORD(LINT#4294967296); (* results in 16#00000000 *)
out := TO_DWORD(INT#-1); (* results in 16#0000FFFF *)
out := TO_DWORD(SINT#-16); (* results in 16#000000F0 *)
out := TO_DWORD(LWORD#16#00000000ABABCD00); (* results in 16#ABABCD00 *)
out := TO_DWORD('LWORD#16#00000000A0A0CA0D'); (* results in 16#A0A0CA0D *)
|
|
Additional information
| EN/ENO behavior
The POU is only executed if TRUE is applied to the EN input. If EN = FALSE, the POU is not executed and ENO = FALSE indicates the inactivity.
If any of the errors listed under "Error behavior" occurs while executing the function, ENO is set to FALSE.
Note
ENO stays TRUE for an input value of data type REAL that is not a real number (NaN) or a positive (Inf+) or negative infinity (Inf-) value. |
|