FB_EcGetAllSlavePresentStateChanges
The function block FB_EcGetAllSlavePresentStateChanges
can be used to read the EtherCAT state changes from state “slave is present” to “INIT_NO_COMM” of all slaves connected to the master. If the call is successful, the buffer transferred in the parameter pBufAddr contains the number of state changes of all slaves as an array of UDINTs. The EtherCAT state change from state “slave is present” to “INIT_NO_COMM” means that the connection to the slave has been interrupted. For example by disconnecting the EtherCAT cable.
Inputs
VAR_INPUT
sNetId : T_AmsNetId; (*AmsNetId of the EtherCAT master device*)
pAddrBuf : POINTER TO ARRAY [0..EC_MAX_SLAVES] OF UDINT; (*Contains the address of the buffer the counters for the state changes from Present to INIT_NO_COMM are copied to.*)
cbBufLen : UDINT; (*Size of the buffer pAddrBuf. The size of the buffer must be at least nSlave *4 Bytes *)
bExecute : BOOL; (*Function Block execution is triggered by a rising edge at this input*)
tTimeout : TIME; (*States the time before the function is cancelled.*)
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String containing the AMS network ID of the EtherCAT master device. (Type: T_AmsNetId) |
pAddrBuf | POINTER TO ARRAY | Address of an array of UDINTs, into which the number of state changes from "slave is present" to INIT_NO_COMM for the individual slaves is to be written. |
bBufLen | UDINT | Maximum available buffer size (in bytes) for the data to be read |
bExecute | BOOL | The function block is activated by a positive edge at this input. |
tTimeout | TIME | Maximum time allowed for the execution of the function block. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
nSlaves : UINT;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output is set when the function block is activated, and remains set until a feedback is received. |
bError | BOOL | This output is set after the bBusy output has been reset when an error occurs in the transmission of the command. |
nErrId | UDINT | Supplies the ADS error code associated with the most recently executed command if the bError output is set. Error 1798 (0x706) indicates a null pointer at the buffer address. Error 1797 (0x705) indicates inadequate buffer size. |
nSlaves | UINT | The number of slaves connected to the master. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_EtherCAT |