FB_EcGetSlaveIdentity
The function block FB_EcGetSlaveIdentity
can be used to read the CANopen identity of an individual EtherCAT slave device. If the call is successful, the output variable identity, whose type is ST_EcSlaveIdentity
, contains the requested identity information.
Inputs
VAR_INPUT
sNetId : T_AmsNetId;
nSlaveAddr : UINT;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String containing the AMS network ID of the EtherCAT master device. (Type T_AmsNetId) |
nSlaveAddr | UINT | Fixed address of the EtherCAT slave |
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;
identity : ST_EcSlaveIdentity;
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. |
identity | ST_EcSlaveIdentity | CANopen Identity of the EtherCAT device |
Example of an implementation in ST:
PROGRAM TEST_GetSlaveIdentity
VAR
fbGetSlaveIdentity : FB_EcGetSlaveIdentity;
sNetId : T_AmsNetId := '172.16.2.131.2.1';
bExecute : BOOL;
identity : ST_EcSlaveIdentity;
nSlaveAddr : UINT := 1001;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbGetSlaveIdentity(sNetId:= sNetId, nSlaveAddr:= nSlaveAddr, bExecute:=bExecute);
identity := fbGetSlaveIdentity.identity;
bError := fbGetSlaveIdentity.bError;
nErrId := fbGetSlaveIdentity.nErrId;
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_EtherCAT |