FB_EcFoeLoad

FB_EcFoeLoad 1:

The function block FB_EcFoeLoad can be used to download or upload files to or from an EtherCAT device via the "File access over EtherCAT" mailbox protocol (FoE).

FB_EcFoeLoad 2:

The file path can only point to the local file system on the computer. This means that network paths cannot be used here! To upload or download files via the FoE protocol, the function block automatically resets the EtherCAT device to BOOTSTRAP mode. Finally, the function block tries to reset the device to the original state.

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId;
    nSlaveAddr  : UINT;
    sPathName   : T_MaxString;
    dwPass      : DWORD := 0;
    eMode       : E_EcFoeMode := eFoeMode_Write;
    bExecute    : BOOL; 
    tTimeout    : TIME := T#200s; 
END_VAR

sNetId: This is a string that contains the AMS network identifier of the EtherCAT device.

nSlaveAddr: Fixed address of EtherCAT slaves, whose file is to be uploaded or downloaded.

sPathName: Contains the path name and the file name of file to be written or to be read. (e.g.: 'C:\FOE_Test\EL6751\ECATFW__EL6751_C6_V0030.efw' ).

dwPass: Password (default: 0).

eMode: "File access over EtherCAT" access mode (default: write access).

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

tTimeout: Maximum time allowed for the execution of the function block.

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
    cbLoad      : UDINT;
    nProgress   : UDINT;
    sInfo       : T_MaxString;
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.

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

cbLoad: Number of successfull written or read data bytes.

nProgress: Percentage progress at write access (Range: 0 - 100%). This variable is not used by read access, and always 0.

sInfo: Additional command information (reserved).

Example in ST: 

The firmware download via the "File access over EtherCAT" mailbox protocol is started at a rising edge at the bLoad variable.

PROGRAM MAIN
VAR
    fbDownload : FB_EcFoeLoad := (
        sNetID := '5.0.34.38.3.1',
        nSlaveAddr := 1004,
        sPathName := 'C:\FOE_Test\EL6751\ECATFW__EL6751_C6_V0030.efw',
        dwPass := 0,
        eMode := eFoeMode_Write );

    bLoad : BOOL;
    bBusy : BOOL;
    bError : BOOL;
    nErrID : UDINT;
    nBytesWritten : UDINT;
    nPercent : UDINT;
END_VAR
fbDownload(      bExecute := bLoad,
        bBusy => bBusy,
        bError => bError,
        nErrId => nErrID,
        cbLoad => nBytesWritten,
        nProgress => nPercent );

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v2.10.0 Build > 1307

PC or CX (x86)
CX (ARM)

TcEtherCAT.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib are included automatically)