Beckhoff ethercat 64 with bit linuxcnc, How to install.

More
29 Sep 2020 06:35 #184242 by hozte
Hello AP,

do you find a solution? I have the same problem.

regards
Matthias

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

More
29 Sep 2020 08:21 #184253 by hozte
After reading this Thread, Grotis give a hint at page 4 to someone who have the same problem. Unfortunately i cant read the hint:-(

Maybe Grotius can help again?

best regards Matthias

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

More
29 Sep 2020 09:11 - 29 Sep 2020 09:18 #184257 by Grotius
Hi,

Ec debianize is just a script for autostart the ethercat bus at pc startup.
But if ec debianize is not working, follow this steps and start your bus by a terminal command.

For info, this example has nothing involved with linuxcnc. The steps are showing how to install the ethercat bus on a linux pc and
then how to insert a ethercat kernel module EL2124 into the golden ring.

Info:
etherlab.org/en/ethercat/index.php

in terminal :
hg clone hg.code.sf.net/p/etherlabmaster/code ethercat-hg
cd ethercat-hg
hg update stable-1.5

Then in the ethercat-hg directory open the textfile INSTALL with text editor. Follow this steps.

In terminal:
./bootstrap
./configure --disable-8139too (this disables the 8139 driver, we will use generic driver)
make all modules

sudo make modules_install install
sudo depmod

--x--
sudo ln -s ${PREFIX}/etc/init.d/ethercat /etc/init.d/ethercat
sudo cp ${PREFIX}/etc/sysconfig/ethercat /etc/sysconfig/ethercat
--x--

if the steps between x are a problem. open directory ethercat-hg/script/
copy the ethercat-hg/sysconfig map to c:etc/ result = c:etc/sysconfig/ethercat
copy the ethercat-hg/inti.d/ethercat to c:etc/init.d/.. result = etc/init.d/etercat

Then in terminal :
ip link show (for your mac adres, used by next step)

open file as root : (sudo thunar, or sudo apt-get install thunar)
/etc/sysconfig/ethercat ( insert mac adress and generic driver )

MASTER0_DEVICE="yo:ur:ma:c:ad:re"
DEVICE_MODULES="generic"

Ok close file.

This one i did not use :
echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules

Restart your system.
I started the ethercat by terminal command :
/etc/init.d/ethercat start
or
sudo /etc/init.d/ethercat start

You can do also : ethercat start / ethercat stop / ethercat status / etc.

Now the lights on the busterminal are flickering.
To test a kernel module, in terminal :

goto :
ethercat-hg/examples/mini/ (open terminal here)

In terminal :
sudo insmod ec_mini.ko
dmesg

My output : [ 6256.088425] ec_mini: AL states: 0x0A.

Ok now we make a custom kernel module for the EL2124. See attached mini.c file
Rename your current ethercat-hg/examples/mini.c file
Copy the attached mini.c file into ethercat-hg/examples

1.
open terminal in : ethercat-hg/examples/mini/
in terminal :
sudo make clean

2.
open terminal in : ethercat-hg/
in terminal :
make modules all

3.
open terminal in : ethercat-hg/examples/mini/
in terminal :
sudo insmod ec_mini.ko

4.
In terminal type : dmesg
Output dmesg :
[ 6647.436412] EtherCAT 0: Domain 0: Working counter changed to 1/1
[ 6647.436413] .
[ 6647.436414] ec_mini: Domain1: WC 1.
[ 6647.436415] ec_mini: Domain1: State 2.
[ 6647.508440] EtherCAT 0: Slave states on main device: OP.
[ 6647.804426] ec_mini: AL states: 0x08.

Ok the EL2124 is flickering 5 volts outputs. So now we are sure the ethercat bus is working oke.

to unload the kernel module : sudo rmmod ec_mini.ko
then : dmesg

Terminal output:
[ 7365.583838] ec_mini: Stopping...
[ 7365.583841] ec_mini: Releasing master...
[ 7365.583842] EtherCAT 0: Releasing master...
[ 7365.583868] EtherCAT 0: Master thread exited.
[ 7365.583875] EtherCAT 0: Starting EtherCAT-IDLE thread.
[ 7365.583916] EtherCAT 0: Released.
[ 7365.583916] ec_mini: Unloading.
[ 7365.592445] EtherCAT 0: Slave states on main device: PREOP, OP.
[ 7365.616433] EtherCAT 0: Slave states on main device: PREOP.


In the map /ethercat-hg/examples/user/main.c
This example is also working nice with QT programming. But it's at userland level.
Attachments:
Last edit: 29 Sep 2020 09:18 by Grotius.
The following user(s) said Thank You: Nico2017

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

More
29 Sep 2020 18:03 #184314 by hozte
Hello Grotius,
thanks for this fast answer. I will test this tomorrow.

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

More
05 Oct 2020 10:08 #184955 by hozte
it requiered more time, but it works!

Many thanks

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

More
05 Oct 2020 18:31 #184991 by Grotius
** Installation guide for Ethercat with Debian10.

It's done in 4 stages.

1. Install debian 10 (includes linuxcnc)
2. Install etherlab software
3. Install ec-debianize (is etherlab, configured linuxcnc compatible)
4. Install linuxcnc-ethercat (lcec driver for linuxcnc)

$ are user terminal commands, # as root.

-- Download & install the iso cd : www.linuxcnc.org/iso/linuxcnc-2.8.0-buster.iso

-- Install missing buster kernel headers

$ sudo apt install linux-headers-$(uname -r)

-- Install some dependencies
$ sudo apt-get install debhelper dkms gettext autoconf automake libtool quilt mercurial git

-- Get the ethercat software
$ hg clone hg.code.sf.net/p/etherlabmaster/code ethercat-hg
$ cd ethercat-hg
$ hg update stable-1.5

-- Install the ethercat software
$ ./bootstrap
$ ./configure --disable-8139too --with-linux-dir=/usr/src/linux-headers-4.19.0-11-rt-amd64/
$ make all modules
$ sudo make modules_install install
$ sudo depmod

**x**
-- Retrieve mac adres
$ ip link show

-- Copy some files around. Use $ sudo thunar
copy from etherlab-hg directory "script/init.d/ethercat" to /etc/init.d/ -->> change permissions to user
copy from etherlab-hg directory "script/sysconfig/ethercat" to /etc/sysconfig -->> change permissions to user

-- Edit ethercat file in /etc/sysconfig/:
MASTER0_DEVICE="your mac adres"
DEVICE_MODULES="generic"
**x**

-- Start Ethercat bus
$ sudo /etc/init.d/ethercat start

-- Check if your ethercat bus is running :
$ sudo /etc/init.d/ethercat status

-- At this stage we have no ec-debianize patches done to the ethercat software.

-- Install ec-debianize
edit file :
/etc/mercurial/hgrc
add to file :

[extensions]
mq =

$ git clone github.com/sittner/ec-debianize.git
$ cd ec-debianize
$ ./get_source.sh
$ cd etherlabmaster && dpkg-checkbuilddeps (and install missing deps by : sudo apt-get instal ..)
$ dpkg-buildpackage

-- Install deb packages
$ sudo dpkg -i /home/user/ec-debianize/etherlabmaster_1.5.2+20190904hg33b922p8ea394-1_amd64.deb
$ sudo dpkg -i /home/user/ec-debianize/etherlabmaster-dbgsym_1.5.2+20190904hg33b922p8ea394-1_amd64.deb
$ sudo dpkg -i /home/user/ec-debianize/etherlabmaster-dev_1.5.2+20190904hg33b922p8ea394-1_amd64.deb

edit file : /etc/default/ethercat -> see steps section **x** above
$ sudo update-ethercat-config


-- Install linuxcnc-ethercat
$ git clone github.com/sittner/linuxcnc-ethercat.git
$ cd linuxcnc-ethercat
$ sudo apt-get install libexpat1-dev
$ make

Restart pc. Ethercat bus will now start by itself. Don't forget to attach cat cable.

-- Test Linuxcnc with ethercat

1. Start linuxcnc choose axis config, create desktop icon.

2. Edit : /home/user/linuxcnc/configs/sim.axis/axis.ini
Add : POSTGUI_HALFILE = postgui.hal

3. Create postgui.hal file in the axis.ini directory.
Add :
loadusr -W /home/user/linuxcnc-ethercat/src/lcec_conf /home/user/linuxcnc/configs/sim.axis/ethercat-conf.xml
loadrt lcec
addf lcec.read-all servo-thread
addf lcec.write-all servo-thread

4. Create ethercat-conf.xml file in the axis.ini directory.
my file looks like :

<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="1000">
<slave idx="0" type="EK1100" name="Terminal"/>
<slave idx="1" type="EL2124" name="Dig_out0"/>
<slave idx="2" type="EL2124" name="Dig_out1"/>
</master>
</masters>

5. Copy the lcec_conf file from /home/user/linuxcnc-ethercat/src/ to your linuxcnc axis.ini directory
6. Copy the lcec.so file from /home/user/linuxcnc-ethercat/src/ to /usr/lib/linuxcnc/modules/
7. Open /dev/Ethercat0 --> set all permissions to read/write.
Open /etc/udev/rules.d/00-ethercat.rules -> to stop complaining Ethercat0 rules i modified to : KERNEL=="EtherCAT[0-9]*", MODE="0660", GROUP="your user group name"

8. Restart linuxcnc. Open machine -> hal configuration -> Pins -> lcec
your slave pin's will show up.
9. Test Hal command : setp lcec.0.Dig_out0.dout-0 true
10. Oke that's all. Application restart tested ok.
The following user(s) said Thank You: tommylight, Nico2017

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

More
05 Oct 2020 20:07 #185002 by Mike duran
good, I new to this group and i want to install ethercat on my machines as show in your instructions, when executing the "dpkg-buildpackage" instruction inside the etherlabmaster directory, it throws me this error, you know why:

dpkg-source --before-build etherlabmaster
debian/rules clean
dh clean --with autoreconf,dkms
dh_testdir
dh_auto_clean
dh_autoreconf_clean
debian/rules override_dh_clean
make[1]: Entering directory '/home/lion/ec-debianize/etherlabmaster'
rm -f ChangeLog
dh_clean
make[1]: Leaving directory '/home/lion/ec-debianize/etherlabmaster'
dpkg-source -b etherlabmaster
dpkg-source: error: can't build with source format '3.0 (quilt)': no upstream tarball found at ../etherlabmaster_1.5.2+20190904hg33b922p8ea394.orig.tar.{bz2,gz,lzma,xz}
dpkg-buildpackage: error: dpkg-source -b etherlabmaster gave error exit status 255

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

More
05 Oct 2020 20:46 - 05 Oct 2020 20:58 #185006 by Grotius
Hi, I know your error. I could fix that quite quickly. It's solution is at --Install ec-debianize next line.

Just to help you a little bit more :

First be sure you have a mercurial install.
$ sudo apt-get install mercurial (mercurial is just as github, mercurial has a config file we have to edit to solve your issue).

Open file : c:/etc/mercurial/hgrc (use "sudo thunar" in terminal to edit the file as root)
Add to file hgrc file the following 2 lines of text :

[extensions]
mq =


save file.

reference 1 : forum.linuxcnc.org/24-hal-components/223...ver?start=870#166516
reference 2 : stackoverflow.com/questions/8360471/how-...xtensions-such-as-mq

If your error keeps the same. restart pc.
Last edit: 05 Oct 2020 20:58 by Grotius.
The following user(s) said Thank You: Nico2017, Mike duran

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

More
05 Oct 2020 23:37 #185019 by Mike duran
Grotius, thanks for your quick answer, it worked for me but at the moment of wanting to run an ini file from linuxcnc I get the following error in terminal:

# I already copied the lcec_conf file in the file where the ini are, so if the error I do not think is because of that

Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/lion/linuxcnc_debug.txt
and
/home/lion/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

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

More
06 Oct 2020 12:40 - 06 Oct 2020 12:48 #185057 by Grotius
Hi Mike,

You forgot to send the debug output of linuxcnc. Or make a screenshot of the relevant debug info.
Start your linuxcnc config step by step. And be sure about correct path's.

In my postgui.hal file the search path is :
loadusr -W /home/user/linuxcnc-ethercat/src/lcec_conf /home/user/linuxcnc/configs/sim.axis/ethercat-conf.xml

For your postgui.hal file the path is :
1**. loadusr -W /youpath/lcec_conf .. .. .. .. .. /yourpath/ethercat-conf.xml (delete the dots)
2. loadrt lcec
3. addf lcec.read-all servo-thread
addf lcec.write-all servo-thread


In fact you could directly link to the orginal lcec_conf folder, in above example without making a copy of the
lcec_conf file to your linuxcnc config directory, where your axis.ini file is located.

You could start linuxcnc with only line 1**. Only load the lcec_conf file. If linuxcnc starts normal, add line 2, etc.
Check the message output of linuxcnc and anticipate on this. If you can't solve it. Just ask over here.

I mentioned Debian buster 10 will not provide usb-tetering from a clean install.
To enable Ethernet over USB :

in terminal :
$ ip link show --> look for the output number other then enp0s25 or lo, in my case :
3: enp0s26f7u5: <BROADCAST,MULTICAST,UP,LOWER_UP>

goto :
c:/etc/modules-load.d/modules.conf --> add:
g_ether

c:/etc/network/interfaces --> add :
allow-hotplug enp0s26f7u5
iface enp0s26f7u5 inet dhcp


done !
restart pc.

Reference : unix.stackexchange.com/questions/574640/...-using-ethernet-over
Last edit: 06 Oct 2020 12:48 by Grotius.
The following user(s) said Thank You: Mike duran

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

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