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 SymInfo data structure, 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.

VAR_INPUT

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

NETID: The AmsNetId of the TwinCAT computer on which the function is to be executed can be entered here (type: T_AmsNetID). If it is to be run on the local computer, an empty string can be entered.

PORT: The port number of the PLC run-time system to which the symbolic variable belongs (type: T_AmsPort).

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

START: the block is activated by a positive edge at this input.

TMOUT: States the length of the timeout that may not be exceeded by execution of the ADS command.

VAR_OUTPUT

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

BUSY: When the function block is activated this output is set. It remains set until a feedback is received.

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

ERRID: Supplies the ADS error number when the ERR output is set.

SymInfo: A structure with additional information on the symbolic variable (type: SYMINFOSTRUCT).

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 2:

Online View:

PLC_ReadSymInfoByName 3:

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)