FB_SoEAX5000FirmwareUpdate
With the FB_SoEAX5000FirmwareUpdate function block the Firmware of the AX5000 can be checked and automatically changed to a given version (Revision and Build) or to the current Build of the configured revision.
For the update:
- the configured slave type is determined, e.g. AX5103-0000-0010
- the current slave is determined with the predefined slave address, e.g. AX5103-0000-0009
- the current slave firmware is determined, e.g. v1.05_b0009
- a comparison of the configuration and the found slave regarding number of channels, current, revision and firmware is made
- the name of the required firmware file is determined and a search for the file performed
- the firmware update is executed (if necessary)
- the current slave with the predefined slave address is determined again
- the slave is switched to the predefined EtherCAT state
A successful update ends with eFwUpdateState = eFwU_FwUpdateDone.
If the update is not required, this is signaled via eFwUpdateState = eFwU_NoFwUpdateRequired.
The firmware update takes place via the specified channel (A=0 or B=1) from stDriveRef. In the case of two-channel devices only one of the two channels can be used. The other channel signals eFwUpdateState = eFwU_UpdateViaOtherChannelActive or eFwUpdateState = eFwU_UpdateViaOtherChannel.
During the firmware update (eFwUpdateState = eFwU_FwUpdateInProgress), iLoadProgress signals the progress in percent.
Notice | |
Faulty update due to interruptions Interruptions during the update may result in it not being executed or executed incorrectly. Afterwards, the terminal may no longer be usable without the appropriate firmware. The rules during the update are:
|
Inputs
VAR_INPUT
sNetId : T_AmsNetId;
bExecute : BOOL;
sFirmwareVersion : STRING(20); (* version string vx.yy_bnnnn, e.g. "v1.05_b0009" for v1.05 Build 0009*)
sFirmwarePath : T_MaxString; (* drive:\path, e.g. "C:\TwinCAT\Io\TcDriveManager\FirmwarePool" *)
iReqEcState : UINT := EC_DEVICE_STATE_OP;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | AMS-NetID of the controller (IPC). |
bExecute | BOOL | The function block is activated by a positive edge at this input. |
sFirmwareVersion | STRING(20) | Specifies the desired firmware version in the form of vx.yy_bnnnn, e.g. "v1.05_b0009" for Version v1.05 Build 0009. Release-Builds:
Customer-specific Firmware-Builds:
...
Debug-Builds:
|
sFirmwarePath | T_MaxString | Specifies the path for the firmware pool in which the firmware files are located, e.g. C:\TwinCAT\Io\TcDriveManager\FirmwarePool. |
iReqEcState | UINT | Desired EtherCAT state after the update (only if an update is actually being executed). The states are defined in PLC Lib Tc2_EtherCAT as global constants. |
tTimeout | TIME | Since the firmware update for large EtherCAT networks can take longer, only the timeout for individual internal ADS instances is specified here. |
Inputs/outputs
VAR_IN_OUT
Axis : NCTOPLC_AXIS_REF;(* reference to NC axis *)
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis data structure of the type NCTOPLC_AXIS_REF |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
iDiagNumber : UDINT;
eFwUpdateState : E_FwUpdateState;
iLoadProgress : INT;
sSelectedFirmwareFile : STRING(MAX_STRING_LENGTH); (* found firmware file, e.g. "AX5yxx_xxxx_-0010_v1_05_b0009.efw" *)
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. |
iAdsErrId | UINT | Returns the ADS error code of the last executed command when the bError output is set. |
iSercosErrId | UINT | In the case of a set bError output returns the Sercos error of the last executed command. |
iDiagNumber | UDINT | In the case of a set bError output returns the drive error of the last executed firmware update. |
eFwUpdateState | E_FwUpdateState | Returns the status of the firmware update. |
iLoadProgress | INT | Returns the progress of the actual firmware update as a percentage. |
sSelectedFirmwareFile | STRING(MAX_STRING_LENGTH) | Displays the name of the firmware file being searched for. |
Sample
VAR CONSTANT
iNumOfDrives : INT := 2;
END_VAR
VAR
fbFirmwareUpdate : ARRAY [1..iNumOfDrives] OF FB_SoEAX5000FirmwareUpdate;
NcToPlc AT %I* : ARRAY [1..iNumOfDrives] OF NCTOPLC_AXIS_REF;
sFirmwareVersion : ARRAY [1..iNumOfDrives] OF STRING(20)(* := 2('v1.04_b0002')*);
eFwUpdateState : ARRAY [1..iNumOfDrives] OF E_FwUpdateState;
sSelectedFirmwareFile: ARRAY [1..iNumOfDrives] OF STRING(MAX_STRING_LENGTH);
iUpdateState : INT;
bExecute : BOOL;
sNetIdIPC : T_AmsNetId := '';
sFirmwarePath : T_MaxString := 'C:\TwinCAT\Io\TcDriveManager\FirmwarePool';
I : INT;
bAnyBusy : BOOL;
bAnyError : BOOL;
END_VAR
CASE iUpdateState OF
0:
IF bExecute THEN
iUpdateState := 1;
END_IF
1:
FOR I := 1 TO iNumOfDrives DO
fbFirmwareUpdate[I](
Axis := NcToPlc[I],
bExecute := TRUE,
tTimeout := T#15s,
sFirmwareVersion := sFirmwareVersion[I],
sFirmwarePath := sFirmwarePath,
sNetId := sNetIdIPC,
iReqEcState := EC_DEVICE_STATE_OP,
eFwUpdateState => eFwUpdateState[I],
);
END_FOR
iUpdateState := 2;
2:
bAnyBusy := FALSE;
bAnyError:= FALSE;
FOR I := 1 TO iNumOfDrives DO
fbFirmwareUpdate[I](
Axis := NcToPlc[I],
eFwUpdateState => eFwUpdateState[I],
sSelectedFirmwareFile => sSelectedFirmwareFile[I],
);
IF NOT fbFirmwareUpdate[I].bBusy THEN
fbFirmwareUpdate[I](bExecute := FALSE, Axis := NcToPlc[I]);
IF fbFirmwareUpdate[I].bError THEN
bAnyError := TRUE;
END_IF
ELSE
bAnyBusy := TRUE;
END_IF
END_FOR
IF NOT bAnyBusy THEN
bExecute := FALSE;
IF NOT bAnyError THEN
iUpdateState := 0; (* OK *)
ELSE
iUpdateState := 0; (* Error *)
END_IF
END_IF
END_CASE