FB_EcLogicalReadCmd

FB_EcLogicalReadCmd 1:

The function block FB_EcLogicalReadCmd sends a logical read EtherCAT command(LRD). 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;
    pDstBuf  : 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 read.

pDestBuf:The address (pointer) of the receive 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_LogicalReadCmd
VAR
    fbReadCmd   : FB_EcLogicalReadCmd;
    bExecute    : BOOL;
    value       : USINT;
    logAddr     : UDINT :=16#10000;
    sNetId      : T_AmsNetId:='192.168.1.5.3.1';
    
    wkc         : UINT;
    bError      : BOOL;
    nErrId      : UDINT;
END_VAR
fbReadCmd (sNetId:=sNetID, logAddr:=logAddr, LEN := SIZEOF(value), pDstBuf:=ADR(value), bExecute:=bExecute);
wkc := fbReadCmd.wkc;
bError:=fbReadCmd.bError;
nErrId:=fbReadCmd.nErrId;

Requirements

Development Environment

Target System

PLC Libraries to include

TwinCAT v2.10.0 Build >= 1314 or higher

PC or CX (x86)

TcEtherCAT.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib  are included automatically  )

TwinCAT v2.10.0 Build >= 1314 or higher

CX (ARM)