FB_AddRouteEntry

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. An AMS router connection is functional when both communication partners have entered each other in their respective connection list.
When using the function block, only the list of the communication partner is extended.

FB_AddRouteEntry 3: Inputs

VAR_INPUT
    sNetID   : T_AmsNetID;
    stRoute  : ST_AmsRouteEntry;
    bExecute : BOOL;
    tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

sNetID

T_AmsNetID

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 can be specified here. For the local computer an empty string may be specified.

stRoute

ST_AmsRouteEntry

Structure element with parameters for the new connection.

bExecute

BOOL

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

tTimeout

TIME

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

FB_AddRouteEntry 4: Outputs

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
END_VAR

Name

Type

Description

bBusy

BOOL

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

bError

BOOL

If an error occurs during the transmission of the command, this output is set after the bBusy output is reset.

nErrId

UDINT

Returns the ADS error number when the bError output is set.

Example:

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

PROGRAM P_TEST3
VAR
    fbAddRoute  : FB_AddRouteEntry;
    bExecute    : BOOL;
    bBusy       : BOOL;
    bError      : BOOL;
    nErrID      : UDINT;
    stRoute     : ST_AmsRouteEntry := ( sName := 'TEST',
                                        sNetID := '172.16.6.111.1.1',
                                        sAddress := '172.16.6.111',
                                        eTransport := eRouteTransport_TCP_IP );
END_VAR

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

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)