Beckhoff ethercat 64 with bit linuxcnc, How to install.

More
27 Nov 2018 05:45 - 27 Nov 2018 08:07 #121451 by Grotius
I still have problem's to get Ethercat running on Linuxcnc with 64 bit preemt-rt kernel.

Installation overview :
Current Linux install : www.linuxcnc.org/testing-stretch-rtpreempt/
Current Linuxcnc-dev version : github linuxcnc
Current Ethercat linuxcnc install : github.com/sittner/linuxcnc-ethercat
Current Ethercat etherlab install : hg clone hg.code.sf.net/p/etherlabmaster/code ethercat-hg

The attached mini.c file work's good. It will be compiled to ec_mini.ko and work's after loading the ethercat master.
Then you see the digital output's flickering on the Beckhoff device after # insmod ec_mini.ko

compiling linuxcnc-ethercat:
This one is not so easy to solve, but it succeed's. In linuxcnc we first load the Lcec_config.
After that we can loadrt lcec.

Error message :
The message in Linuxcnc is : dlopen, could not find ecrt_ .... , insmod failed for lcec driver.

Suspect :
1. I think we need a lcec.ko instead of a lcec.so. So we need a RTAI kernel instead of a preemptable user space kernel.
2. Also i supect that the linuxcnc makefile does not link the module.symvers file into the kernel. Even when i set the correct
adres with $PWD.
3. If i delete some ecrt_ driver's linuxcnc will error the next ecrt_ driver. So this is not the solution.

Possible solution's :
1. Get a compatible RTAI 64 environment with linuxcnc. The problem is highlabhighlab is offline. This one has no comment's in the readme file, so i don't know if it is usable NTULINUX/RTAI for us and for wich linux version it could be used.

2. I have installed latest ubuntu 64 bit and compiled a 64 bit kernel. Rtai 5.0.1with kernel 4.4.43.
Rai 5.0.1 how to
Okey this succeed's but linuxcnc will not work on this 64 bit linux software. Linuxcnc has confict's with a few mathematical things.
Now i could solve this in the source code. I think machinekit has solved this. Maybe Arc-eye know's how much work this is?

3. Write a glue model between the ec_mini.ko (etherlab working slave) and linuxcnc hal. (lcec.so)

4. Try machinekit. But i have much work done in adapting reverse_speed, adaptive_speed and external offset's and the Grotius user gui.

5. Go and get a 32 bit draftsight program.

Anyone has an idea? I can use some help.
I am now about 40 hours later in development. Have learned a lot. But still no succes on 64 bit linuxcnc. Okey if it will work
on 64 bit finally, then that would be great !!

Edit, sinds 5 minutes i got it working on 64 bit. Yes partytime.
Later on i will make and post a nice installation how to document.
I am also concidering to make an integration test in the makefile for linuxcnc_dev.


Attachments:
Last edit: 27 Nov 2018 08:07 by Grotius.

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

More
27 Nov 2018 13:32 - 28 Nov 2018 14:36 #121471 by Grotius
Hi,

For Linuxcnc Ethercat users. I have made a install guide for 64 bit users, so you can use Draftsight 64 bit on same pc.

Install this www.linuxcnc.org/testing-stretch-rtpreem...uspace-amd64-r13.iso

Open terminal in your home directory.

$ sudo apt-get install dist-upgrade (update system after iso install)
$ sudo apt-get install git (for linuxcnc and linuxcnc-ethercat)
$ sudo apt-get install mercurial (for ec-debianize)
$ sudo apt-get install geany (easy text editor)

$ git clone github.com/LinuxCNC/linuxcnc.git
$ git clone github.com/sittner/linuxcnc-ethercat.git
$ git clone github.com/sittner/ec-debianize.git

1. Install linuxcnc
$ linuxcnc/debian/ => ./configure uspace => cd ..
$ linuxcnc/ => dpkg-checkbuilddeps => sudo apt-get install ..... until you are done.
$ cd src/ => ./autogen.sh => ./configure => make -j2 ( j2 = dual processor speed )
$ sudo make setuid

2. Install ec-debianize
$ sudo apt-get install quilt (dependency for ec-debianize)
$ cd ec-debianize => ./get_sourse.sh (works only if mercurial is installed)
$ cd ec-debianize/etherlabmaster/ => dpkg-buildpackage (dpkg-checkbuilddeps optional)
(the output error "failed to sign .dsc file is no issue)
$ cd ec-debianize => sudo dpkg -i etherlabmaster_1.5.2+20180317hg9e65f7-2_amd64.deb
$ cd ec-debianize => sudo dpkg -i etherlabmaster-dev_1.5.2+201803a17hg9e65f7-2_amd64.deb

Open etc/default/ethercat as root : $ sudo thunar
Find your mac adres : $ ip link show (output = link/ether ....)
Type in MASTER0_DEVICE="lo:ve:me:te:nd:er" (your mac adres my dear)
Type in DEVICE_MODULES="generic"
$ sudo update-ethercat-config (reboot, or restart your pc)

3. Install linuxcnc-ethercat
$ cd linuxcnc-ethercat/ => make

4. To start linuxcnc with ethercat, start linuxcnc with simple axis gui.
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.

Good luck. Many many thanks to Sascha. He is founder of Linuxcnc Ethercat. Great to see what he has done in the mean time !!!



To install glade for custom screen development on 64 bit systems :
$ sudo apt-get install glade
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
Now you have also the glade program fully functional for your linuxcnc needs.

Added 28-11-2018 :
1. For the installation of debian iso cd R13, i have 1 little issue's solved.
I mentioned that system is waiting for network connection at boot time up to 1.5 minutes.
Solution ==> Lib/systemd/system/network-service => edit file => line 21 => "1sec"

2. Each time the pc's boot's up the Ethercat rules are only read, that is not good. So permanent solution is :
Solution ==> Etc/udev/rules.d/00-ethercat.rules/ ==> GROUP="your user name"
Attachments:
Last edit: 28 Nov 2018 14:36 by Grotius.
The following user(s) said Thank You: chimeno, arvidb, tommylight, islander261, Nico2017, anfänger, thefabricator03, cheng, cola wonton, sevketsakinc and 1 other people also said thanks.

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

More
28 Nov 2018 20:32 - 28 Nov 2018 21:19 #121546 by Grotius
How to create a new Ethercat driver.

Driver : EL3062


1. Correct your own slave position and name in the xml file : <slave idx="3" type="EL3062" name="D4"/>
Keep the xml file simple. In etherlabmaster/tool/ you can do $ ./ethercat xml -p3
This is create a xml file from slave number 3. This output you can not use. It's as simple as the above single line.

2. Copy a EL c and h file that comes close to your new driver, in my case the EL3255, a 5 channel analog input device.

3. Modify the EL3255.c and EL3255.h to your EL3062.c and EL3062.h needs.
It's almost as simple as the find and replace function for whole document with text editor geany.

4. Modify the lcec.main.c file ==> add your EL3062 to the list.

5. Modify the lcec.config.c & lcec.config.h file ==> add your EL3062 to the list.

6. Add your EL3255 to the Kbuild file ==> This file brings all the drivers to one single lcec.so component.

7. Do a "make clean" in your top directory and do a "make" You must start clean. You see what "make clean" does in the output.

8. Copy your new lcec.so from your src directory to your rtlib.

9. Copy your new config file to your bin directory.

10. Start linuxcnc.

11. Keep in mind. The makefile output is in the same directory as you did make. So lcec.so and config is in this direcory.
Copy them to your rip-environment or to the normal linuxcnc environment, for example usr/bin/ for config file

12. Don't give up after first attempt.



Okey after 3 attemp's it succeeded for me. The bottelneck for me was in the lcec.main file.
// analog in, 2ch, 12 bits
{ lcecSlaveTypeEL3062, LCEC_EL31x2_VID, LCEC_EL3062_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},
// analog in, 2ch, 16 bits
{ lcecSlaveTypeEL3102, LCEC_EL31x2_VID, LCEC_EL3102_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},

I suspected to change the LCEC_EL31x2 line would be LCEC3062, but that was not the case.

Good luck with making your own drivers.

Sascha is very clever. I would like to call him some day and make a little interview with him. If he agree's i can make a short life story
of him on one page, what he does and how he became the founder of linuxcnc ethercat.
If i look at his code, it almost must be his job. I think even he can write linuxcnc on his own.
Attachments:
Last edit: 28 Nov 2018 21:19 by Grotius.
The following user(s) said Thank You: chimeno, arvidb, islander261, Nico2017, CORBETT, JimPanski, cheng, Stormholt

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

More
17 Dec 2018 21:05 - 17 Dec 2018 21:30 #122536 by Nico2017
Hi,
first of all thank you so much for summarizing the different step in such a post, it is super handy as I have been trying to install a working linuxcnc with ethercat navigating through a lot of different thread. I have an installation running but it is not on the latest debian and as I also received new hardware equipment I wanted to give it a go to have a last up to date system.

I however still face some issues. I tried your installation process slightly differently. First I installed the latest debian stretch from an official iso, then install the latest RT kernel. In the end doing uname -a gives me:
Linux username 4.9.0-8-rt-amd64 #1 SMP PREEMPT RT Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
Then following your steps:
  1. install linuxcnc with debian packages to have it working from anywhere, and not RIP only as I believe you are suggesting it
  2. install ethercat with ec-debianize. Everything runs as indicated, and when I do ethercat slaves in the end I can see all my connected ethercat modules properly.
  3. install linuxcnc-ethercat, run well first time but then had to do some make clean and sudo make install afterwards as I was facing the issue described below. Moreover to me I think there is no need to do copy lcec_conf ==> ../linuxcnc-ethercat/src/lcec_conf ==> to your linuxcnc sim map (copy it where your ini files is) as lcec_conf command works anywhere if you do a global installation (sudo make install). I nevertheless copied as indicated: copy lcec_so ==> ../linuxcnc-ethercat/src/lcec.so ==> to your home/.../linuxcnc/rtlib/ (this is only for linuxcnc_dev users even if I was not sure it was relevant to my case

In the end I am facing an ethercat related issue while trying your simple axis gui tutorial. Just doing loadusr -W lcec_conf ethercat-conf.xml in the postgui is fine, as I can see the lcec with halshow, but when I uncomment the other lines I got:
LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/plotterview/linuxcnc/configs/sim.axis'
Machine configuration file is 'axis.ini'
Starting LinuxCNC...
Found file(lib): /usr/share/linuxcnc/hallib/core_sim.hal
Note: Using POSIX realtime
Found file(lib): /usr/share/linuxcnc/hallib/sim_spindle_encoder.hal
Found file(lib): /usr/share/linuxcnc/hallib/axis_manualtoolchange.hal
Found file(lib): /usr/share/linuxcnc/hallib/simulated_home.hal
Found file(lib): /usr/share/linuxcnc/hallib/check_xyz_constraints.hal
note: MAXV max: 5.000 units/sec 300.000 units/min
note: LJOG max: 5.000 units/sec 300.000 units/min
note: LJOG default: 0.250 units/sec 15.000 units/min
note: jog_order='XYZ'
note: jog_invert=set([])

lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: rtapi_mutex_get
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: rtapi_mutex_get

test_postgui.hal:2: waitpid failed /usr/bin/rtapi_app lcec
test_postgui.hal:2: /usr/bin/rtapi_app exited without becoming ready
test_postgui.hal:2: insmod for lcec failed, returned -1

Shutting down and cleaning up LinuxCNC...
task: 1063 cycles, min=0.000020, max=0.004440, avg=0.001056, 0 latency excursions (> 10x expected cycle time of 0.001000s)
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/plotterview/linuxcnc_debug.txt
and
/home/plotterview/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

I believe this could be related to some posts, for which you already provided some helpfull replies:
github.com/sittner/linuxcnc-ethercat/issues/57
forum.linuxcnc.org/24-hal-components/223...er?limit=6&start=642

In this case it is not the ethercat permission issue, as I also followed your instruction to make it permanent.
I tried ldd lcec.so:
ldd lcec.so
linux-vdso.so.1 (0x00007ffc9e3be000)
liblinuxcnchal.so.0 => /usr/lib/liblinuxcnchal.so.0 (0x00007f62974df000)
libethercat.so.1 => /usr/lib/x86_64-linux-gnu/libethercat.so.1 (0x00007f62972d6000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6296fd2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6296c33000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6296a2b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f629680e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6297903000)
This only works when I am in linuxcnc-ethercat/src otherwise I got a command not found.

Any idea about how I could solve issue.

Thanks again,

Nicolas
Last edit: 17 Dec 2018 21:30 by Nico2017. Reason: More precise informatiom
The following user(s) said Thank You: Grotius

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

More
21 Dec 2018 08:02 #122678 by shameless
Hi, I have installed Linuxcnc .
I want to know that if ec_debianize is the source code of etherlab-master?
and what the relationship between linuxcnc-ethercat and etherlab-master?
The following user(s) said Thank You: Grotius

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

More
21 Dec 2018 13:47 #122695 by shameless
I can not install the linuxcnc-ethercat,
when I 'make', print "halcompile/comp ececutable not found or set"
Could you tell me why?

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

More
21 Dec 2018 22:18 #122734 by Grotius
@Nicolas,

Thanks for your compliment's. For me it's a kind of public timeline comment tutorial, very handy to look back some time's,
and trough the public publication everyone has profit of this !!

It could be your kernel version. Some newer kernels are incompatible with linuxcnc because of different mathematic symbols or something like that. Machinekit has solved this problem so far i know. But i am not sure.
There is a new 64 bit linuxcnc kernel available on github, but there is no nice install guide.

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

More
21 Dec 2018 22:40 #122736 by Grotius
@Shameless,

I want to know that if ec_debianize is the source code of etherlab-master?
No it's not the source code of etherlab-master.
A simple explenation could be :
Ec_debianize is a tool that configures the etherlab-master for debian 64 bit system's.

In other word's ec_debianize is a tool that configures ethercat for preempt rt kernels. The clue is .so component instead of .ko component.

and what the relationship between linuxcnc-ethercat and etherlab-master?
Etherlab master is the main interface for the ethercat protocol. It runs outside of linuxcnc.
To talk with etherlab master, linuxcnc has to have a glue component. This is linuxcnc-ethercat.
It's complicated. In theory etherlab-master could be integrated into linuxcnc-ethercat.

I can not install the linuxcnc-ethercat,
when I 'make', print "halcompile/comp ececutable not found or set"
Could you tell me why?


It looks like linuxcnc is not installed as run in place, did you installed the linuxcnc-dev version with all dependencies?

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

More
26 Dec 2018 02:20 - 26 Dec 2018 02:27 #122895 by shameless
I want to say thank you, and I should add the path to my profile,thanks.
Last edit: 26 Dec 2018 02:27 by shameless.
The following user(s) said Thank You: Grotius

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

More
07 Jan 2019 06:54 #123674 by shameless
@Grotius Hi, I recently haven't solved the problem that there are some problem shows when lcec.so is loaded, after I start the linuxcnc.
Could you tell me that, how ethercat works with linuxcnc?
I mean if when we start linuxcnc, and the lcec.so is inserted normally, will ethercat start automatically? or I should start ethercat manually first, and then start linuxcnc later.
Kind regards
The following user(s) said Thank You: cheng

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

Time to create page: 0.311 seconds
Powered by Kunena Forum