FB_SoEAX5000FirmwareUpdate

FB_SoEAX5000FirmwareUpdate 1:

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:

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:

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

FB_SoEAX5000FirmwareUpdate 2: 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

NetId

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:

  • "v1.05_b0009"    for a specific build, e.g. v1.05 Build 0009
  • "v1.05_b00??"    latest build of a specified version, e.g. v1.05
  • "v1.??_b00??"    latest build of a specified main version, e.g. v1
  • "v?.??_b00??"    latest build of the latest version
  • " "            latest build of the latest version

Custom firmware builds:

  • "v1.05_b1009"    for a specific build, e.g. v1.05 Build 0009
  • "v1.05_b10??"    latest build of a specified version, e.g. v1.05
  • "v1.??_b10??"    latest build of a specified main version, e.g. v1
  • "v?.??_b10??"    latest build of the latest version

...

  • "v1.05_b8909"    for a specific build, e.g. v1.05 Build 8909
  • "v1.05_b89??"    latest build of a specified version, e.g. v1.05
  • "v1.??_b89??"    latest build of a specified main version, e.g. v1
  • "v?.??_b89??"    latest build of the latest version

Debug builds:

  • "v1.05_b9009"    for a specific build, e.g. v1.05 Build 9009
  • "v1.05_b90??"    latest build of a specified version, e.g. v1.05
  • "v1.??_b90??"    latest build of a specified main version, e.g. v1
  • "v?.??_b90??"    latest build of the latest version

 

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 statuses are defined as global constants in PLC Lib Tc2_EtherCAT.

tTimeout

TIME

Since the firmware update for large EtherCAT networks can take longer, only the timeout for individual internal ADS instances is specified here.

FB_SoEAX5000FirmwareUpdate 3: Inputs/outputs

VAR_IN_OUT
   Axis : AXIS_REF;
END_VAR

Name

Type

Description

Axis

AXIS_REF

Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state.

FB_SoEAX5000FirmwareUpdate 4: 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

Busy

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;
    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 := 0; (* Error *)
        END_IF
      END_IF
END_CASE