【实操填坑】在树莓派上编译 EtherCAT IgH Master 主站程序

官网下载地址:
https://etherlab.org/download/ethercat/ (可list查看文件列表)
https://etherlab.org/download/ethercat/ethercat-1.5.2.pdf (pdf doc手册)

===============================================
本人操作环境:树莓派 3B+
pi@ProfinetPI:~ $ uname -a
Linux ProfinetPI 4.19.71-rt24-v8 #1 SMP PREEMPT RT Wed Jan 26 01:35:13 CST 2022 aarch64 GNU/Linux

ethercat代码版本为: 1.5.2-master-3ee5e50a
(注意:1.5.2 release包,在内核>4.15.x时会编译make modules出错,因为从4.15开始内核timer使用方式更改。)

==============================================
1. 编译ethercat master和安装:

$ git clone https://gitlab.com/etherlab.org/ethercat.git

$ cd ethercat (进入clone的源码主目录)

$ ./bootstrap (若下载的是tar.bz包,其中带有m4子目录,则不需此步骤; git clone的才需要)

$ ./configure –prefix=/opt/etherlab –with-linux-dir=/usr/src/linux –enable-8139too=no –enable-generic=yes (提前准备好内核源码,已编译)

$ make -j 4 (4个线程加快)

$ make modules (需要有Modules.symvers和 System.map文件)(分别是编译内核,编译内核模块后产生)
(此命令执行的结尾会 运行depmod, 注意不能skip, 否则安装时 modprobe会有问题)

make install
make modules_install //注意 depmod是否执行了. 安装到了 /lib/modules/

2. 开始与系统集成【二选1】
//【方案1】 如果要用 init.d脚本, 那么用下面3行:
$ sudo mkdir /etc/sysconfig
$ sudo cp /opt/etherlab/etc/sysconfig/ethercat /etc/sysconfig/ethercat //这是配置文件
$ sudo cp /opt/etherlab/etc/init.d/ethercat /etc/init.d/ethercat //这是启动脚本,特别要 注意修改其中 -c 的配置文件位置!!!
$ insserv ethercat (安装为 开机自启动服务)
// 方案1启停 master内核主站的命令为: # /etc/init.d/ethercat start| stop| reload (或 #service ethercat start|stop)

//【方案2】 如果是用的 systemd管理服务, 则运行如下命令:
cp /opt/etherlab/etc/ethercat.conf /etc/ethercat.conf (配置文件的位置)
nano /usr/lib/systemd/system/ethercat.service (如果没有,照着pdf doc 第7.4节拷贝一个.)
(这里特别 要修改其中的命令!!!! 显式自己手动写上配置文件位置 -c /path/to/conf_file再 start) (坑:不会如pdf所说默认去找/etc/ethercat.conf作为配置文件)
systemctl enable ethercat.service (设置 开机启动服务)
// 方案2启停 master内核主站的命令为: # systemctl start| stop| status ethercat.service

其实这两种系统集成方案,都是用了ethercat提供的最基础的命令来启停 内核模块,
也可以直接运行基础命令来启停【方案3】, 指令如下:
/opt/etherlab/sbin/ethercatctl -c /path/to/conf_file start|stop 【注意 配置文件路径要正确

3.启动EtherCAT主站内核模块

三种方案不管用哪种, 在 启动前都要修改自己的配置文件

启动前一定要确保对应配置文件中加入了 网卡mac 和 内核模块类型
$ sudo vi /etc/sysconfig/ethercat //更改配置文件:(填入 MAC地址或”eth0″,以及 网卡类型 “generic”

正式开始启动Master主站 (三种方法选一种即可,以方案1为例)
/etc/init.d/ethercat start|stop //注意配置文件中路径是否对.

启动后,检查是否已经载入了内核模块:
lsmod | grep ec_ (会输出两行, ec_generic 和 ec_master, 说明已装载)

4.使用tools工具

tools工具为:/opt/etherlab/bin/ethercat, 连接符号到/usr/bin/下以方便使用:
$ sudo ln -s /opt/etherlab/bin/ethercat /usr/bin/ethercat //软连接

tools的使用(/opt/etherlab/bin/ethercat为tools工具)参见 pdf doc 第7章,简单命令如下:
ethercat slave (显示挂载在主站上的从站信息)
0 0:0 PREOP + SV660_1Axis_00913 (显示出了挂在主站网络上的 汇川 SV660N伺服)

pi@ProfinetPI:~ $ ethercat -h (帮助信息)
Usage: ethercat [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.

ip Set EoE IP parameters.

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

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

#安装IgH EtherCAT主站部分完结, 之后就是如何使用主站来控制 伺服点击转圈圈了。#

Original: https://www.cnblogs.com/zhw618/p/15856283.html
Author: zhw618
Title: 【实操填坑】在树莓派上编译 EtherCAT IgH Master 主站程序

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/581788/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • [LINUX] 在 Win10 上搭建好用的终端开发环境:windows terminal + git bash + zsh + oh-my-zsh

    1、安装 git for windows 2、安装终端 2.1 Windows Terminal 2.1.1 安装 Windows Terminal 2.1.2 设置 Window…

    Linux 2023年6月8日
    0101
  • redis

    字符串:类似vector,有空闲的空间 capacity和len,当长度小于1M时,每次扩容加倍,大于1M,每次扩容1M,最大512M hash: 相当于c++ unordered…

    Linux 2023年5月28日
    088
  • Linux常用命令

    Linux常用命令 在学习瑞吉外卖项目课程中自己做的一个linux常用命令的小笔记便于以后复习使用,仅供参考。 文件目录操作命令 pwd:显示该目录或者文件的路径 ls命令 ls:…

    Linux 2023年6月7日
    084
  • JavaScript快速入门-07-异常处理与调试

    7、异常处理与调试 7.1 异常处理 7.1.1 try/catch语句 try/catch语句常用于处理JavaScript中的异常,其基本语法如下所示: try { // 可能…

    Linux 2023年6月7日
    0109
  • 快速登陆linux服务器

    前言 本文适用于喜欢原生终端的用户,钟爱第三方ssh客户端的可以无视….客户端可以保存用户信息和密码,比较无脑。mac可以使用终端,win可以使用git的bash。 上…

    Linux 2023年6月14日
    0111
  • 【Docker搭建】1. 在Docker中安装MySQL5.7

    docker pull mysql:5.7 将全部的配置文件和关联的文件夹统一放到 /opt/docker/mysql 中 创建 MySQL 配置文件文件夹 mkdir -p /o…

    Linux 2023年6月13日
    079
  • [ Python ] 音视频剪辑

    https://www.cnblogs.com/yeungchie/ 视频 提取视频 from moviepy.editor import * 从 MP4 文件提取 video =…

    Linux 2023年6月7日
    093
  • rpm 打patch

    1、把patch文件放入SOURCES中 2、修改SPECS中的XXX.spec,把下图中箭头的部分都要写上,这里是一个坑 3、最后安装rmp包的时候如果有问题加上–f…

    Linux 2023年6月13日
    0107
  • 使用docker 5分钟搭建一个博客(mysql+WordPress)

    一.系统环境 二.前言 三.搭建博客 3.1 创建wordpress和mysql容器 3.2 在wordpress界面设置个人博客信息 3.3 WordPress容器创建命令的简化…

    Linux 2023年6月7日
    0100
  • LeetCode-47. 全排列 II

    题目来源 题目详情 给定一个可包含重复数字的序列 nums , 按任意顺序 返回所有不重复的全排列。 示例 1: 输入: nums = [1,1,2]输出:[[1,1,2],[1,…

    Linux 2023年6月7日
    082
  • Oracle中row_number()、rank()、dense_rank() 的区别

    row_number的用途非常广泛,排序最好用它,它会为查询出来的每一行记录生成一个序号,依次排序且不会重复,注意使用row_number函数时必须要用over子句选择对某一列进行…

    Linux 2023年6月14日
    094
  • Tomcat性能优化方案

    你使用过tomcat的话,简单的说就是”内存溢出”. 通常情况下,这种问题出现在实际的生产环境中.产生这种问题的原因是tomcat使用较少的内存给进程,通过…

    Linux 2023年6月14日
    0108
  • Linux系统安装Mysql8.0流程与遇到的问题

    安装MySQL版本为:8.0.16 1、首次安装,下载命令: wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8….

    Linux 2023年6月6日
    0120
  • [云原生]Kubernetes-资源管理(第3章)

    一、资源管理介绍 二、YAML语言介绍 三、资源管理方式 3.1 命令式对象管理 3.2 命令式对象配置 3.3 声明式对象配置 参考: Kubernetes(K8S) 入门进阶实…

    Linux 2023年6月13日
    0118
  • Redis分布式锁的使用与实现原理

    模拟一个电商里面下单减库存的场景。1.首先在redis里加入商品库存数量。 2.新建一个Spring Boot项目,在pom里面引入相关的依赖。 <dependency&gt…

    Linux 2023年5月28日
    0109
  • 解决dpkg -i后自动安装依赖的问题

    自ubuntu14.04后,运行 若有未安装的依赖会先标记,再运行 自动将标记的依赖安装,再安装包即可 参考引用: https://qastack.cn/ubuntu/40011/…

    Linux 2023年6月13日
    091
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球