FB_EcSoeWrite
The function block FB_EcSoeWrite allows to write drive parameters with the "Servo Drive Profile over EtherCAT"(SoE) protocol. This requires the slave to have a mailbox and to support the SoE protocol. The parameter to be written is specified by the parameters nIdn (Identification number), nElement and nDriveNo .
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId;
nSlaveAddr : UINT;
nIdn : WORD;
nElement : BYTE;
nDriveNo : BYTE;
bCommand : BOOL;
pSrcBuf : DWORD;
cbBufLen : UDINT;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
sNetId: This is a string that contains the AMS network identifier of the EtherCAT master device.
nSlaveAddr: Fixed address of the EtherCAT slave to which the SoE write command should be sent to.
nIdn: Identification number of the parameter that is to be written.
nElement: Element number of the parameter that is to be written. The following values are allowed:
Value | Description |
---|---|
0x01 | Data Status |
0x02 | Name (read only) |
0x04 | Attribute |
0x08 | Unit |
0x10 | Minimum |
0x20 | Maximum |
0x40 | Value |
0x80 | Default |
nDriveNo: Number of the drive.
bCommand: This parameter should be set, if the internal command execution should be used.
pSrcBuf:The address (pointer) of the send buffer.
cbBufLen:The maximum available buffer size for the data to be sent, in bytes.
bExecute: The block is activated by a rising edge at this input.
tTimeout: Maximum time allowed for the execution of the function block.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
bBusy: This output is set when the function block is activated and remains set until an acknowledgement is received.
bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.
nErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.
Example for an implementation in ST:
PROGRAM TEST_SoEWrite
VAR
fbSoeWrite : FB_EcSoEWrite;
sNetId : T_AmsNetId := '172.16.2.131.2.1';
bExecute : BOOL;
nSlaveAddr : UINT := 1006;
nIdn : WORD := 15;
nElement : BYTE := 0;
nDriveNo : BYTE := 0;
bCommand : BOOL := FALSE;
val : UINT;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbSoEWrite(sNetId:= sNetId,nSlaveAddr :=nSlaveAddr, nIdn := nIdn, nElement:=nElement, nDriveNo := nDriveNo,bCommand:=bCommand, pSrcBuf:= ADR(val), cbBufLen:=SIZEOF(val),bExecute:=bExecute);
bError:=fbSoEWrite.bError;
nErrId:=fbSoEWrite.nErrId;
Requirements
Development environment | Target system type | PLC libraries to be linked |
---|---|---|
TwinCAT v2.10.0 or higher | PC or CX (x86) | TcEtherCAT.lib |
TwinCAT v2.10.0 Build >= 1301 or higher | CX (ARM) |