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.

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.

FB_EcFoeLoad 3: Inputs

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

Name

Type

Description

sNetId

T_AmsNetId

String containing the AMS network ID of the EtherCAT master device.

nSlaveAddr

UINT

Fixed address of the EtherCAT slave whose file is to be uploaded or downloaded.

sPathName

T_MaxString

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

dwPass

DWORD

Password (default: 0)

eMode

E_EcFoeMode

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

bExecute

BOOL

The function block is activated by a positive edge at this input.

tTimeout

TIME

Maximum time that must not be exceeded when the function block is executed (default: 200 s).

FB_EcFoeLoad 4: Outputs

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

cbLoad

UDINT

Number of successfully written or read data bytes

nProgress

UDINT

Write access progress (range: 0 - 100%). This variable is currently not used for read access, in which case it is always 0.

sInfo

T_MaxString

Additional command information as string (reserved)

Sample in ST:

A rising edge at the bLoad variable triggers the firmware download via the “File access over EtherCAT” mailbox protocol.

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 v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT