ReadMemory (FB)ΒΆ

FUNCTION_BLOCK ReadMemory EXTENDS CBM.ETrigA

This function block is for reading the memory of EtherCAT Slaves.

Example:

Following example code reads the register 0x130 (current status)

PROGRAM PLC_PRG
VAR
   etcreadmemory : ReadMemory;
   wStatus : WORD;
   xRead : BOOL;
END_VAR
etcreadmemory(xExecute := xRead, usiCom:=1, wSlaveAddress := 1002,
     xAutoIncAdr := FALSE, xBroadcast := FALSE, uiMemOffset := 16#130,
     iSize := 2, pDest := ADR(wStatus), udiTimeout := 500);
InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

xExecute

BOOL

Rising edge: Action starts
Falling edge: Resets outputs
If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle.

ETrigA

xAbort

BOOL

TRUE: Action is stopped immediately and all outputs are reset to their initial values.

ETrigA

Output

xDone

BOOL

TRUE: Action successfully completed

ETrigA

xBusy

BOOL

TRUE: Function block active

ETrigA

xError

BOOL

TRUE: Error occurred, function block aborts action
FALSE: No error

ETrigA

xAborted

BOOL

TRUE : Action aborted by user

ETrigA

Input

usiCom

USINT

1

index of master 1: first Ethercat master

wSlaveAddress

WORD

address either auto increment address or physical address of device

xAutoIncAdr

BOOL

flag that determines which way to use the given address

xBroadcast

BOOL

flag if broadcast read should be used, if true then wSlaveAddress and bAutoIncAdr are not used

uiMemOffset

UINT

offset of memory

iSize

INT

bytes to read

pDest

POINTER TO BYTE

buffer to store the data

udiTimeOut

UDINT

Timeout for operation in ms

Output

uiWorkingCounter

UINT

working counter of received command