Beckhoff ethercat 64 with bit linuxcnc, How to install.

More
03 Jun 2019 23:37 - 05 Aug 2019 02:41 #135811 by Nico2017
Hi all,

here is a quick step by step tutorial for the install.

  • Install linux debian with the latest OS:
    1. install debian OS from https://www.debian.org/distrib/ , choose the relevant iso adapted to your CPU architecture. I usually select the netinst for an installation through the network. But if you want to keep a ready to go iso download the CD one. During the install, select Gnome desktop as you might want to use Glade to design your machine interface.
    2. install the real time kernel:
      sudo synaptic
      then search for linux-image. Mark for installation the latest linux-image-***-rt-*** which might be described as a PREEMPT_RT kernel. The *** must match the version you want (probably the latest on the list) and the architecture of your install. Select the associated headers linux-headers-***-rt-*** matching the real time installation you just previously marked. Mark it for installation as well. Then apply to install both.
    3. reboot and make sure that you boot choosing the real time kernel newly installed (in the advanced options for Debian sub menu). This might be the one booting by default now. To check use
      uname -a
      which should display your real time install -rt- . We are going to uninstall the non real time kernel:
      sudo synaptic
      , then search linux-image and then mark for complete removal the original install. Reboot, then the system should always boot on the remaining system which is the real time. While booting the advanced options for Debian sub menu should only display the rt option and its recovery mode.
  • Install linuxcnc
  • You can follow instructions from @Grotius in this thread, big thanks for that. Also you can find the guidelines for the linuxcnc build in http://linuxcnc.org/docs/2.8/html/code/building-linuxcnc.html . I slightly adapted them for different reasons:
    1. git clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
      to clone linuxcnc into the linuxcnc-dev directory. This way I never mistake it with the linuxcnc directory created by the linuxcnc installation, where all the machine configurations are stored.
    2. git clone https://github.com/sittner/ec-debianize.git
      , while we are cloning repository I also clone the other 2 required.
    3. git clone https://github.com/sittner/linuxcnc-ethercat.git
    4. sudo apt-get install dpkg-dev
      to install dpkg and prepare to be able to check the dependencies
    5. cd linuxcnc-dev/debian
      ./configure uspace
      cd ..
    6. dpkg-checkbuilddeps
      lists the packages that need to be installed before proceeding. Use a
      sudo apt-get install packagename
      to install the missing elements. Repeat until all required packages are installed.
    7. I extend the memory of the hal components before buidling linuxcnc, from @dgarret in https://forum.linuxcnc.org/10-advanced-configuration/3894-insufficient-memory-for-signal-pin?start=20
      cd src/hal/
      gedit hal_priv.h
      then I modify the value #define HAL_SIZE (85*4096) to #define HAL_SIZE (190*4096) to double the hal memory. I save and come back to the main linuxcnc-dev directory.
    8. Now you can either build for run in place or build package. I choose the second option, build the package .deb for your install:
      dpkg-buildpackage -b -uc
      , this should create two .deb on the parent directory. Install those debian package using
      sudo dpkg -i linuxcnc-uspace_XXX_*.deb
      , use
      sudo apt-get --fix-broken install
      if any packages are indicated as missing. Instal
      sudo dpkg -i linuxcnc-uspace-dev_XXX_*.deb
      and possibly missing packages too.
    9. halcmd status
      to check that the hal memory hal been installed with extended limitation, reading in the total shared memory the value which should match NNN*4096 with NNN the value you entered before building linuxcnc.
    10. you can test linuxcnc with a sim config with
      linuxcnc
      , the configs file being saved by default in ~/linuxcnc
    11. if you need to add special components like me to extend and go above the 16 limitation see: https://forum.linuxcnc.org/24-hal-components/35902-hal-names-16-argument-limit?start=0

  • Install ethercat
  • Once again, you can follow instructions from @Grotius in this thread.
    1. sudo apt-get install quilt
    2. cd ec-debianize
      ./get_source.sh
    3. cd ec-debianize/etherlabmaster/
      dpkg-buildpackage
      . If it fails you can use
      dpkg-checkbuilddeps
      and
      sudo apt-get install nameofpackage
      then retry to build the package. Once built, you should have the .deb files in ec-debianize.
    4. cd ec-debianize 
      sudo dpkg -i etherlabmaster_*_amd64.deb
      sudo dpkg -i etherlabmaster-dev_*_amd64.deb
    5. Identify your MAC address for the ethernet connexion linked to your Ethercat bus. To do so you can use
      sudo apt-get install net-tools
      sudo ifconfig
      then you can read your MAC addresses.
    6. Identify your MAC address for the ethernet connexion linked to your Ethercat bus. To do so you can use
      sudo gedit /etc/default/ethercat
      then modify the MASTER0_DEVICE="" to MASTER0_DEVICE="MACADRESS" with MACADRESS the value obtain with ifconfig. Also change DEVICE_MODULES="" to DEVICE_MODULES="generic" then save.
    7. sudo update-ethercat-config
      then reboot to make those modifications effective. To check that the ethercat is working, just connect and power your ethercat bus then try
      ethercat slaves
      You should see all the ethercat module connected to your bus.

  • Install ethercat linuxcnc driver
    1. This first step is required to make the ethercat+linuxcnc work, as indicated by @Hawkeye in https://forum.linuxcnc.org/24-hal-components/22346-ethercat-hal-driver?start=670#123888 . On my case this is required to avoid the error while launching linuxcnc with ethercat:
      <stdin>:3: waitpid failed /usr/bin/rtapi_app lcec
      <stdin>:3: /usr/bin/rtapi_app exited without becoming ready
      <stdin>:3: insmod for lcec failed, returned -1
      Go to the directory where you have been cloning the git linuxcnc-ethercat. Mine is in ~/linuxcnc-ethercat.
      cd ~/linuxcnc-ethercat
      gedit ~/linuxcnc-ethercat/src/lcec_main.c 
      edit this file adding #include "rtapi_mutex.h" below #include "rtapi_app.h" then save and close gedit.
    2. Then come back to the linuxcnc-ethercat directory, and
      make -jN
      N being the number of processor to speed up the process.
      sudo make install

    3. Copy some files across to the relevant location:
      cp ~/linuxcnc-ethercat/src/lcec_conf ~/linuxcnc/configs/FolderWhereInIFileForConfig
      to your linuxcnc sim folder (copy it where your ini files is)
      cp ~/linuxcnc-ethercat/src/lcec.so ~/linuxcnc-dev/rtlib/
      apparently only required for for linuxcnc_dev users
    4. Make the Ethercat0 permission permanent for your user for linuxcnc
      sudo adduser $USER ethercat
      sudo adduser root ethercat
      . Reboot to make it effective permanently.

  • Test linuxcnc with ethercat modules
  • Open and run an axis simulation then use

    Grotius wrote: copy lcec_conf ==> ../linuxcnc-ethercat/src/lcec_conf ==> to your linuxcnc sim map (copy it where your ini files is)
    copy lcec_so ==> ../linuxcnc-ethercat/src/lcec.so ==> to your home/.../linuxcnc/rtlib/ (this is only for linuxcnc_dev users)
    copy and edit the ethercat_config.xml from the linuxcnc-ethercat example directory and copy it where your ini file is.
    In your ini file add "HALFILE = postgui.hal"
    make a postgui.hal file include :
    loadusr -W lcec_conf ethercat-conf.xml
    #loadrt lcec
    #addf lcec.read-all servo-thread
    #addf lcec.write-all servo-thread
    First check if lcec_conf will load, open your halmeter.
    When you see the Lcec section, uncheck the # sign's in the postgui.hal file.

    To shorten boot time at connexion:
    sudo gedit /lib/systemd/system/networking.service
    then edit the last line TimeoutStartSec=5min to TimeoutStartSec=1sec and save

  • Install Glade,
    1. on
    https://forum.linuxcnc.org/48-gladevcp/33309-glade-3-20-will-not-work-with-linuxcnc-please-follow-this-for-3-8-6?start=10 , following @newbynobi instructions:

    newbynobi wrote:

    wget ftp://ftp.gnome.org/pub/GNOME/sources/glade3/3.8/glade3-3.8.6.tar.xz
    tar -xpf glade3-3.8.6.tar.xz
    now install it by typing:
    cd glade3-3.8.6
    ./configure
    make
    sudo make install
    to test the glade install, enter in the terminal:
    glade-3

    It might fail to find libxml-2.0, in this case
    sudo apt-get install libxml2-dev
    . It might also fail to launch in this case, try
    sudo apt-get install libgladeui*
    ( https://stackoverflow.com/questions/25756617/trouble-installing-glade-interface-designer-glade-doesnt-launch )
  • adapt Glade library for linuxcnc, thanks again to @newbynobi
  • newbynobi wrote:

    sudo mkdir -p /usr/local/share/glade3/backup/catalogs
    sudo mkdir -p /usr/local/share/glade3/backup/pixmaps
    sudo cp /usr/local/share/glade3/catalogs/* /usr/local/share/glade3/backup/catalogs
    sudo cp -r /usr/local/share/glade3/pixmaps/* /usr/local/share/glade3/backup/pixmaps

    now copy/add the missing files to that dir with the following terminal commands
    sudo cp ~/linuxcnc-dev/lib/python/gladevcp/*.xml /usr/local/share/glade3/catalogs
    sudo cp ~/linuxcnc-dev/lib/python/gladevcp/*.png /usr/local/share/glade3/pixmaps


    PS: somehow if glade-3 works but the hal components are not showing up, you can try to uninstall glade-3 using
    suo make uninstall
    sudo make clean
    Then follow the command indicated by Grotius, even if this is not you associated OS:

    paste this before "http:// : " ( to many links in post )
    linuxcnc.org/dists/wheezy/base/binary-amd64/libgladeui-1-11_3.8.0-0ubuntu6_amd64.deb
    linuxcnc.org/dists/wheezy/base/binary-amd64/glade-gtk2_3.8.0-0ubuntu6_amd64.deb
    linuxcnc.org/dists/wheezy/base/binary-amd64/glade-gnome_3.8.0-0ubuntu6_amd64.deb
    Unpack in terminal :
    $ sudo dpkg -i libgladeui-1-11_3.8.0-0ubuntu6_amd64.deb
    $ sudo dpkg -i glade-gtk2_3.8.0-0ubuntu6_amd64.deb
    $ sudo dpkg -i glade-gnome_3.8.0-0ubuntu6_amd64.deb

    Then retry to install glade-3, with
    ./configure
    make -jn
    sudo make install
    I believe this issue could come from a missing dependency linuxcnc and glade hal components related but I am not sure 100%.

    I hope that this post will be usefull and contains all steps to create a new install with a latest RT OS for Debian and linuxcnc on a 64bits architecture, with a running Ethercat capability and Glade for building user interface. This is more a summary of different answers from different post and I though it would be useful to assemble them in one post.

    Thank you to those who helped me when I was stuck in one step: @grotius, @Hawkeye, @dgarrett, @newbynobi

    Nicolas
    Last edit: 05 Aug 2019 02:41 by Nico2017. Reason: More precise
    The following user(s) said Thank You: chimeno, Grotius, cola wonton

    Please Log in or Create an account to join the conversation.

    More
    04 Jun 2019 18:24 #135852 by chimeno
    Hello Nico2017
    I would like to know this line "add #include" rtapi_mutex.h "below #include" rtapi_app.h "then save and close gedit.
    make -jN "in what affects the linuxcnc-ethercat ?, I just tried and I said that the file does not exist, where does it come from?
    regards
    Chimeno

    Please Log in or Create an account to join the conversation.

    More
    02 Jul 2019 02:17 #138365 by cheng
    hi Could you tell me how to use l to control the servo motor, or give me a tutorial

    Please Log in or Create an account to join the conversation.

    More
    04 Jul 2019 22:37 - 04 Jul 2019 22:42 #138649 by JimPanski
    Hi@all!

    i am trying to install ethercat but after $ dpkg-buildpackage i got this error:
    configure: exit 1
    dh_auto_configure: ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=${prefix}/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --enable-kernel --enable-generic --enable-ccat --disable-8139too --disable-e100 --disable-e1000 --disable-e1000e --disable-r8169 --enable-sii-assign --enable-hrtimer returned exit code 1
    debian/rules:24: die Regel für Ziel „override_dh_auto_configure“ scheiterte
    make[1]: *** [override_dh_auto_configure] Fehler 2
    make[1]: Verzeichnis „/home/usr/ec-debianize/etherlabmaster“ wird verlassen
    debian/rules:13: die Regel für Ziel „build“ scheiterte
    make: *** [build] Fehler 2
    dpkg-buildpackage: Fehler: Fehler-Exitstatus von debian/rules build war 2
    has anyone an idea what the problem is? i tried this the last couple hours with starting over again. tried also dpkg-buildpackage -b -uc but nothing helped. dpkg-checkbuilddeps shows nothing
    thank you for your help!
    Last edit: 04 Jul 2019 22:42 by JimPanski.

    Please Log in or Create an account to join the conversation.

    More
    04 Jul 2019 22:57 #138650 by Grotius
    @Jim,

    Aiai, a German installation 64 bit ethercat, nice !!

    dpkg-checkbuilddeps shows nothing
    That is good news for today !

    In what step are you at the installation?
    It looks you did a terminal : ./configure

    die Regel für Ziel „override_dh_auto_configure“ scheiterte
    What has been your override command?

    Read this carefully :

    Part of the message is hidden for the guests. Please log in or register to see it.

    Please Log in or Create an account to join the conversation.

    More
    04 Jul 2019 23:02 #138652 by Grotius
    @Cheng,

    Your question is here : forum.linuxcnc.org/38-general-linuxcnc-q...cnc-to-control-slave

    It's nice to see Ethercat is next to Hong Kong !!

    Please Log in or Create an account to join the conversation.

    More
    04 Jul 2019 23:10 #138653 by JimPanski
    Hi Grotius!

    this was quick ;) yes, i hope this will be nice :D

    GOOD NEWS! I managed to find the problem. At the installation of the preemt kernel i got the wrong header files choosen. Now with the correct headers and deinstalled unused kernel+header files this works so far! awsome...

    Thank you for your quick response and generally for your nice feedback with those components. only because of that i am now switched to beckhoff for this upcoming project ;)

    Best regards
    Conny
    The following user(s) said Thank You: Grotius

    Please Log in or Create an account to join the conversation.

    More
    05 Jul 2019 21:40 #138709 by JimPanski
    Hi Grotius,

    my inputs on the EL1004 modules are working fine now :) At least on the second try. Now i know that you cant load the lcec component in the already existing postgui_call_list.hal! its a bit tricky because of postgui.hal in the description.


    But one thing i have to ask:

    Grotius wrote: I now use a EL2124 to guide 4 stepgen signals ( 4 motor pulse train's )

    Does it mean you are using one EL2124 for 4 independent stepper drivers? if so, please tell me how can this be done if you need a 5v STP DIR and ENA signal for one driver.

    Thank you!

    Please Log in or Create an account to join the conversation.

    More
    08 Jul 2019 21:56 #138898 by Grotius
    @Nico,

    Thank you very much for your tutorial. Sorry i was a bit late to thank you.

    Respect for you B)
    The following user(s) said Thank You: Nico2017

    Please Log in or Create an account to join the conversation.

    More
    09 Jul 2019 00:31 - 09 Jul 2019 00:42 #138919 by Grotius
    @Jim,

    Does it mean you are using one EL2124 for 4 independent stepper drivers? if so, please tell me how can this be done if you need a 5v STP DIR and ENA signal for one driver.

    2 pieces of this high speed (<1ms) output stuff is enough.



    Switching times typ. TON: < 1 µs, typ. TOFF: < 1 µs

    If a McLaren has this valve time, they will go faster....

    Now i know that you cant load the lcec component in the already existing postgui_call_list.hal!
    Is this for the Nico tutorial? Please provide more information about your item... This for other user's.
    Last edit: 09 Jul 2019 00:42 by Grotius.

    Please Log in or Create an account to join the conversation.

    Moderators: PCWjmelson
    Time to create page: 0.145 seconds
    Powered by Kunena Forum