查看: 1685|回复: 0

[经验] 米尔基于瑞萨RZ/G2L开发板基于SOEM的EtherCAT主站应用

[复制链接]
  • TA的每日心情

    2019-10-15 10:48
  • 签到天数: 7 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    发表于 2023-8-24 18:28:40 | 显示全部楼层 |阅读模式
    分享到:
    本篇测评由优秀测评者“qinyunti”提供。

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

    下载代码git clone ‍[url]https://github.com/OpenEtherCATsociety/SOEM‍[/url]
    PC端

    编译
    cd SOEM/
    export CC=gcc
    mkdir build_pc
    cd build_pc/

    cmake ..
    1. lhj@lhj:~/SOEM/build_pc$ cmake ..
    2. -- The C compiler identification is GNU 9.4.0
    3. -- Check for working C compiler: /usr/bin/gcc
    4. -- Check for working C compiler: /usr/bin/gcc -- works
    5. -- Detecting C compiler ABI info
    6. -- Detecting C compiler ABI info - done
    7. -- Detecting C compile features
    8. -- Detecting C compile features - done
    9. -- OS is linux
    10. -- LIB_DIR: lib
    11. -- Configuring done
    12. -- Generating done
    13. -- Build files have been written to: /home/lhj/SOEM/build_pc
    14. lhj@lhj:~/SOEM/build_pc$
    复制代码


    make
    1. lhj@lhj:~/SOEM/build_pc$ make
    2. Scanning dependencies of target soem
    3. [  4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
    4. [  9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
    5. [ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
    6. [ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
    7. [ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
    8. [ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
    9. [ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
    10. [ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
    11. [ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
    12. [ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
    13. [ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
    14. [ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
    15. [ 61%] Linking C static library libsoem.a
    16. [ 61%] Built target soem
    17. Scanning dependencies of target simple_ng
    18. [ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
    19. [ 71%] Linking C executable simple_ng
    20. [ 71%] Built target simple_ng
    21. Scanning dependencies of target slaveinfo
    22. [ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
    23. [ 80%] Linking C executable slaveinfo
    24. [ 80%] Built target slaveinfo
    25. Scanning dependencies of target eepromtool
    26. [ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
    27. [ 90%] Linking C executable eepromtool
    28. [ 90%] Built target eepromtool
    29. Scanning dependencies of target simple_test
    30. [ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
    31. [100%] Linking C executable simple_test
    32. [100%] Built target simple_test
    33. lhj@lhj:~/SOEM/build_pc$
    复制代码


    部署

    生成的文件如下
    其中libsoem.a为库文件
    test/linux/下的
    simple_test,slaveinfo,eepromtool为测试Demo。
    1. <font face="黑体">lhj@lhj:~/SOEM/build_pc$ tree .
    2. .
    3. |-- CMakeCache.txt
    4. |-- CMakeFiles
    5. |   |-- 3.16.3
    6. |   |   |-- CMakeCCompiler.cmake
    7. |   |   |-- CMakeDetermineCompilerABI_C.bin
    8. |   |   |-- CMakeSystem.cmake
    9. |   |   `-- CompilerIdC
    10. |   |       |-- CMakeCCompilerId.c
    11. |   |       |-- a.out
    12. |   |       `-- tmp
    13. |   |-- CMakeDirectoryInformation.cmake
    14. |   |-- CMakeOutput.log
    15. |   |-- CMakeTmp
    16. |   |-- Export
    17. |   |   `-- share
    18. |   |       `-- soem
    19. |   |           `-- cmake
    20. |   |               |-- soemConfig-noconfig.cmake
    21. |   |               `-- soemConfig.cmake
    22. |   |-- Makefile.cmake
    23. |   |-- Makefile2
    24. |   |-- TargetDirectories.txt
    25. |   |-- cmake.check_cache
    26. |   |-- progress.marks
    27. |   `-- soem.dir
    28. |       |-- C.includecache
    29. |       |-- DependInfo.cmake
    30. |       |-- build.make
    31. |       |-- cmake_clean.cmake
    32. |       |-- cmake_clean_target.cmake
    33. |       |-- depend.internal
    34. |       |-- depend.make
    35. |       |-- flags.make
    36. |       |-- link.txt
    37. |       |-- osal
    38. |       |   `-- linux
    39. |       |       `-- osal.c.o
    40. |       |-- oshw
    41. |       |   `-- linux
    42. |       |       |-- nicdrv.c.o
    43. |       |       `-- oshw.c.o
    44. |       |-- progress.make
    45. |       `-- soem
    46. |           |-- ethercatbase.c.o
    47. |           |-- ethercatcoe.c.o
    48. |           |-- ethercatconfig.c.o
    49. |           |-- ethercatdc.c.o
    50. |           |-- ethercateoe.c.o
    51. |           |-- ethercatfoe.c.o
    52. |           |-- ethercatmain.c.o
    53. |           |-- ethercatprint.c.o
    54. |           `-- ethercatsoe.c.o
    55. |-- Makefile
    56. |-- cmake_install.cmake
    57. |-- libsoem.a
    58. `-- test
    59. |-- linux
    60. |   |-- eepromtool
    61. |   |   |-- CMakeFiles
    62. |   |   |   |-- CMakeDirectoryInformation.cmake
    63. |   |   |   |-- eepromtool.dir
    64. |   |   |   |   |-- C.includecache
    65. |   |   |   |   |-- DependInfo.cmake
    66. |   |   |   |   |-- build.make
    67. |   |   |   |   |-- cmake_clean.cmake
    68. |   |   |   |   |-- depend.internal
    69. |   |   |   |   |-- depend.make
    70. |   |   |   |   |-- eepromtool.c.o
    71. |   |   |   |   |-- flags.make
    72. |   |   |   |   |-- link.txt
    73. |   |   |   |   `-- progress.make
    74. |   |   |   `-- progress.marks
    75. |   |   |-- Makefile
    76. |   |   |-- cmake_install.cmake
    77. |   |   `-- eepromtool
    78. |   |-- simple_test
    79. |   |   |-- CMakeFiles
    80. |   |   |   |-- CMakeDirectoryInformation.cmake
    81. |   |   |   |-- progress.marks
    82. |   |   |   `-- simple_test.dir
    83. |   |   |       |-- C.includecache
    84. |   |   |       |-- DependInfo.cmake
    85. |   |   |       |-- build.make
    86. |   |   |       |-- cmake_clean.cmake
    87. |   |   |       |-- depend.internal
    88. |   |   |       |-- depend.make
    89. |   |   |       |-- flags.make
    90. |   |   |       |-- link.txt
    91. |   |   |       |-- progress.make
    92. |   |   |       `-- simple_test.c.o
    93. |   |   |-- Makefile
    94. |   |   |-- cmake_install.cmake
    95. |   |   `-- simple_test
    96. |   `-- slaveinfo
    97. |       |-- CMakeFiles
    98. |       |   |-- CMakeDirectoryInformation.cmake
    99. |       |   |-- progress.marks
    100. |       |   `-- slaveinfo.dir
    101. |       |       |-- C.includecache
    102. |       |       |-- DependInfo.cmake
    103. |       |       |-- build.make
    104. |       |       |-- cmake_clean.cmake
    105. |       |       |-- depend.internal
    106. |       |       |-- depend.make
    107. |       |       |-- flags.make
    108. |       |       |-- link.txt
    109. |       |       |-- progress.make
    110. |       |       `-- slaveinfo.c.o
    111. |       |-- Makefile
    112. |       |-- cmake_install.cmake
    113. |       `-- slaveinfo
    114. `-- simple_ng
    115. |-- CMakeFiles
    116. |   |-- CMakeDirectoryInformation.cmake
    117. |   |-- progress.marks
    118. |   `-- simple_ng.dir
    119. |       |-- C.includecache
    120. |       |-- DependInfo.cmake
    121. |       |-- build.make
    122. |       |-- cmake_clean.cmake
    123. |       |-- depend.internal
    124. |       |-- depend.make
    125. |       |-- flags.make
    126. |       |-- link.txt
    127. |       |-- progress.make
    128. |       `-- simple_ng.c.o
    129. |-- Makefile
    130. |-- cmake_install.cmake
    131. `-- simple_ng
    132. 29 directories, 100 files
    133. lhj@lhj:~/SOEM/build_pc$


    134. <font style="font-size: 20px"><b>开发板端</b></font>
    135. <b><font style="font-size: 18px"><b>编译</b></font></b><font style="font-size: 15px">cd SOEM/</font><font style="font-size: 15px">export CC=aarch64-linux-gnu-gcc</font><font style="font-size: 15px">mkdir build</font><font style="font-size: 15px"> </font><font style="font-size: 15px">cd build/</font><font style="font-size: 15px"> </font>
    136. </font><div align="left"><font face="黑体">cmake ..</font></div><font face="黑体">lhj@lhj:~/SOEM/build$ cmake ..
    137. -- The C compiler identification is GNU 9.4.0
    138. -- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc
    139. -- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc -- works
    140. -- Detecting C compiler ABI info
    141. -- Detecting C compiler ABI info - done
    142. -- Detecting C compile features
    143. -- Detecting C compile features - done
    144. -- OS is linux
    145. -- LIB_DIR: lib
    146. -- Configuring done
    147. -- Generating done
    148. -- Build files have been written to: /home/lhj/SOEM/build
    149. lhj@lhj:~/SOEM/build$
    150. </font>
    复制代码

    make
    1. lhj@lhj:~/SOEM/build$ make
    2. Scanning dependencies of target soem
    3. [  4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
    4. [  9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
    5. [ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
    6. [ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
    7. [ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
    8. [ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
    9. [ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
    10. [ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
    11. [ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
    12. [ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
    13. [ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
    14. [ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
    15. [ 61%] Linking C static library libsoem.a
    16. [ 61%] Built target soem
    17. Scanning dependencies of target simple_ng
    18. [ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
    19. [ 71%] Linking C executable simple_ng
    20. [ 71%] Built target simple_ng
    21. Scanning dependencies of target slaveinfo
    22. [ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
    23. [ 80%] Linking C executable slaveinfo
    24. [ 80%] Built target slaveinfo
    25. Scanning dependencies of target eepromtool
    26. [ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
    27. [ 90%] Linking C executable eepromtool
    28. [ 90%] Built target eepromtool
    29. Scanning dependencies of target simple_test
    30. [ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
    31. [100%] Linking C executable simple_test
    32. [100%] Built target simple_test
    33. lhj@lhj:~/SOEM/build$
    复制代码


    部署

    cp libsoem.a /mnt/d
    cp test/linux/simple_test/simple_test /mnt/d
    cp test/linux/slaveinfo/slaveinfo  /mnt/d
    将上述文件rz导入开发板
    chmod +x simple_test slaveinfo

    运行

    1. root@myir-yg2lx:~# ./slaveinfo eth0
    2. SOEM (Simple Open EtherCAT Master)
    3. Slaveinfo
    4. Starting slaveinfo
    5. ec_init on eth0 succeeded.
    6. No slaves found!
    7. End slaveinfo, close socket
    8. End program
    复制代码
    1. root@myir-yg2lx:~# ./simple_test eth0
    2. SOEM (Simple Open EtherCAT Master)
    3. Simple test
    4. Starting simple test
    5. ec_init on eth0 succeeded.
    6. No slaves found!
    7. End simple test, close socket
    8. End program
    9. root@myir-yg2lx:~#
    复制代码

    总结

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



    回复

    使用道具 举报

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

    本版积分规则

    关闭

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



    手机版|小黑屋|与非网

    GMT+8, 2024-11-18 04:28 , Processed in 0.124472 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.