de:s7:tia_datatypes

Differences

This shows you the differences between two versions of the page.

de:s7:tia_datatypes [2022/04/21 15:01] ()
 1:  1:
 +====== TIA Portal data type conversions ======
 +
 +Jump to conversions: [[#konvertern|Konvertern]]
 +===== TIA Portal data types =====
 +
 +The following table summarizes the supported and unsupported data types:
 +^data type^name^memory requirements^supported^value range^converters|
 +|**binary numbers**|||||
 +|{{anchor:bool:BOOL}} {{anchor:bool}}|bool|1bit \\ (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|[[#bool_to_word|16 BOOL → WORD and BYTE]] \\ [[#word_to_bool|WORD → 16 BOOL]] \\ [[#byte_to_bool|BYTE → 8 BOOL]]|
 +|{{anchor:byte:BYTE}}|byte|8 bit|S7-300/400, \\  S7-1200, \\  S7-1500|8 bit bit pattern, \\ Dec: 0..255, Hex: 00..FF|[[#bool_to_word|16 BOOL → WORD und BYTE]] \\ [[#byte_to_bool|BYTE → 8 BOOL]] \\ [[de:project_s7:acttimeconv|DT → WORD/BYTE]] \\ |
 +|{{anchor:word:WORD}}|word|16 bit|S7-300/400, \\   S7-1200, \\  S7-1500|16 bit bit pattern|[[#bool_to_word|16 BOOL → WORD and BYTE]] \\ [[#word_to_bool|WORD → 16 BOOL]] \\ [[#string_to_db_regs|STRING → DB REGS]] \\ [[#db_reg_to_string|DB REGS → STRING]] \\ [[de:project_s7:acttimeconv|DT → WORD/BYTE]] \\ [[#word_to_real|WORD → REAL]] \\ [[#real_to_word|REAL → WORD]]|
 +|{{anchor:dword:DWORD}}|double word|32 bit|S7-300/400, \\  S7-1200, \\  S7-1500|32 bit bit pattern||
 +|{{anchor:lword:LWORD}}|long word|64 bit|S7-1200, \\  S7-1500|64 bit bit pattern||
 +|**{{anchor:integers:Integers}}**|||||
 +|{{anchor:sint:SINT}}|short integer|8 bit|S7-1200, \\  S7-1500|Dec: -128..127, Hex: 0..7F||
 +|{{anchor:int:INT}}|integer|16 bit|S7-300/400, \\  S7-1200, \\  S7-1500|Dec: -32768..32767, \\  Hex: 0..7FFF||
 +|{{anchor:dint:DINT}}|double integer|32 bit|S7-300/400, \\  S7-1200, \\  S7-1500|Dec: -2147483648..+2147483647, \\  Hex: 0..#7FFFFFFF||
 +|{{anchor:usint:USINT}}|unsigned \\ short integer|8 bit|S7-1200, \\  S7-1500|Dec: 0..255, Hex: 00..FF||
 +|{{anchor:uint:UINT}}|unsigned \\ integer|16 bit|S7-1200, \\  S7-1500|Dec: 0..65535, Hex: 0000..FFFF||
 +|{{anchor:udint:UDINT}}|unsigned \\ double integer|32 bit|S7-1200, \\  S7-1500|Dec: 0..4294967295, \\  Hex: 00000000..FFFFFFFF||
 +|{{anchor:lint:LINT}}|long integer|64 bit|S7-1500|Dec: -9223372036854775808.. \\ +9223372036854775807, \\ Hex: 0000000000000000.. \\ 7FFFFFFFFFFFFFFF||
 +|{{anchor:ulint:ULINT}}|unsigned \\ long integer|64 bit|S7-1500|Dec: 0..18446744073709551615, \\ Hex: 0000000000000000.. \\ FFFFFFFFFFFFFFFF||
 +|**{{anchor:fpn:floating point numbers}}**|||||
 +|{{anchor:real:REAL}}|real|32 bit|S7-300/400, \\  S7-1200, \\  S7-1500|-3.402823e+38..-1.175 495e-38 and \\ +1.175 495e-38..+3.402823e+38|[[#word_to_real|WORD → REAL]] \\ [[#real_to_word|REAL → WORD]]|
 +|{{anchor:lreal:LREAL}}|long real|64 bit|S7-1200, \\  S7-1500|-1.7976931348623158e+308 \\ ..-2.2250738585072014e-308 and \\ +2.2250738585072014e-308 \\ ..+1.7976931348623158e+308||
 +|**{{anchor:s5time:S5 Time}}**|||||
 +|{{anchor:s5time:S5TIME}}|S5 time|16 bit|S7-300/400, \\  S7-1500|S5T#0H_0M_0S_0MS.. \\ S5T#2H_46M_30S_0MS||
 +|**{{anchor:s7time:S7 Time}}**|||||
 +|{{anchor:time:TIME}}|time|32 bit|S7-300/400, \\  S7-1200, \\  S7-1500|T#-24d20h31m23s648ms.. \\ T#+24d20h31m23s647ms||
 +|{{anchor:ltime:LTIME}}|long time|64 bit|S7-1500|LT#-106751d23h47m \\ 16s854ms775us808ns.. \\ LT#+106751d23h47m \\ 16s854ms775us807ns||
 +|**{{anchor:char:Characters}}**|||||
 +|{{anchor:char:CHAR}}|character|8 bit|S7-300/400, \\  S7-1200, \\  S7-1500|ASCII character set||
 +|{{anchor:wchar:WCHAR}}|word char|16 bit|S7-1200, \\  S7-1500|16 bit Unicode||
 +|{{anchor:string:STRING}}|string|Long \\ + 2 byte|S7-300/400, \\  S7-1200, \\  S7-1500|0 to 254 characters|[[#string_to_db_regs|STRING → DB REGS]] \\ [[#db_reg_to_string|DB REGS → STRING]] \\ [[de:project_s7:str2dec|STRING → REAL/LINT]] \\ [[de:project_s7:dt_to_string|DT → STRING]]|
 +|{{anchor:wstring:WSTRING}}|word string|Long \\ + 2 word|S7-1200, \\  S7-1500|0 to 16382 characters||
 +|**{{anchor:date_type:Date types}}**|||||
 +|{{anchor:date:DATE}}|date|16 bit|S7-300/400, \\  S7-1200, \\  S7-1500|D#1990-01-01..D#2168-12-31||
 +|{{anchor:tod:TOD}}|time_of_day|32 bit|S7-300/400, \\  S7-1200, \\  S7-1500|TOD#00:00:00.000.. \\ TOD#23:59:59.999||
 +|{{anchor:ltod:LTOD}}|long \\ time_of_day|64 bit|S7-1500|LTOD#00:00:00.000000000 .. \\ LTOD#23:59:59.999999999||
 +|{{anchor:dt:DT}}|date_and_time|64 bit|S7-300/400, \\  S7-1500|Min.: \\  DT#1990-01-01-0:0:0 \\ Max.:  \\ DT#2089-12-31-23:59:59.999|[[de:project_s7:acttimeconv|DT → WORD/BYTE]] \\ [[de:project_s7:dt_to_string|DT → STRING]]|
 +|{{anchor:ldt:LDT}}|long \\ date_and_time|64 bit|S7-1500|Min.: \\  LDT#1970-01-01-0:0:0.000000000, 16#0 \\ Max.:  \\ LDT#2262-04-11-23:47:16.854775807, \\ 16#7FFF_FFFF_FFFF_FFFF||
 +|{{anchor:dtl:DTL}}|date time long|96 bit|S7-1200, \\  S7-1500|Min.: \\  DTL#1970-01-01-00:00:00.0 \\ Max.: \\  DTL#2554-12-31-23:59:59.999999999||
 +|**Pointer**|||||
 +|{{anchor:pointer:POINTER}}|pointer|48 bit|S7-300/400, \\  S7-1500|-||
 +|{{anchor:any:ANY}}|any type|80 bit|S7-300/400, \\  S7-1500|-||
 +|{{anchor:variant:VARIANT}}|variant|-|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**,..)
 +
 +===== "Base" conversions =====
 +The TIA Portal offers many conversions (and doesn't offer many more). These are summarized in the following table:
 +^type^solution^conversions|
 +|Int|"CONV"|DInt, Real, Bcd16, USint, UInt, UDint, SInt, LReal und Char|
 +|DInt|"CONV"|Int,Real, Bcd32, USint, UInt, UDint, SInt, LReal und Char|
 +|Real|"CONV"|Int, DInt, USint, UInt, UDint, SInt und LReal|
 +|USint|"CONV"|Int, DInt, Real, UInt, UDint, SInt, LReal und Char|
 +|UInt|"CONV"|Int, DInt, Real, USint, UDint, SInt, LReal und Char|
 +|UDint|"CONV"|Int, DInt, Real, USint, UInt, SInt, LReal und Char|
 +|SInt|"CONV"|Int, DInt, Real, USint, UInt, UDint, LReal und Char|
 +|LReal|"CONV"|Int, DInt, Real, USint, UInt, UDint, SInt|
 +|Char|"CONV"|Int, DInt, USint, UInt, UDint, SInt und Char|
 +|Bcd16|"CONV"|Int|
 +|Bcd32|"CONV"|DInt|
 +
 +=== "CONV" utility ===
 +   - 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.
 +   - 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.
 +   - 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.
 +   - 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").
 +
 +===== converters =====
 +
 +**Install converters in TIA Portal:**
 +   - ZIP File: Extract the downloaded zip file to a directory
 +   - TIA Portal -> Devices window -> External source files -> Add new external file -> Select file
 +   - Switch online to offline
 +   - Right click on the inserted file in the list -> Generate blocks from source
 +   - "Block can be overwritten" warning -> click OK
 +   - Enjoy the time we gained with this copy (maybe write thanks to the author)
 +
 +
 +
 +^Converter_Name^Download^Description^Image_of_TIA|
 +|{{anchor:bool_to_word}}{{anchor:bool_to_byte}}**16 BOOL → WORD und BYTE**|{{de:s7:bit2word_byte.scl|SCL Download}}|Convert 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.|{{de:s7:bit2word_byte.jpg?100|BOOL -> WORD und BYTE}}|
 +|{{anchor:word_to_bool}}**WORD → 16 BOOL**|{{de:s7:word2bits.scl|SCL Download}}|Split word into 16 bits. \\ Block tested with TIA 15.1.|{{:de:s7:word2bit.png?100|WORD -> 16 BOOL}}|
 +|{{anchor:byte_to_bool}}**BYTE → 8 BOOL**|{{ :de:s7:byte2bits.scl |SCL Download}}|Split byte into 8 bits. \\ Block tested with TIA 15.1.|{{:de:s7:byte2bit.png?100|BYTE -> 8 BOOL}}|
 +|{{anchor:string_to_db_regs}}**STRING → DB REGS**|{{ :de:s7:stringtoregs.scl |SCL Download}}|The 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)|{{:de:s7:stringtoregs_1.png?100|Pic1}} \\ {{:de:s7:stringtoregs_2.png?100|Pic2}} |
 +|{{anchor:db_reg_to_string}}**DB REGS → STRING**|{{ :de:s7:regstostring.scl |SCL Download}}|The 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) \\|{{:de:s7:regstostring.png?100|Pic}} \\ Reads 64 characters from register 32 (of DB6).|
 +|{{anchor:real_to_word}}**REAL → WORD**|{{ :de:s7:unscaletoword.scl |SCL Download}}| \\ Unscale Real to Word. Block tested with TIA 16. ||
 +|{{anchor:word_to_real}}**WORD → REAL**|{{ :de:s7:scalefromword.scl |SCL Download}}| \\ Scale Word to Real. Block tested with TIA 16. ||
 +
 +{{page>de:project_s7:foot}}
 +
 +
  
  • de/s7/tia_datatypes.txt
  • 2022/04/21 15:01
  • ()