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.
VAR_INPUT
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
sNetId: AMSNetId of the TwinCAT EtherNet/IP scanner through which the command is to run
sIPv4Addr: IP address of the target CPU
bExecute. A positive edge starts the command
bDataTableWrite: FALSE triggers a DataTableRead, TRUE a DataTableWrite
sSrcElementName: String for the source name
sDstElementName: String for the target name
nNumberOfElements: Number of elements
nLocalIndex: For ARRAYs the start index has to be set to indicate from which ARRAY index the data should be taken (local system)
nRemoteIndex: For ARRAYs the start index has to be set to indicate from which ARRAY index the data should be taken (remote system)
nSessionTimeoutMSec: Timeout for the session; the default is 30 seconds
nCmdTimeoutMSec: Timeout for the command; the default is 7.5 seconds
bRackComm: TRUE if the CPU is modular, i.e. a CPU with a rack design, for example a CompactLogix
nPort: Port number of the CPU (usually 1)
nSlot: Slot number if the CPU is not plugged into slot 0
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until a feedback is received. While Busy = TRUE, no new command will be accepted at the inputs.
bError: If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.
nErrId: If an bError output is set, this parameter supplies an error number.
Example
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';
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_HELPSTRING(FB_CIP_DATA_TABLE_RDWR.nErrId;
END_IF