ADSWRTCTL
This block permits the execution of an ADS control command to affect the state of an ADS device, e.g. to start, stop or reset a device.
VAR_INPUT
VAR_INPUT
NETID : T_AmsNetId;
PORT : T_AmsPort;
ADSSTATE : UINT;
DEVSTATE : UINT;
LEN : UDINT;
SRCADDR : DWORD;
WRITE : BOOL;
TMOUT : TIME;
END_VAR
NETID : Is a string containing the AMS network identifier of the target device to which the ADS command is directed.
PORT : Contains the port number of the ADS device.
ADSSTATE : Contains the state identification code of the ADS target device. The codes shown here are specified for all ADS servers:
- ADSSTATE_IDLE =1 ;
- ADSSTATE_RESET =2 ;
- ADSSTATE_INIT =3 ;
- ADSSTATE_START =4 ;
- ADSSTATE_RUN=5 ;
- ADSSTATE_STOP =6 ;
- ADSSTATE_SAVECFG =7 ;
- ADSSTATE_LOADCFG =8;
DEVSTATE : Contains the specific state identification code of the ADS target device. The codes given here are supplementary information which is specific to the ADS device.
LEN : Contains the number, in bytes, of the data that is to be written.
SRCADDR : Contains the address of the buffer from which the data to be written is to be fetched. The programmer is himself responsible for dimensioning the buffer to such a size that ‘LEN’ bytes can be taken from it. The buffer can be a single variable, an array or a structure, whose address can be found with the ADR operator.
WRITE : The ADS command is triggered by a rising edge at this input.
TMOUT : States the time before the function is cancelled.
VAR_OUTPUT
VAR_OUTPUT
BUSY : BOOL;
ERR : BOOL;
ERRID : UDINT;
END_VAR
BUSY : This output remains TRUE until the block has executed a command, but at the longest for the duration supplied to the ‘Timeout’ input. While Busy = TRUE, no new command will be accepted at the inputs. Please note that it is not the execution of the service but its acceptance whose time is monitored.
ERR : This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in ‘ErrorId’. If the block has a timeout error, ‘Error’ is TRUE and ‘ErrorId’ is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs.
ERRID : Contains the command-specific error code of the most recently executed command. Is reset to 0 by the execution of a command at the inputs.
Example of calling the block in FBD:

In the example a reset command (ADSSTATE=2) is sent to the I/O server (Port300), along with supplementary data hex.AFFE. As a result the I/O server executes a bus reset.
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | PLCSystem.Lib |
TwinCAT v2.8.0 | PC or CX (x86) | TcSystem.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) | TcSystem.Lib |