ReadNbrSlaves (FB)ΒΆ
FUNCTION_BLOCK ReadNbrSlaves EXTENDS ETrigA
Reads the number of connected slaves
Example:
PROGRAM PLC_PRG
VAR
readnbr : ReadNbrSlaves;
xRead : BOOL;
wNbrSlaves : WORD;
END_VAR
IF xRead THEN
readnbr.usiCom := DWORD_TO_USINT(Ethercat_Master.InstanceNumber);
readnbr(xExecute := TRUE, udiTimeOut := 1000);
IF readnbr.xDone THEN
xRead := FALSE;
wNbrSlaves := readnbr.wNumberSlaves;
readnbr(xExecute := FALSE);
END_IF
END_IF
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
xExecute
BOOL
Rising edge: Action startsFalling edge: Resets outputsIf 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 completedETrigA
xBusy
BOOL
TRUE
: Function block activeETrigA
xError
BOOL
TRUE
: Error occurred, function block aborts actionFALSE
: No errorETrigA
xAborted
BOOL
TRUE
: Action aborted by userETrigA
Input
usiCom
USINT
1
index of master 1: first Ethercat master
udiTimeOut
UDINT
Timeout for operation in ms
Output
wNumberSlaves
WORD
number of slaves currently available