PLC_ReadSymInfoByName

PLC_ReadSymInfoByName 1:

The function block PLC_ReadSymInfoByName allows additional information about a PLC symbolic variables (e.g. data type identification, index group, index offset, comment...) to be read using the symbol name. After successful execution, the data is available in the data structure SymInfo, whose type is SYMINFOSTRUCT. The maximum length of the symbol name that is transferred to the function block as a parameter is limited to 255 characters.

PLC_ReadSymInfoByName 2: Inputs

VAR_INPUT
    NETID    : T_AmsNetId;
    PORT     : T_AmsPort;
    SYMNAME  : T_MaxString;
    START    : BOOL;
    TMOUT    : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

NETID

T_AmsNetID

The network address of the TwinCAT computer on which the function is to be executed can be specified here. For the local computer an empty string may be specified.

PORT

T_AmsPort

The port number of the PLC runtime system to which the symbolic variable belongs.

SYMNAME

T_MaxString

The symbol name of the PLC variable whose information is to be read (max. 255 characters, including the complete path, e.g. 'MAIN.INIT_TASK.VARINT').

START

BOOL

The function block is enabled by a positive edge at this input.

TMOUT

TIME

Time-out period that may not be exceeded when executing the ADS command.

PLC_ReadSymInfoByName 3: Outputs

VAR_OUTPUT
    BUSY     : BOOL;
    ERR      : BOOL;
    ERRID    : UDINT;
    SymInfo  : SYMINFOSTRUCT;
END_VAR

Name

Type

Description

BUSY

BOOL

When the function block is enabled, this output is set and remains set until a feedback is received.

ERR

BOOL

If an error should occur during the transfer of the command, then this output is set once the BUSY output was reset.

ERRID

ADS error number

Returns the error code, if the ERR output is set.

SymInfo

SYMINFOSTRUCT

Structure with additional information on the symbolic variable.

Example:

PROGRAM MAIN
VAR
    PLC_ReadSymInfoByName1  : PLC_ReadSymInfoByName;
    bStart AT%QX0.5         : BOOL; (*Starts FB execution*)
    bBusy                   : BOOL;
    bError                  : BOOL;
    iErrorId                : UDINT;
    SymInfo                 : SYMINFOSTRUCT;(*Structure with sombol information*)
END_VAR
PLC_ReadSymInfoByName 4:

Online View:

PLC_ReadSymInfoByName 5:

The data obtained in this way has the following meanings:

symEntryLen = 16#43: The actual length of the entry in the symbol table is 67 bytes;

idxGroup = 16#F031: It is a variable from the PLC process image of the physical outputs;

idxOffset = 16#5: The variable is located at byte offset zero and bit offset 5;

byteSize = 16#1: The variable's value occupies one byte in memory;

adsDataType = ADST_BIT: The ADS data type ID;

symDataType = BOOL: The data type identification in the PLC;

symComment = 'STARTS FB EXECUTION': Comment that the user has added to the variable definition line.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)