Item reference syntax
- Last UpdatedSep 16, 2024
- 2 minute read
Item references in this Communication Driver use the following syntax.
PLC I/O Addresses
Note: This type of addressing is supported for TwinCAT 2.x only. If your target device runs TwinCAT 3.x, you must use the variable addressing described in the next section below.
You can access specific PLC I/O addresses for memory and I/O registers using the following syntax:
<register type><data type><address number>[.bit]:<variable type>
For strings:
<register type><data type><address number>:STRING[<length>]
The following syntax diagram shows all of the possible options:
{ register type | %M | %Q | %I }{ data type | B | X | W | D }address number{ | .bit }:{ variable type | BOOL | BYTE | WORD | DWORD | SINT | USINT | INT | UINT | DINT | UDINT | REAL | LREAL | TIME | TOD | DATE | DT | STRING{ | [length] } }
where,
register type: The register type: %M (memory), %Q (output), or %I (input).
data type: The data type: B (byte), X (byte for bit access), W (word), or D (double word).
address number: The memory or I/O address number on the PLC.
bit: Indicates the bit number to be read from/written to the device. In order to access individual bits,data type must be X (e.g. %IX0.0). This parameter is optional.
length: The length of the string in bytes/characters. This parameter is optional; if no length is specified, the default length is 80. The maximum possible length on the device is 1024.
Note: Length suffix for string is not supported on TwinCAT version 3.x.
variable type: The variable type that is configured for this address. The valid types are: BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, TOD (TIME_OF_DAY), DATE, DT (DATE_AND_TIME), and STRING. If you do not indicate the variable type, it will automatically fill this field with the default type according to the configured data type: BOOL for X, BYTE for B, WORD for W, and DWORD for D.
Note: If the specified STRING length is greater than the actual STRING length on the device, the device might return a "string overflow” error.