FB_CoEWrite
With the function block FB_CoEWrite, an object from the object directory of an EtherCAT slave can be written via an SDO (Service Data Object) download. This requires the slave to have a mailbox and to support the CoE (CANopen over EtherCAT) protocol. With the help of the SubIndex and Index parameters a selection is made as to which object should be written. Via CompleteAccess := TRUE the parameter can be written with sub-elements.
Inputs
VAR_INPUT
sNetId : T_AmsNetId;(*netID of PC with NC*)
iIndex : WORD;(*CoE object index*)
iSubIndex : BYTE;(*CoE sub index*)
pDstBuf : PVOID;(*Contains the address of the buffer for the received data*)
iBufLen : UDINT;(*Contains the max. number of bytes to be received*)
bExecute : BOOL;(*Function block execution is triggered by a rising edge at this input.*)
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;(*States the time before the function is cancelled.*)
bCompleteAccess : BOOL;(*Function block reads the complete object with all sub index*)
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String, which contains the AMS Network ID of the PC (type: T_AmsNetId). |
iIndex | WORD | Index of the object that is supposed to be written. |
iSubIndex | BYTE | Subindex of the object that is supposed to be written. |
pDstBuf | PVOID | Address (pointer) to the transmit buffer |
iBufLen | UDINT | Maximum available buffer size (in bytes) for the data to be read |
bExecute | BOOL | The function block is enabled via a positive edge at this input. |
tTimeout | TIME | Maximum time allowed for the execution of the function block. |
bCompleteAccess | BOOL | Via Complete Access the complete object can be accessed at once. |
Inputs/outputs
VAR_IN_OUT
Axis : NCTOPLC_AXIS_REF;
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis data structure of type NCTOPLC_AXIS_REF, which addresses an axis uniquely within the system. Among other things it contains the current state of the axis such as the position, the velocity and the error state. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iCANopenErrId : UINT;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output is set when the function block is activated, and remains set until a feedback is received. |
bError | BOOL | This output is set after the bBusy output has been reset when an error occurs in the transmission of the command. |
iAdsErrId | UINT | In the event of a set bError output returns the ADS error code. |
iCANopenErrId | UINT | In the event of a set bError output returns the CANopen error code. |