Ubuntu16.04 IGH Ethercat 安装使用教程(一)

本文档详细介绍了如何在Ubuntu和Debian系统上安装支持Linux4.x内核的EtherCAT稳定版1.5。首先从sourceforge下载源码,然后安装必要的依赖,接着进行编译和安装。在安装过程中,解决了一个关于signal_pending函数声明的错误。最后,配置网络并启动测试。这是一个针对高级用户的教程,适合需要在现代Linux发行版中使用EtherCAT技术的开发者。
摘要由CSDN通过智能技术生成

**前言:**EtherCAT(以太网控制自动化技术)是一个开放架构,以以太网为基础的现场总线系统,其名称的CAT为控制自动化技术(Control Automation Technology)字首的缩写。EtherCAT是确定性的工业以太网,最早是由德国的Beckhoff公司研发。
优势:免费、开源、稳定性能良好、支持实时扩展。

说明:目前在etherlab官网上的ethercat IGH协议最高版本只到1.5.2,并且根据其提供的使用手册来看只支持linux2.6/3.x内核。对于现在普遍的ubuntu 16.4以上以及debian9以上的Linux发行版来说,都是linux4.x内核,网上的朋友如果参照几年前的帖子进行安装的话,在编译时会出现一系列棘手的BUG,导致走上排解BUG的不归路,不过目前该问题已解决。
相关文章可参考:
https://blog.csdn.net/weixin_40293570/article/details/107610445
https://www.lizhongyi.com/archives/ethercat%E7%BC%96%E8%AF%91/

1、首先下载所需要的IGH程序源码

在sourceforge上下载IGH stable-1.5版本,这个是支持linux4.x内核的。附上网址2个:

https://sourceforge.net/p/etherlabmaster/code/ci/stable-1.5/tree/
http://hg.code.sf.net/p/etherlabmaster/code
  点击DownloadSnapshot进行压缩包下载,重命名为简短一点的名字(例如 etherlab-stable1.5.zip),然后按照以下步骤配置,编译,安装即可

2、然后下载所需要的依赖

sudo apt install autoconf automake libtool net-tools
sudo apt-get install linux-headers-$(uname -r)

3、进行编译安装

unzip etherlab-stable1.5.zip
cd ~/etherlab-stable1.5     #注:这个文件夹为解压后重命名的文件夹,原来的名字太长不好记。
./bootstrap
./configure --enable-cycles --enable-hrtimer --enable-8139too=no    #可以打开configure查看详细配置项,如果你没有安装linux-headers,要在第一步安装linux-headers并指定--with-linux-dir=
make all modules
sudo make modules_install install
sudo depmod
sudo ln -fs /usr/local/etc/init.d/ethercat /etc/init.d/
sudo mkdir /etc/sysconfig
sudo ln -fs /usr/local/etc/sysconfig/ethercat /etc/sysconfig/
sudo -i
echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules

注意:与1.5.2版本不同,stable-1.5版本已将安装目录/opt/etherlab改为/usr/local

4、进行网络配置

ifconfig   #查询有线网卡的MAC地址在下面一条修改
sudo nano /etc/sysconfig/ethercat
MASTER0_DEVICE=”00:0c:29:b4:aa:66”      #注:此为ifconfig命令显示的网卡地址,安装时应该为自己的
DEVICE_MODULES=”generic”         #注:设置网卡为默认generic,如果有问题请修改为其他

5、启动测试

debian@debian:~$ ethercat

Please specify a command!

Usage: ethercat <COMMAND> [OPTIONS] [ARGUMENTS]

Commands (can be abbreviated):
  alias      Write alias addresses.
  config     Show slave configurations.
  crc        CRC error register diagnosis.
  cstruct    Generate slave PDO information in C language.
  data       Output binary domain process data.
  debug      Set the master's debug level.
  domains    Show configured domains.
  download   Write an SDO entry to a slave.
  eoe        Display Ethernet over EtherCAT statictics.
  foe_read   Read a file from a slave via FoE.
  foe_write  Store a file on a slave via FoE.
  graph      Output the bus topology as a graph.
  master     Show master and Ethernet device information.
  pdos       List Sync managers, PDO assignment and mapping.
  reg_read   Output a slave's register contents.
  reg_write  Write data to a slave's registers.
  rescan     Rescan the bus.
  sdos       List SDO dictionaries.
  sii_read   Output a slave's SII contents.
  sii_write  Write SII contents to a slave.
  slaves     Display slaves on the bus.
  soe_read   Read an SoE IDN from a slave.
  soe_write  Write an SoE IDN to a slave.
  states     Request application-layer states.
  upload     Read an SDO entry from a slave.
  version    Show version information.
  xml        Generate slave information XML.

Global options:
  --master  -m <master>  Comma separated list of masters
                         to select, ranges are allowed.
                         Examples: '1,3', '5-7,9', '-3'.
                         Default: '-' (all).
  --force   -f           Force a command.
  --quiet   -q           Output less information.
  --verbose -v           Output more information.
  --help    -h           Show this help.

Numerical values can be specified either with decimal (no
prefix), octal (prefix '0') or hexadecimal (prefix '0x') base.

Call 'ethercat <COMMAND> --help' for command-specific help.

Send bug reports to fp@igh-essen.com.
Please specify a command!

Usage: ethercat <COMMAND> [OPTIONS] [ARGUMENTS]

Commands (can be abbreviated):
  alias      Write alias addresses.
  config     Show slave configurations.
  crc        CRC error register diagnosis.
  cstruct    Generate slave PDO information in C language.
  data       Output binary domain process data.
  debug      Set the master's debug level.
  domains    Show configured domains.
  download   Write an SDO entry to a slave.
  eoe        Display Ethernet over EtherCAT statictics.
  foe_read   Read a file from a slave via FoE.
  foe_write  Store a file on a slave via FoE.
  graph      Output the bus topology as a graph.
  master     Show master and Ethernet device information.
  pdos       List Sync managers, PDO assignment and mapping.
  reg_read   Output a slave's register contents.
  reg_write  Write data to a slave's registers.
  rescan     Rescan the bus.
  sdos       List SDO dictionaries.
  sii_read   Output a slave's SII contents.
  sii_write  Write SII contents to a slave.
  slaves     Display slaves on the bus.
  soe_read   Read an SoE IDN from a slave.
  soe_write  Write an SoE IDN to a slave.
  states     Request application-layer states.
  upload     Read an SDO entry from a slave.
  version    Show version information.
  xml        Generate slave information XML.

Global options:
  --master  -m <master>  Comma separated list of masters
                         to select, ranges are allowed.
                         Examples: '1,3', '5-7,9', '-3'.
                         Default: '-' (all).
  --force   -f           Force a command.
  --quiet   -q           Output less information.
  --verbose -v           Output more information.
  --help    -h           Show this help.

Numerical values can be specified either with decimal (no
prefix), octal (prefix '0') or hexadecimal (prefix '0x') base.

Call 'ethercat <COMMAND> --help' for command-specific help.

Send bug reports to fp@igh-essen.com.

安装完成,可以接上从站进行测试,参考下一节

6、遇到问题解决办法

make all modules #执行此步后报错如下
master/master.c:1444:25: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]

解决方案:修改master/master.c文件,增加头文件引用

48行 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
49行 #include <linux/sched/types.h> // struct sched_param
50行 #include <linux/sched/signal.h> //增加signal.h
51行 #endif

祝一切好运!!!

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值