EtherCAT xpc

From Ethercat

Jump to: navigation, search

The configured EtherCAT can be used in Matlab/Simulink using xPC target. The configurations are exported in the EtherCAT configurator in an xml file and imported in Matlab. Before you can use the special EtherCAT Simulink library you have to download and install a zip-file.


Basic configuration

The xPC target must have an ethernet adapter based on the Intel 8255X chipset to be able to comminucate with the EtherCAT Coupler. The Beckhoff FC9001 is an example of a suitable EtherCAT adapter. The EtherCAT coupler needs to be connected to the xPC target with a normal ethernet cable (no crossed cable/ no switch). The xPC target explorer xpcexplr can make a boot floppy/CD/DOS/Network. The xPC target configuration can be checked using the Matlab command: xpctest.

A basic EtherCAT Simulink model consist of at least three blocks: EtherCAT Init, EtherCAT Rx frames and EtherCAT update

Key settings in Simulink and modification in .xml file

In the simulink model you build, make sure in the Simulation->Configuration parameters->Code generation->system target file, change it to xpctarget.tlc

Matlab simulink will popup an error when you try to build and initialize the blocks: that BOOL type data cannot be accept, just open the xml file and replace all BOOL with BOOLEAN manually. then you are fine to initialize the blocks.Additionally not al combinations of MATLAB and the ethercat configurator will work. Matlab provides bugfixes on its website (834038, 932059, 877125, 780463).

Read/write variables

The variables can be read/write using respectively the EtherCAT Simulink blocks: EtherCAT Rx Var and EtherCAT Tx Var. Pay attention that the variables read/write are values between 1 and 231.


If you use the xPC EtherCAT library together with other xPC libraries, there might occur an error during building your model. This could be due to a small bug in [MATLAB root]\toolbox\rtw\targets\xpc\target\build\xpcblocks\rtwmakecfg.m (line 148):

makeInfo.library(1).Name = 'AtEcat_xpc'; 

changing this line into the following might fix the problem:

makeInfo.library(k).Name = 'AtEcat_xpc'; 

setup matlab xpc

  • connect the 2 pc's with a cross link cable
  • turn off internet access (for safety)
  • turn off windows firewall (from control panel)
  • run matlab
  • get the IP info by typing in the comand line

If you are using xpcexplr (32bit sytems)

  • run xpcexplr
  • go to comminucations panel
  • set the ip adres to the ip adres you got with !ipconfig + 1 (eg you got set
  • set the LAN subnet mask adres

If you are using the command line (64bit systems)

tgs = xpctarget.targets;
env = tgs.Item('TargetPC1');

env.TcpIpTargetAddress = '';
env.TcpIpSubNetMask = ''; 
env.TargetMACAdress = '00:00:00:00:00:00';
env.TargetBoot = 'NetworkBoot';

the ip adres should be the ip adres you obtained with !ipconfig + 1.

Build and compile code

To build models xPC requires a installed and configured compiler (e.g. Microsoft SDK 7.1, refer to the MATLAB website for the best compiler for your setup). After the installation the compiler can be configured with:

xpcsetCC setup

Test xPC

The proper working of xPC can be tested with:


Personal tools

דומיין בעברית  דומיין  דומין  תוכנה לניהול  קשרי לקוחות  CRM, ניהול קשרי לקוחות  דומין בעברית  פורומים  ספרדית  גיבוי