在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
芯片精品文章合集(500篇!) 创芯人才网--重磅上线啦!
查看: 685|回复: 0

[解决] 米尔基于瑞萨RZ/G2L开发板在工控领域的应用-基于SOEM的EtherCAT主站

[复制链接]
发表于 2023-8-24 18:02:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本篇测评由优秀测评者“qinyunti”提供。

前言
本文介绍【米尔MYD-YG2LX开发板】在工控领域的应用,实现基于SOEM的EtherCAT主站。开发环境基于WSL2。

下载代码git clone https://github.com/OpenEtherCATsociety/SOEM‍
PC端编译cd SOEM/export CC=gccmkdir build_pccd build_pc/
cmake ..
lhj@lhj:~/SOEM/build_pc$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- OS is linux
-- LIB_DIR: lib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lhj/SOEM/build_pc
lhj@lhj:~/SOEM/build_pc$

make
lhj@lhj:~/SOEM/build_pc$ make
Scanning dependencies of target soem
[  4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
[  9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
[ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
[ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
[ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
[ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
[ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
[ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
[ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
[ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
[ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
[ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
[ 61%] Linking C static library libsoem.a
[ 61%] Built target soem
Scanning dependencies of target simple_ng
[ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
[ 71%] Linking C executable simple_ng
[ 71%] Built target simple_ng
Scanning dependencies of target slaveinfo
[ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
[ 80%] Linking C executable slaveinfo
[ 80%] Built target slaveinfo
Scanning dependencies of target eepromtool
[ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
[ 90%] Linking C executable eepromtool
[ 90%] Built target eepromtool
Scanning dependencies of target simple_test
[ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
[100%] Linking C executable simple_test
[100%] Built target simple_test
lhj@lhj:~/SOEM/build_pc$

部署生成的文件如下其中libsoem.a为库文件test/linux/下的
simple_test,slaveinfo,eepromtool为测试Demo。
lhj@lhj:~/SOEM/build_pc$ tree .
.
|-- CMakeCache.txt
|-- CMakeFiles
|   |-- 3.16.3
|   |   |-- CMakeCCompiler.cmake
|   |   |-- CMakeDetermineCompilerABI_C.bin
|   |   |-- CMakeSystem.cmake
|   |   `-- CompilerIdC
|   |       |-- CMakeCCompilerId.c
|   |       |-- a.out
|   |       `-- tmp
|   |-- CMakeDirectoryInformation.cmake
|   |-- CMakeOutput.log
|   |-- CMakeTmp
|   |-- Export
|   |   `-- share
|   |       `-- soem
|   |           `-- cmake
|   |               |-- soemConfig-noconfig.cmake
|   |               `-- soemConfig.cmake
|   |-- Makefile.cmake
|   |-- Makefile2
|   |-- TargetDirectories.txt
|   |-- cmake.check_cache
|   |-- progress.marks
|   `-- soem.dir
|       |-- C.includecache
|       |-- DependInfo.cmake
|       |-- build.make
|       |-- cmake_clean.cmake
|       |-- cmake_clean_target.cmake
|       |-- depend.internal
|       |-- depend.make
|       |-- flags.make
|       |-- link.txt
|       |-- osal
|       |   `-- linux
|       |       `-- osal.c.o
|       |-- oshw
|       |   `-- linux
|       |       |-- nicdrv.c.o
|       |       `-- oshw.c.o
|       |-- progress.make
|       `-- soem
|           |-- ethercatbase.c.o
|           |-- ethercatcoe.c.o
|           |-- ethercatconfig.c.o
|           |-- ethercatdc.c.o
|           |-- ethercateoe.c.o
|           |-- ethercatfoe.c.o
|           |-- ethercatmain.c.o
|           |-- ethercatprint.c.o
|           `-- ethercatsoe.c.o
|-- Makefile
|-- cmake_install.cmake
|-- libsoem.a
`-- test
|-- linux
|   |-- eepromtool
|   |   |-- CMakeFiles
|   |   |   |-- CMakeDirectoryInformation.cmake
|   |   |   |-- eepromtool.dir
|   |   |   |   |-- C.includecache
|   |   |   |   |-- DependInfo.cmake
|   |   |   |   |-- build.make
|   |   |   |   |-- cmake_clean.cmake
|   |   |   |   |-- depend.internal
|   |   |   |   |-- depend.make
|   |   |   |   |-- eepromtool.c.o
|   |   |   |   |-- flags.make
|   |   |   |   |-- link.txt
|   |   |   |   `-- progress.make
|   |   |   `-- progress.marks
|   |   |-- Makefile
|   |   |-- cmake_install.cmake
|   |   `-- eepromtool
|   |-- simple_test
|   |   |-- CMakeFiles
|   |   |   |-- CMakeDirectoryInformation.cmake
|   |   |   |-- progress.marks
|   |   |   `-- simple_test.dir
|   |   |       |-- C.includecache
|   |   |       |-- DependInfo.cmake
|   |   |       |-- build.make
|   |   |       |-- cmake_clean.cmake
|   |   |       |-- depend.internal
|   |   |       |-- depend.make
|   |   |       |-- flags.make
|   |   |       |-- link.txt
|   |   |       |-- progress.make
|   |   |       `-- simple_test.c.o
|   |   |-- Makefile
|   |   |-- cmake_install.cmake
|   |   `-- simple_test
|   `-- slaveinfo
|       |-- CMakeFiles
|       |   |-- CMakeDirectoryInformation.cmake
|       |   |-- progress.marks
|       |   `-- slaveinfo.dir
|       |       |-- C.includecache
|       |       |-- DependInfo.cmake
|       |       |-- build.make
|       |       |-- cmake_clean.cmake
|       |       |-- depend.internal
|       |       |-- depend.make
|       |       |-- flags.make
|       |       |-- link.txt
|       |       |-- progress.make
|       |       `-- slaveinfo.c.o
|       |-- Makefile
|       |-- cmake_install.cmake
|       `-- slaveinfo
`-- simple_ng
|-- CMakeFiles
|   |-- CMakeDirectoryInformation.cmake
|   |-- progress.marks
|   `-- simple_ng.dir
|       |-- C.includecache
|       |-- DependInfo.cmake
|       |-- build.make
|       |-- cmake_clean.cmake
|       |-- depend.internal
|       |-- depend.make
|       |-- flags.make
|       |-- link.txt
|       |-- progress.make
|       `-- simple_ng.c.o
|-- Makefile
|-- cmake_install.cmake
`-- simple_ng
29 directories, 100 files
lhj@lhj:~/SOEM/build_pc$


开发板端编译cd SOEM/export CC=aarch64-linux-gnu-gccmkdir build cd build/
cmake ..
lhj@lhj:~/SOEM/build$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- OS is linux
-- LIB_DIR: lib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lhj/SOEM/build
lhj@lhj:~/SOEM/build$

make
lhj@lhj:~/SOEM/build$ make
Scanning dependencies of target soem
[  4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
[  9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
[ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
[ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
[ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
[ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
[ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
[ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
[ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
[ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
[ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
[ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
[ 61%] Linking C static library libsoem.a
[ 61%] Built target soem
Scanning dependencies of target simple_ng
[ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
[ 71%] Linking C executable simple_ng
[ 71%] Built target simple_ng
Scanning dependencies of target slaveinfo
[ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
[ 80%] Linking C executable slaveinfo
[ 80%] Built target slaveinfo
Scanning dependencies of target eepromtool
[ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
[ 90%] Linking C executable eepromtool
[ 90%] Built target eepromtool
Scanning dependencies of target simple_test
[ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
[100%] Linking C executable simple_test
[100%] Built target simple_test
lhj@lhj:~/SOEM/build$

部署cp libsoem.a /mnt/dcp test/linux/simple_test/simple_test /mnt/dcp test/linux/slaveinfo/slaveinfo  /mnt/d将上述文件rz导入开发板chmod +x simple_test slaveinfo
运行root@myir-yg2lx:~# ./slaveinfo eth0
SOEM (Simple Open EtherCAT Master)
Slaveinfo
Starting slaveinfo
ec_init on eth0 succeeded.
No slaves found!
End slaveinfo, close socket
End program
root@myir-yg2lx:~# ./simple_test eth0
SOEM (Simple Open EtherCAT Master)
Simple test
Starting simple test
ec_init on eth0 succeeded.
No slaves found!
End simple test, close socket
End program
root@myir-yg2lx:~#

总结本开发板接口资源丰富,性能强,特别适合工控领域的应用,比如作为EtherCAT主站。由于没有从站,所以暂时未能演示和从站通讯的功能。

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-16 13:39 , Processed in 0.013344 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表