FB_AddRouteEntry 1:

The function block can be used to add a new AMS router connection (remote route) to a TwinCAT system.

FB_AddRouteEntry 2:

AMS Router connection list

Both communication partners of an AMS Router connection have an AMS Router connection list. These lists contain AMS router connections. The functionality of an AMS router connection is given if both communication partners have entered each other in their connection list.
When using the function block, the list of only one communication partner is extended.


    sNetID   : T_AmsNetID;
    stRoute  : ST_AmsRouteEntry;
    bExecute : BOOL;

sNetID: Here you can specify a string with the network address of the TwinCAT computer on which a new connection is to be added to the AMS router connection list (type: T_AmsNetID). If it is to be run on the local computer, an empty string can be entered.

stRoute: Structure element with parameters for the new connection (type: ST_AmsRouteEntry).

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

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


    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;

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

bError: In the event of an error during the command transfer, this output is set once the bBusy output has been reset.

nErrId: Supplies the ADS error number when the bError output is set.


On the local TwinCAT system a new AMS router connection is to be added with the connection name: "TEST", TwinCAT network address: "", IP address: "" and transport route: "TCP/IP".

    fbAddRoute  : FB_AddRouteEntry;
    bExecute    : BOOL;
    bBusy       : BOOL;
    bError      : BOOL;
    nErrID      : UDINT;
    stRoute     : ST_AmsRouteEntry := ( sName := 'TEST',
                                        sNetID := '',
                                        sAddress := '',
                                        eTransport := eRouteTransport_TCP_IP );

The required connection parameters are already initialized in the declaration part. The new connection is added if a rising edge is detected at the bExecute variable.

FB_AddRouteEntry 3:


Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)