This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

EtherCAT Init

Initialize EtherCAT Master node with data in the EtherCAT Network Information (ENI) file

  • Library:
  • EtherCAT


The EtherCAT Init block initializes the EtherCAT® master stack. The block specifies the Ethernet interface cards in the network.

Before you use this block, create and save an EtherCAT Network Information (ENI) file. You export the ENI file from one of these EtherCAT configurators: the Beckhoff® ET9000, the Beckhoff TwinCAT®, or the Acontis EC-Engineer. See Configure EtherCAT Network.

To find the ENI file, click Browse. To read the ENI file and store the data in the EtherCAT Init block, click Refresh Data.

The Simulink® Real-Time™ software supports multiple EtherCAT networks. To use multiple networks:

  • Use a different Ethernet card interface for each EtherCAT network.

  • In the model, use one EtherCAT Init block for each network.

If you configure EtherCAT distributed clocks in master shift mode, using the IEEE 1588 Sync Execution block in the same model produces a build error. To include EtherCAT distributed clocks and IEEE® 1588 synchronized execution in the same model, use EtherCAT bus shift mode.



expand all

The Status vector contains six values: ErrVal, MasterState, DCErrVal, MasterToNetworkClkDiff, DCInitState, and NetworkToSlaveClkDiff.

  • ErrVal — Error status:

    • No error: 0

    • Error: Value less than 0.

    Because ErrVal shows the latest error status, the propagation of errors can hide the original error. To find the original error, add an EtherCAT Get Notifications block and use SimulinkRealTime.etherCAT.filterNotifications to print the status codes that the EtherCAT stack transmits.

  • MasterState — Operating state of the EtherCAT network:

    INIT1Initialization – The system finds slave devices and initializes the communication controller.
    PREOP2Preoperational — The system uses the communication controller to exchange system-specific initialization data. In this state, the network cannot transmit or receive signal data.
    SAFEOP4Safe operational — The network is running and ready for full operation. The master sends input data to the slave device. The slave device output remains in a safe state.
    OP8Operational — The network is in full operation. The master sends input data to the slave device. The slave device responds with output data.

  • DCErrVal — DC error status:

    The value 0 appears both if the distributed clock is turned off and if no error occurs.

  • MasterToNetworkClkDiff — Time difference, in nanoseconds, between the master stack clock and the clock on the first slave device that has enabled DC.

  • DCInitState — Operating state of the distributed clock:

    • DC not enabled or not initialized: 0

    • DC has been started: 1

  • NetworkToSlaveClkDiff — Time difference, in nanoseconds, between the clock on the first EtherCAT slave device and the least closely locked clock on the remaining slave devices.

    This value applies only to slave devices that have enabled DC. If only one device on the network has enabled DC, this value is 0.

Data Types: int32


expand all

Specify the ENI file that you exported from the EtherCAT configurator.

You can specify the full path name or a partial path name. If you specify only the file name, the software searches for the file in the current folder and on the MATLAB® path. If more than one file with that name exists on the path, MATLAB displays a message box where you select the file that you want.

Clicking Browse inserts a full, editable path name.

A unique integer in the range 0–15 that identifies the Ethernet card for an EtherCAT network.

For each EtherCAT network, the software generates a unique device index. The software inserts that device index as Device index into the EtherCAT Init block that represents the network.

Enter the PCI bus number for the Ethernet card.

Enter the PCI slot number for the Ethernet card.

Enter the distributed clock initialization parameter, one of these values:

  • Large model (default) — Sends 16,000 timing initialization packets and allows 1 second of settling time. Provides best initial synchronization between multiple slaves that have DC enabled.

  • Medium model — Sends 8,000 timing initialization packets and allows 0.3 seconds of settling time. The model reaches operational state about a second earlier than it does with the Large model setting.

  • Small model — Sends 2,000 timing initialization packets and allows 0.2 seconds of settling time. The model reaches operational state earlier than it does with the other settings.

Monitor device synchronization at the moment that the model enters the operational state. Check that the devices are synchronized closely enough for your application.


Selecting Enable Log and Debugging makes these parameters visible: Log link layer error messages, Log master state changes, Log all state changes, Log base clock changes, Log master config changes, and Target log filename.

To generate driver-level messages for driver and network debugging, select these check boxes.

For a high-speed model, turning on these options can cause CPU overloads.


To make these parameters visible, select Enable Log and Debugging.

Enter the name of the log file on the target computer, in single quotes. The default value is 'c:\dbglog.txt'.

If the target computer does not have a usable disk partition, the software does not create the log file.


To make these parameters visible, select Enable Log and Debugging.

Introduced in R2010b

Was this topic helpful?