ADSWRITE
This function block permits execution of an ADS write command, for the transfer of data to an ADS device.
VAR_INPUT
VAR_INPUT
NETID : T_AmsNetId;
PORT : T_AmsPort;
IDXGRP : UDINT;
IDXOFFS : UDINT;
LEN : UDINT;
SRCADDR : DWORD;
WRITE : BOOL;
TMOUT : TIME;
END_VAR
NETID : is a string containing the AMS network ID of the target device to which the ADS command is directed.
PORT: contains the port number of the ADS device to which the command is directed.
IDXGRP : contains the index group number (32-bit, unsigned) of the requested ADS service. This value is to be found in the ADS table of the addressed device.
IDXOFFS : contains the index offset number (32-bit, unsigned) of the requested ADS service. This value is to be found in the ADS table of the addressed device.
LEN : contains the number of data to be read in bytes.
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 : specifies the time until the abortion of the function.
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
fbAdsWrite : ADSWRITE;
bWrite : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
Buffer : ARRAY[1..10] OF BYTE := 1,2,3,4,5,6,7,8,9,0;
END_VAR
In this sample, an ADS command is sent to an ADS device with network address '172.16.2.209.1.1' and port number 801. This port number could, for instance, be used to address the PLC's first runtime system. The service to be executed is encoded in the index group and the index offset parameters. If successful, 10 bytes of data (Buffer variable) are written into the flags area of the target device, starting at byte offset 100.
Requirements
Development environment |
Target platform |
PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 & TwinCAT v2.8.0 |
BC9xxx (165) firmware version >= 0xB6 |
TcAdsBC.Lb6 |