You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

<This page is currently under active progress.  Please contact Alisha Babbitt (ababbitt@slac.stanford.edu) for more information or questions.>

This page covers how to setup a new EtherCAT device and integrate into the EPICS Control System.  The following topics are included:

  • EtherCAT Resources & Reference Material
  • linuxRT PC Set-up
  • EtherCAT linuxRT Configuration
  • EtherCAT Template for Creating Epics Application
  • Configuring EtherCAT Epics Application
  • Debugging Tips

 

EtherCAT Resources & Reference Material

The following resources and reference material provide an introduction to the EtherCAT technology:

linuxRT PC Set-up

In the SLAC environment, we are currently running EtherCAT on industrial PC's running linux with a pre-emptive real-time patch (linuxRT).  Before configuring for EtherCAT, the very first step is to set-up a new linuxRT host.

Verification checks on linuxRT machines:

  • Please see $IOC/cpu-<bld>-<name>/README on instructions on how to power cycle machines remotely through the use of ipmi commands
  • Once you set-up your linuxRT machine and boot up, log in as laci to your linuxRT system. ( ssh laci@cpu-<bld>-<name>)
  • Test if your machine is running real-time linux using  uname -a
$ uname -a
Linux cpu-b34-mc23 3.18.11-rt7 #5 SMP PREEMPT RT Wed Mar 16 19:03:38 PDT 2016 x86_64 GNU/Linux
$ /lib/libc.so.6
GNU C Library (Buildroot) stable release version 2.20, by Roland McGrath et al.
Copyright (C) 2014 Free Software Foundation, Inc.


EtherCAT linuxRT Configuration

We are currently using Etherlab's EtherCAT Master module, which can be found under the package area.  The kernel-modules.cmd file needs to be updated to include the following:

  1. Location of EtherCAT kernel drivers
  2. Install kernel drivers
  3. Network configuration
  4. EtherCAT system configuration & set-up
  5. Start scanner process

Update the following lines of code in your $IOC/cpu-<>-<>/kernel-modules.cmd.  The following code excerpts are from $IOC/cpu-b084-hp03/kernel-modules.cmd

This current code stanza  defines the location for the EtherCAT kernel drivers.

 

# ===============================================================

# Define kernel module driver location

# ===============================================================

PACKAGE_TOP=/afs/slac/g/lcls/package

KERNEL_DRIVER_HOME=$PACKAGE_TOP/linuxKernel_Modules

ETHERCAT_DRIVER=$KERNEL_DRIVER_HOME/ethercat/buildroot-2015.02-x86_64

The following stanza provides the network configuration, installs kernel drivers, and performs some EtherCAT system configuration & set-up

# =========================================

# Install EtherCat kernel drivers + Set-up

# =========================================

# Need to configure another ethernet port on cpu-b084-hp03 for ethercat

# MUST configure another ethernet port for ethercat

# ifconfig eth1 192.168.1.10 netmask 255.255.252.0

# Recommend using the following logic to configure based on the port’s MAC Address

EthCat_MAC_ADDR=00:0B:AB:39:3F:CB

eth_cat=$(ifconfig -a | grep "HWaddr ${EthCat_MAC_ADDR}" | awk '{print $1}')

ifconfig ${eth_cat} netmask 255.255.255.0



# insert MAC address for eth1 after main_devices

# the ethercat slaves/devices are connected at eth1 (for this specific configuration)


insmod $ETHERCAT_DRIVER/master/ec_master.ko main_devices=${EthCat_MAC_ADDR}

insmod $ETHERCAT_DRIVER/devices/ec_generic.ko


/sbin/ifconfig eth1 up


ln -s $ETHERCAT_DRIVER/tool/ethercat /sbin/ethercat


sleep 5

chmod o+rw /dev/EtherCAT*


# ===========================================================

Next, need to add the following lines to start the scanner process up automatically.

# ===================================================================

 

# Now we start the ethercat scanner process under the linux screen program:

 

# This will allow us to attach/detach to our Ethercat scanner process

 

# ==============================================

 

# ==============================================

cd $EPICS_IOCS/cpu-b084-hp03

su laci -c $EPICS_IOCS/vioc-b084-tmp1/scannerStartup.sh

# =================================================

 


Verification checks on linuxRT machines:

  •  Test if your machine has the Etherlab EtherCAT driver module loaded.

$ ethercat version

IgH EtherCAT master 1.5.2 2eff7c993a63

$ lsmod | grep ec

ec_generic              3453  1

ec_master             240382  3 ec_generic

  • If the slaves are connected with the setup, the ethercat command line tool can help visualize it.

$ ethercat slaves

0  0:0  OP  +  E1250-EC-UC V1.7b1

  • Another helpful ethercat command line took is ethercat master

EtherCAT Template for Creating Epics Application

When starting a new EtherCAT application, it is highly recommended to start a new epics application and vioc using the slac_ethercat template.

Configuring EtherCAT Epics Application

The EtherCAT application has two parts.

  1. The scanner process which scans the bus.
  2. The IOC application

The scanner process open up unix socket for communication with IOC.

To setup the scanner, chain.xml file is to be created.

  1. Obtain the device.xml file from the vendor and add it in the /etc/xml folder.
  2. Create a chain.xml file defining the devices on the network. (ref: $APP/users/namrata/EtherCATest/etc)

<chain>

<device type_name="E1250-EC-UC" revision="0x00010007" position="0" name="LINMOTOR0" />

</chain>

  1. To obtain the revision number for the device use the slaves etherlab command line tool.

    $ ethercat slaves -v -p0

    === Master 0, Slave 0 ===

    Device: Main

    State: OP

    Flag: +

    Identity:

      Vendor Id:       0x4c4e5449

      Product code:    0x009606e3

      Revision number: 0x00010007

      Serial number:   0x1bd200e7

  2. Generate the scanner.xml file using the script - expandChain.py present under /etc/scripts
scripts/expandChain.py  chain.xml > scanner.xml
  1. Generate the database template file using the script - makeTemplate.py present under /etc/scripts. The maketemplate.py file has shortennames function: Use it to shortenn names of the PVs.
scripts/maketemplate.py -b xml -d E1250-EC-UC -r 0x00010007 -o E1250-EC-UC.template
  1. Add the scanner.xml file in a bin folder along with the scanner binary in $IOC/vioc-b34-mc23 folder.
  2. Add the script to start the scanner as a linux screen process. (ref: $IOC/cpu-b34-mc23)

  3. Start the scanner at 100Hz frequency.

 

Python version: Python 2.7.9

export the correct version to the path

 $ python --version

 Python 2.7.4

$ export PATH=/afs/slac/g/lcls/package/python/python2.7.9/linux-x86_64/bin/:$PATH

$ python --version

Python 2.7.9




Debugging Tips

  • No labels