de:s7:tia_datatypes

TIA Portal data type conversions

Jump to conversions: Konvertern

The following table summarizes the supported and unsupported data types:

data typenamememory requirementssupportedvalue rangeconverters
binary numbers
BOOLbool1bit
(S7-1500
opt:
1 byte)
S7-300/400,
S7-1200,
S7-1500
FALSE or TRUE
BOOL#0 or BOOL#1
BOOL#FALSE or BOOL#TRUE
16 BOOL → WORD and BYTE
WORD → 16 BOOL
BYTE → 8 BOOL
BYTEbyte8 bitS7-300/400,
S7-1200,
S7-1500
8 bit bit pattern,
Dec: 0..255, Hex: 00..FF
16 BOOL → WORD und BYTE
BYTE → 8 BOOL
DT → WORD/BYTE
WORDword16 bitS7-300/400,
S7-1200,
S7-1500
16 bit bit pattern16 BOOL → WORD and BYTE
WORD → 16 BOOL
STRING → DB REGS
DB REGS → STRING
DT → WORD/BYTE
WORD → REAL
REAL → WORD
DWORDdouble word32 bitS7-300/400,
S7-1200,
S7-1500
32 bit bit pattern
LWORDlong word64 bitS7-1200,
S7-1500
64 bit bit pattern
Integers

SINTshort integer8 bitS7-1200,
S7-1500
Dec: -128..127, Hex: 0..7F
INTinteger16 bitS7-300/400,
S7-1200,
S7-1500
Dec: -32768..32767,
Hex: 0..7FFF
DINTdouble integer32 bitS7-300/400,
S7-1200,
S7-1500
Dec: -2147483648..+2147483647,
Hex: 0..#7FFFFFFF
USINTunsigned
short integer
8 bitS7-1200,
S7-1500
Dec: 0..255, Hex: 00..FF
UINTunsigned
integer
16 bitS7-1200,
S7-1500
Dec: 0..65535, Hex: 0000..FFFF
UDINTunsigned
double integer
32 bitS7-1200,
S7-1500
Dec: 0..4294967295,
Hex: 00000000..FFFFFFFF
LINTlong integer64 bitS7-1500Dec: -9223372036854775808..
+9223372036854775807,
Hex: 0000000000000000..
7FFFFFFFFFFFFFFF
ULINTunsigned
long integer
64 bitS7-1500Dec: 0..18446744073709551615,
Hex: 0000000000000000..
FFFFFFFFFFFFFFFF
floating point numbers

REALreal32 bitS7-300/400,
S7-1200,
S7-1500
-3.402823e+38..-1.175 495e-38 and
+1.175 495e-38..+3.402823e+38
WORD → REAL
REAL → WORD
LREALlong real64 bitS7-1200,
S7-1500
-1.7976931348623158e+308
..-2.2250738585072014e-308 and
+2.2250738585072014e-308
..+1.7976931348623158e+308
S5 Time

S5TIMES5 time16 bitS7-300/400,
S7-1500
S5T#0H_0M_0S_0MS..
S5T#2H_46M_30S_0MS
S7 Time

TIMEtime32 bitS7-300/400,
S7-1200,
S7-1500
T#-24d20h31m23s648ms..
T#+24d20h31m23s647ms
LTIMElong time64 bitS7-1500LT#-106751d23h47m
16s854ms775us808ns..
LT#+106751d23h47m
16s854ms775us807ns
Characters

CHARcharacter8 bitS7-300/400,
S7-1200,
S7-1500
ASCII character set
WCHARword char16 bitS7-1200,
S7-1500
16 bit Unicode
STRINGstringLong
+ 2 byte
S7-300/400,
S7-1200,
S7-1500
0 to 254 charactersSTRING → DB REGS
DB REGS → STRING
STRING → REAL/LINT
DT → STRING
WSTRINGword stringLong
+ 2 word
S7-1200,
S7-1500
0 to 16382 characters
Date types

DATEdate16 bitS7-300/400,
S7-1200,
S7-1500
D#1990-01-01..D#2168-12-31
TODtime_of_day32 bitS7-300/400,
S7-1200,
S7-1500
TOD#00:00:00.000..
TOD#23:59:59.999
LTODlong
time_of_day
64 bitS7-1500LTOD#00:00:00.000000000 ..
LTOD#23:59:59.999999999
DTdate_and_time64 bitS7-300/400,
S7-1500
Min.:
DT#1990-01-01-0:0:0
Max.:
DT#2089-12-31-23:59:59.999
DT → WORD/BYTE
DT → STRING
LDTlong
date_and_time
64 bitS7-1500Min.:
LDT#1970-01-01-0:0:0.000000000, 16#0
Max.:
LDT#2262-04-11-23:47:16.854775807,
16#7FFF_FFFF_FFFF_FFFF
DTLdate time long96 bitS7-1200,
S7-1500
Min.:
DTL#1970-01-01-00:00:00.0
Max.:
DTL#2554-12-31-23:59:59.999999999
Pointer
POINTERpointer48 bitS7-300/400,
S7-1500
-
ANYany type80 bitS7-300/400,
S7-1500
-
VARIANTvariant-S7-1200,
S7-1500
example:
P#M100.0 BYTE 10
P#DB1.DBX0.0 BYTE 10

What is not included in the table:
BCD numbers, BCD16 and BCD32. BCD numbers do not have their own data type. For a BCD number, use the data type WORD or DWORD and enter only the digits 0 to 9 and 0 or F for the sign in the format in hex W#16#xxxx or W#16#xxxx_xxxx. You can also use the notation c#0 through C#999 for a positive three-decade decimal number.

PLC data type (UDT), Anonymous structures (STRUCT), ARRAY, Parameter types (TIMER, COUNTER,..), System data types (IEC_TIMER, IEC_SCOUNTER,..)

The TIA Portal offers many conversions (and doesn't offer many more). These are summarized in the following table:

typesolutionconversions
IntCONVDInt, Real, Bcd16, USint, UInt, UDint, SInt, LReal und Char
DIntCONVInt,Real, Bcd32, USint, UInt, UDint, SInt, LReal und Char
RealCONVInt, DInt, USint, UInt, UDint, SInt und LReal
USintCONVInt, DInt, Real, UInt, UDint, SInt, LReal und Char
UIntCONVInt, DInt, Real, USint, UDint, SInt, LReal und Char
UDintCONVInt, DInt, Real, USint, UInt, SInt, LReal und Char
SIntCONVInt, DInt, Real, USint, UInt, UDint, LReal und Char
LRealCONVInt, DInt, Real, USint, UInt, UDint, SInt
CharCONVInt, DInt, USint, UInt, UDint, SInt und Char
Bcd16CONVInt
Bcd32CONVDInt

"CONV" utility

  1. In the Instructions palette of the block editor, open the Simple Instructions > Converter folder and insert the CONVERT instruction into your network using drag & drop.
  2. After inserting the instruction box, the data types of the instruction are not yet defined and therefore the placeholders ??? to ??? are still below the CONV designation. When you move the cursor over the left triangle of the first three question marks, an arrow button appears.
  3. Click on the left arrow button and select the desired data type for the input parameter IN (e.g. Int) from the drop-down box that opens.
  4. Repeat the process for the OUT output parameter and select the data type into which you want to convert the numerical value (e.g. Real) from the drop-down box on the right. In this example, a numerical value from the Int data type can now be converted to the Real data type (Int to Real).

Install converters in TIA Portal:

  1. ZIP File: Extract the downloaded zip file to a directory
  2. TIA Portal → Devices window → External source files → Add new external file → Select file
  3. Switch online to offline
  4. Right click on the inserted file in the list → Generate blocks from source
  5. Block can be overwritten warning → click OK
  6. Enjoy the time we gained with this copy (maybe write thanks to the author)
Converter_NameDownloadDescriptionImage_of_TIA

16 BOOL → WORD und BYTE

SCL DownloadConvert up to 16 bits to word and bytes (HI and LO)
device tested with TIA 15.1.
For WORD to BYTE conversion use only the first eight bits and set the rest to (fix) 0.
BOOL -> WORD und BYTE

WORD → 16 BOOL

SCL DownloadSplit word into 16 bits.
Block tested with TIA 15.1.
WORD -> 16 BOOL

BYTE → 8 BOOL

SCL DownloadSplit byte into 8 bits.
Block tested with TIA 15.1.
BYTE -> 8 BOOL

STRING → DB REGS

SCL DownloadThe purpose of the program is to prepare the text (string) for Modbus communication. The string is written to the target DB character by character. Attention! The program does not contain internal DB check (is there DB or DB length). The PLC can stop due to bad parameterization!
Block tested with TIA 15.1. Parameters:
text: input (string)
write_db_nr: Target DB number (DInt)
write_db_offset: Offset in DB in bytes (DInt)
fill_char : fill additional text area with this char (char)
Pic1
Pic2

DB REGS → STRING

SCL DownloadThe purpose of the program is to read the text (string) from the Modbus communication. The string is assembled from the Modbus registers. Attention! The program does not contain internal DB check (is there DB or DB length). The PLC can stop due to bad parameterization!
Block tested with TIA 15.1. Parameters:
read_db_nr: Source DB number (DInt)
read_db_offset: Offset in DB in bytes (DInt)
fill_char: empty (00) bytes replaced with this Char (Char)
textOut: output (String) \\
Pic
Reads 64 characters from register 32 (of DB6).

REAL → WORD

SCL Download
Unscale Real to Word. Block tested with TIA 16.

WORD → REAL

SCL Download
Scale Word to Real. Block tested with TIA 16.

Donate

If you have any further questions or have any issues that you can't handle, please contact me! » Impressum

~~socialite~~

2022/04/21 15:01
  • de/s7/tia_datatypes.txt
  • 2022/04/21 15:01
  • ()