FB_EcLogicalWriteCmd
The function block FB_EcLogicalWriteCmd sends a logical write EtherCAT command (LWR). In every slave one can map local address areas (DPRAM of the EtherCAT Slave Controller) to global logical address areas. Therefore, this command addresses all EtherCAT slaves, that have a mapping configured for the selected logical address area.
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId;
logAddr : UDINT;
len : UDINT;
pSrcBuf : DWORD;
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.
logAddr: Logical address.
len: Count of bytes to write.
pSrcBuf:The address (pointer) of the source buffer.
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;
wkc : UINT;
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.
wkc: The working counter is incremented by 1 for each EtherCAT slave that is addressed by this command. If only on EherCAT slave is addressed by this command, the working counter will be 1.
Sample for an implementation in ST:
PROGRAM Test_LogicalWriteCmd
VAR
fbWriteCmd : FB_EcLogicalWriteCmd;
bExecute : BOOL;
value : USINT :=16#55;
logAddr : UDINT :=16#10000;
sNetId : T_AmsNetId:='192.168.1.5.3.1';
wkc : UINT;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbWriteCmd (sNetId:=sNetID, logAddr:=logAddr, LEN := SIZEOF(value), pSrcBuf:=ADR(value), bExecute:=bExecute);
wkc := fbWriteCmd.wkc;
bError:=fbWriteCmd.bError;
nErrId:=fbWriteCmd.nErrId;
Requirements
Development Environment | Target System | PLC Libraries to include |
---|---|---|
TwinCAT v2.10.0 Build >= 1314 or higher | PC or CX (x86) | TcEtherCAT.Lib |
TwinCAT v2.10.0 Build >= 1314 or higher | CX (ARM) |