P4: PLC for SINUMERIK 828D
14.3 Programming
Basic Functions
1106
Function Manual, 09/2011, 6FC5397-0BP40-2BA0
Advantages of the data type check
The data type check helps you to avoid programming errors that have been widely propagated through the
program. If an operation supports numbers with signs, the Programming Tool PLC828 designates the use of
unsigned numbers in addresses of operations.
Example:
The comparison < I is an operation with sign. -1 is less than 0 for addresses with sign. However, if the operation
< I supports unsigned data types, then the programming itself must ensure that the following does not occur:
While a program is being executed, an unsigned value of 40.000 is actually smaller than 0 for the operation < I. If
it cannot be guaranteed that the unsigned numbers for signed operations do not exceed the positive and
negative limit values, then unpredictable events can occur in your program or in the mode of operation of the
control.
Working with operations to convert the data type
Conversion operations convert one data type into another. The Programming Tool PLC828 supports the
following conversion operations to transfer values between the elementary data types.
14.3.2.5
Constants
Range of constants
Conversion of data
types
Conversion operations
Complete data type
check, permissible
addresses
Data check,
permissible addresses
INT in BCD
I_BCD
IN: INT
OUT: INT
IN: WORD, INT
OUT: WORD, INT
BCD in INT
BCD_I
IN: INT
OUT: INT
IN: WORD, INT
OUT: WORD, INT
DINT in REAL
DI_R
IN. DINT
OUT: REAL
IN: DWORD, DINT
OUT: REAL
REAL in DINT
(ROUND)
TRUNC
IN: REAL
OUT: DINT
IN: REAL
OUT: DWORD, DINT
Range without sign
Range with sign
Size of the data
Decimal:
Hexadecimal:
Decimal:
Hexadecimal:
B (Byte)
0 ... 255
0 ... FF
-128 ... +127
80 ... 7F
W (Word)
0 ... 65535
0 ... FFFF
-32768 ... +32767
8000 ... 7FFF
D (Double word)
0 ... 4294967295
0 ... FFFF FFFF
-2147483648 ...
+2147483647
8000 0000 ... 7FFF FFFF
Size
Decimal real number (positive)
Decimal real number (negative)
D (Double word)
+1.175495E-38 ... +3.38
-1.175495E-38 ... -3.38