CoE access to multi-function I/Os

The FB_EcCoeSdoReadEx function block allows data to be read from an object directory of an EtherCAT slave via SDO data (Service Data Object). The nSubIndex and nIndex parameters allow the object that is to be read to be selected. Via bCompleteAccess := TRUE the parameter can be read with subelements.

Sample: Read the firmware version of the multi-function I/Os.

VAR
AMSNetID AT %I*:T_AmsNetIdArr;
Port AT %I*:T_AmsPort;
FB_EcCoESdoReadEx: FB_EcCoESdoReadEx;
FirmwareVersion: STRING;
END_VAR

The AmsNetId and port number are required for communication with the CX7028 interface. The inputs of the function block FB_EcCoeSdoReadEx can be linked with the input variables netId and port under TwinCAT, so that the function block is permanently connected to the CX7028 interface.

CoE access to multi-function I/Os 1:
CoE access to multi-function I/Os, input variables "netId" and "port" under TwinCAT.

The input sNetId of the function block corresponds to the input netId under TwinCAT. The function block requests a string and the link returns a byte array. You can convert the byte array to a string using the F_CreateAmsNetId function. The input nSlaveAddr corresponds to the input port under TwinCAT.

FB_EcCoESdoReadEx(
sNetId:=F_CreateAmsNetId(nIds:=AMSNetID ) , (* AmsNetId of the CX7028 Interface *)
nSlaveAddr:=Port , (* Port Number(nSlaveAddr): 0x1000 *)
nSubIndex:= ,
nIndex:=16#100A , (* Index Number *)
pDstBuf:=ADR(FirmwareVersion) ,
cbBufLen:=SIZEOF(FirmwareVersion) ,
bExecute:=TRUE ,
tTimeout:= ,
bCompleteAccess:= ,
bBusy=> ,
bError=> ,
nErrId=> );

The index number for the CoE object Software version is located under the CoE Online tab.

CoE access to multi-function I/Os 2:
CoE communication, listing of CoE objects with matching index number.

With the FB_EcCoeSdoWriteEx function block an object from the object directory of an EtherCAT slave can be written by SDO-Download. Pay attention to whether the object can be accessed for reading; this is displayed in the Flags column. The nSubIndex and nIndex parameters allow the object that is to be written to be selected. Via bCompleteAccess := TRUE the parameter can be written with subelements.