FB_CIP_DATA_TABLE_RDWR

Variables are read and written from TwinCAT via a function block that is part of the Tc2_EthernetIP.
The function block FB_CIP_DATA_TABLE_RDWR can be used for reading and writing.
Inputs
VAR_INPUT
sNetId : T_AmsNetID;
sIPv4Addr : T_IPv4Addr;
bExecute : BOOL;
bDataTableWrite : BOOL;
sSrcElementName : WORD;
sDstElementName : WORD;
nNumberOfElements : POINTER TO BYTE;
nLocalIndex : WORD;
nRemoteIndex : DWORD;
nSessionTimeoutMSec : DWORD;
nCmdTimeoutMSec : DWORD;
bRackComm : BOOL;
nPort : BYTE;
nSlot : BYTE;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetID | AMSNetId of the TwinCAT EtherNet/IP™ scanner via which the command is to run |
sIPv4Addr | T_IPv4Addr | IP address of the target CPU. |
bExecute | BOOL | A positive edge starts the command. |
bDataTableWrite | BOOL | FALSE triggers a DataTableRead, TRUE a DataTableWrite. |
sSrcElementName | WORD | String for the source name. |
sDstElementName | WORD | String for the target name. |
nNumberOfElements | POINTER OF BYTE | Number of elements |
nLocalIndex | WORD | For ARRAYs the start index has to be set to indicate from which ARRAY index the data should be taken (local system). |
nRemoteIndex | DWORD | For ARRAYs the start index has to be set to indicate from which ARRAY index the data should be taken (remote system). |
nSessionTimeoutMSec | DWORD | Timeout for the session; the default is 30 seconds. |
nCmdTimeoutMSec | DWORD | Timeout for the command; the default is 7.5 seconds. |
bRackComm | BOOL | TRUE if the CPU is modular, i.e. a CPU with a rack design, for example a CompactLogix. |
nPort | BYTE | Port number of the CPU (usually 1). |
nSlot | BYTE | Slot number if the CPU is not plugged into slot 0. |
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. While Busy = TRUE, no new command will be accepted at the inputs. |
bError | BOOL | If an error occurs during the transfer of the command, then this output is set once the bBusy output was reset. |
nErrId | UDINT | If an bError output is set, this parameter supplies an error number. |
Sample
![]() | Removing test code If you have already tested the communication from AB to Beckhoff, you should remove the function calls to DataTable Read/Write from the AB project. |
VAR
FB_CIP_DATA_TABLE_RDWR: FB_CIP_DATA_TABLE_RDWR;
SourceName: STRING := 'Test';
DestName: STRING := 'ETHIP.Test';
Error: STRING;
END_VAR
FB_CIP_DATA_TABLE_RDWR(
sNetId:='5.18.71.214.4.1' ,
sIPv4Addr:='192.168.1.220' ,
bExecute:=TRUE ,
bDataTableWrite:= ,
sSrcElementName:=(SourceName) ,
sDstElementName:=(DestName) ,
nNumberOfElements:=1 ,
nLocalIndex:= ,
nRemoteIndex:= ,
nSessionTimeoutMSec:= ,
nCmdTimeoutMSec:= ,
bRackComm:=TRUE ,
nPort:= ,
nSlot:= ,
bBusy=> ,
bError=> ,
nErrId=> );
IF NOT FB_CIP_DATA_TABLE_RDWR.bBusy THEN
FB_CIP_DATA_TABLE_RDWR(bExecute:=FALSE);
Error:=F_GET_ETHERNETIP_ERROR_TEXT (FB_CIP_DATA_TABLE_RDWR.nErrId);
END_IF