ADSCLOSE

ADSCLOSE 1:

The ADSCLOSE function block can be used to close explicitly an IP connection that is no longer required. The number of IP connections that may be open simultaneously is restricted to four, in order to maintain the use of resources at a minimum. A connection is automatically established when ADSREADEX, ADSWRITE or ADSRDWRTEX are called. Unused connections are automatically closed after 10 seconds. If it is necessary to establish a connection to more than four ADS devices during that period, the connections that are not required must first be closed. 

VAR_INPUT

VAR_INPUT
    NETID       : T_AmsNetId;
    CLOSE       : BOOL;
    TMOUT       : TIME;
END_VAR

T_AmsNetId

NETID: the AMS network ID of the ADS device whose connection is to be disconnected. 

CLOSE : the ADS command is triggered by a rising edge at this input.

TMOUT : states the time that may not be exceeded by execution of the ADS command.

VAR_OUTPUT

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

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

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

ERRID: supplies the ADS error number or the device-specific error number when the ERR output is set.

 

Sample of calling the function block in FBD:

PROGRAM MAIN
VAR
    fbAdsClose  : ADSCLOSE;
    bClose      : BOOL;
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
END_VAR

ADSCLOSE 2:

In this sample, a rising edge at the bClose input triggers closure of the IP connection to the ADS device with network address '172.16.2.209.1.1'.

 

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v2.7.0 & TwinCAT v2.8

BC9xxx (165) firmware version >= 0xB6

TcAdsBC.Lb6