Main Content

Configure EtherCAT Master Node Model

Before configuring the model, complete the procedure in Configure EtherCAT Network by Using TwinCAT 3.

Image of slrt_ex_ethercat_beckhoff_aio model

To configure model slrt_ex_ethercat_beckhoff_aio for execution by using the target computer as master node, complete the procedure in Configure EtherCAT Init Block.

Configure EtherCAT Init Block

Before you use the EtherCAT Init block, configure the EtherCAT® network with TwinCAT® 3.

Before you start this procedure, familiarize yourself with TwinCAT 3 and its documentation.

As part of the configuration process, create and save an EtherCAT Network Information (ENI) file. See Configure EtherCAT Network by Using TwinCAT 3.

To include EtherCAT distributed clocks when PTP is enabled for the model, use EtherCAT bus shift mode.

To configure the EtherCAT Init block of model slrt_ex_ethercat_beckhoff_aio:

  1. Open model slrt_ex_ethercat_beckhoff_aio. In the MATLAB Command Window, type:

    open_system(fullfile(matlabroot, 'toolbox', 'slrealtime',...
    'examples', 'slrt_ex_ethercat_beckhoff_aio'))
  2. Double-click the EtherCAT Init block.

  3. In the Config file (ENI) text box, browse to the EtherCAT Network Information (ENI) file that you created when you configured the network (here, 'BeckhoffAIOconfig.xml'). You can enter the file name with or without single quotes.

  4. Use the default value 0 for parameter Device index.

    If the model includes more than one EtherCAT network, enter a unique Device index for each network. Enter the same value for all blocks in each network.

  5. Enter the Ethernet Port Number for the EtherCAT port that you are connecting to your EtherCAT network. See Install EtherCAT Network for Execution.

  6. Take the default value Large model for parameter DC Tuning.

    Image of EtherCAT Init block mask dialog box

  7. To update the data in the EtherCAT Init block and propagate it to the other EtherCAT blocks, click Refresh Data.

  8. Click OK.

Configure EtherCAT PDO Receive Blocks

Before beginning this procedure, you must have selected a valid ENI file in the EtherCAT Init block.

Before you start this procedure, familiarize yourself with TwinCAT 3 and its documentation.

To configure the EtherCAT PDO Receive blocks of model slrt_ex_ethercat_beckhoff_aio:

  1. Double-click the EtherCAT PDO Receive block labeled EtherCAT PDO Receive.

  2. Set parameter Device Index to the value set in the EtherCAT Init block.

  3. From the Signal Name list, select the variable, here Term 2 (EL3062).AI Standard Channel 1.Value.

  4. Observe the value in seconds of parameter Sample Time.

    Image of EtherCAT PDO Receive block parameters dialog box

  5. Click OK.

Execute steps 1–5 for the EtherCAT PDO Receive block labeled EtherCAT PDO Receive 1.

Configure EtherCAT PDO Transmit Blocks

Before beginning this procedure, you must have selected a valid ENI file in the EtherCAT Init block.

Before you start this procedure, familiarize yourself with TwinCAT 3 and its documentation.

To configure the EtherCAT PDO Transmit blocks of model slrt_ex_ethercat_beckhoff_aio:

  1. Open model slrt_ex_ethercat_beckhoff_aio.

  2. Double-click the EtherCAT PDO Transmit block labeled EtherCAT PDO Transmit.

  3. Set parameter Device Index to the value set in the EtherCAT Init block.

  4. Select a Signal Name variable, here Term 3 (EL4002).AO Outputs Channel 1.Analog output.

  5. Observe the value in seconds of parameter Sample Time.

    Image of EtherCAT PDO Transmit block parameters dialog box

  6. Click OK.

Execute steps 2–6 for the EtherCAT PDO Transmit block labeled EtherCAT PDO Transmit 1.

Configure EtherCAT Model Configuration Parameters

Before beginning this procedure, you must have selected a valid ENI file in the EtherCAT Init block. For more information, see Fixed-Step Size Derivation.

To configure the configuration parameters for model slrt_ex_ethercat_beckhoff_aio:

  1. Open model slrt_ex_ethercat_beckhoff_aio.

  2. Calculate the greatest common divisor (GCD) of the Sample Time values for the EtherCAT tasks and for all source blocks in the model. In this case, the GCD is 0.010.

  3. In the Simulink® Editor, on the Real-Time tab, from the Prepare section, click Hardware Settings. Select Configuration Parameters > Solver.

  4. Set the Type parameter to Fixed-step and Fixed-step size (fundamental sample time) to one of the following:

    • An integral divisor of the GCD value, in seconds.

    • auto, if all other source blocks in the model have defined sample times.

    In this case, set the parameter to 0.010.

    Image of Solver pane of Configuration Parameters dialog box

  5. Click OK.

The next tasks are building, downloading, and executing the EtherCAT master node model.