FB_SoEAX5000FirmwareUpdate

FB_SoEAX5000FirmwareUpdate 1:

The functionblock FB_SoEAX5000FirmwareUpdate can be used to check and update the firmware of the AX5000 to a requested version (revision and build) or to the newest build of the configured revision.  

In order to update the following sequence is executed:
- get configured slave type, i.e. AX5103-0000-0010
- get scanned slave type for the slave address, i.e. AX5103-0000-0009
- get current slave firmware, i.e. v1_05_b0009
- compare configured and scanned slave (number of channels, current, revision, firmware)
- create firmware files name and search for the file
- update firmware (if required)
- rescan slave
- switch the slave to the requested EtherCAT state

A successful updatefinishes witheFwUpdateState = eFwU_FwUpdateDone. If the update is not required, then the state returns eFwUpdateState = eFwU_NoFwUpdateRequired. The firmware update is executed via the channel of the drive (A=0 or B=1) set in stDriveRef. With two channel devices, the firmware update can only be executed via one of the channels. The other channel signalseFwUpdateState = eFwU_UpdateViaOtherChannelActive or = eFwU_UpdateViaOtherChannel.

During the firmware update (eFwUpdateState = eFwU_FwUpdateInProgress) the update progress is reported viaiLoadProgress 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:

  • The PLC and TwinCAT must not be stopped.
  • The EtherCAT connection must not be interrupted.
  • The AX5000 must not be switched off.

VAR_INPUT

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

bExecute: The block is activated by a rising edge at this input.

sFirmwareVersion: The required firmware version in form of vx_yy_bnnnn, i.e. "v1_05_b0009" or "v1.05_b0009" for version v1.05 build 0009.

sFirmwarePath: The path for the firmware pool, where the firmware files are located, i.e. "C:\TwinCAT\Io\TcDriveManager\FirmwarePool".

sNetIdIPC: AMS-NetID of the controller (IPC).

iReqEcState: Requested EtherCAT state after the update (only if an update is executed). The states are defined in the TcEtherCAT.lib as globale constants.

tTimeout: The firmware update can take a few minutes, the timeout here defines the timeout for internal ADS instances.

VAR_IN_OUT

VAR_IN_OUT
    Axis : AXIS_REF; (* Axis reference *)
END_VAR

Axis: Axis structure (see TcMC2.lib).

VAR_OUTPUT

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. "AX5200-0000-0010_v1_05_b0009.efw" *)
END_VAR

bBusy: This output is set when the function block is activated and remains set until an acknowledgement is received.

bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

iAdsErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.

iSercosErrId: Supplies the Sercos error code associated with the most recently executed command if the bError output is set.

iDiagNumber: Supplies the drive error code associated with the most recently executed firmware update if the bError output is set.

eFwUpdateState: Supplies the status of the firmware update. See E_FwUpdateState.

iLoadProgress: Supplies the progress of the firmware load in percent.

sSelectedFirmwareFile: Supplies the name of the searched firmware file.

Sample

VAR CONSTANT
   iNumOfDrives         : INT:= 2;
END_VAR
VAR
    fbFirmwareUpdate     : ARRAY[1..iNumOfDrives] OF FB_SoEAX5000FirmwareUpdate;
    Axes                 : ARRAY [1..iNumOfDrives] OF 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 := Axes[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 := Axes[I],
           eFwUpdateState => eFwUpdateState[I],
           sSelectedFirmwareFile => sSelectedFirmwareFile[I],
        );

        IF NOT fbFirmwareUpdate[I].bBusy THEN
           fbFirmwareUpdate[I](bExecute := FALSE, Axis := Axes[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 := 3; (* Error *)
        END_IF
    END_IF
3:
    (* Error handling *)
    iUpdateState := 0;

END_CASE