FB_EcReadBTN

The function block FB_EcReadBTN can be used to read the BTN from the EEPROM of an EtherCAT slave via ADS. For this the slave must contain the BIC in the EEPROM.
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 to which the SDO upload command should be sent. |
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;
sBTN : STRING()9
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. |
sBTN | STRING()9 | This output contains (after an error-free run) the BTN of the EtherCAT slave after the bBusy output has been reset, e.g. "0002agdw". |
Sample of an implementation in ST
PROGRAM TEST_EcReadBTN
VAR
fbEcBTN : FB_EcReadBTN;
sNetId : T_AmsNetId := '172.16.2.131.2.1';
bExecute : BOOL := TRUE;
nSlaveAddr : UINT := 1006;
sEcBTN : STRING;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbEcBTN(sNetId:= sNetID, nSlaveAddr:= nPort, bExecute:= bExecute, tTimeout:= T#5S);
IF NOT fbEcBTN.bBusy THEN
bExecute := FALSE;
IF NOT fbEcBTN.bError THEN
sEcBTN := fbEcBTN.sBTN;
END_IF
fbEcBTN(bExecute:= bExecute);
END_IF
Prerequisites
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, Arm®) | Tc2_EtherCAT |