meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| automation:direct_indirect_addressing [2026/01/16 13:45] – vamsan | automation:direct_indirect_addressing [2026/01/16 17:24] (current) – vamsan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | === Direct / indirect addressing === | + | === Direct/ |
| Addressing methods are mostly tied to variable types, not areas, so the following procedures apply to both DB and Tag variables. | Addressing methods are mostly tied to variable types, not areas, so the following procedures apply to both DB and Tag variables. | ||
| Line 28: | Line 28: | ||
| </ | </ | ||
| - | Direct addressing is also applicable to [[# | + | Direct addressing is also applicable to [[# |
| - | Another approach is direct addressing, which involves referring to sub-elements | + | Another approach is direct addressing, which involves referring to a variable' |
| == Slice addressing == | == Slice addressing == | ||
| {{anchor: | {{anchor: | ||
| - | Slice addressing involves dividing a memory region, such as a byte or word, into smaller segments | + | Slice addressing involves dividing a memory region, such as a byte or a word, into smaller segments, such as booleans. With S7-1200 and S7-1500, you can target specific parts within declared variables (**only by byte, word, dword**) and access segments of 1, 8, 16, or 32 bits. |
| {{: | {{: | ||
| Line 76: | Line 76: | ||
| ^Name^Length^Description| | ^Name^Length^Description| | ||
| ^Syntax ID|1 byte|Always 16#10 for S7| | ^Syntax ID|1 byte|Always 16#10 for S7| | ||
| - | ^Data Type|1 byte|Code for the type of data being pointed to (e.g., 16#02 for Byte; see bellow | + | ^Data Type|1 byte|Code for the type of data being pointed to (e.g., 16#02 for Byte; see below in the table "TIA Coding of data types" |
| ^Repetition Factor|2 bytes|Number of elements of the specified data type| | ^Repetition Factor|2 bytes|Number of elements of the specified data type| | ||
| ^DB Numbe|2 bytes|The number of the data block (0 if not in a DB)| | ^DB Numbe|2 bytes|The number of the data block (0 if not in a DB)| | ||
| - | ^Memory Area|1 byte|Code for the memory area (e.g., 16#84 for DB; see bellow | + | ^Memory Area|1 byte|Code for the memory area (e.g., 16#84 for DB; see below in the table "TIA Coding of the memory area" |
| ^Address|3 bytes|The start address of the data (bit and byte address)| | ^Address|3 bytes|The start address of the data (bit and byte address)| | ||
| Line 88: | Line 88: | ||
| == Example of using the ANY type == | == Example of using the ANY type == | ||
| - | The pointer with the ANY type is most frequently used with the [[# | + | The pointer with the ANY type is most frequently used with the [[# |
| <code pascal> | <code pascal> | ||
| Line 102: | Line 102: | ||
| END_CASE; | END_CASE; | ||
| </ | </ | ||
| + | == VARIANT versus ANY == | ||
| + | |||
| + | * **ANY** is a fixed 10-byte structure that references an absolute memory address. | ||
| + | * **VARIANT** is a type-safe pointer that preserves the original data type information and enables symbolic addressing without the need for fixed memory location overhead. | ||
| + | * The **ANY** is an older type, already available in the S300 / 400 series. | ||
| + | * The **ANY** can only be used with the S7-1500, whereas **VARIANT** are accessible on all S7 models. | ||
| == VARIANT type == | == VARIANT type == | ||
| {{anchor: | {{anchor: | ||
| + | A VARIANT type parameter is a pointer that can reference various data types beyond a simple instance. This pointer can be an object of a basic data type like [[# | ||
| + | |||
| + | <WRAP center round important 80%> | ||
| + | * Directly assigning a tag to a VARIANT, like //myVARIANT := # | ||
| + | * Direct reading or writing of a signal from an I/O input or output is only possible with an S7-1500 module. | ||
| + | * You can only reference a complete data block if it was originally created from a user-defined data type ([[# | ||
| + | </ | ||
| + | |||