Configuring LinuxCNC with ethercat

More
27 Nov 2022 22:18 - 27 Nov 2022 22:21 #257778 by mwc
My EtherCAT steppers got delivered today, and I have one connected and showing up in the slaves list, as per Rodw's stickied guide.

However, I'm struggling to find much information on how the whole linuxCNC thing gets setup.
I understand what the HAL is and how it's used, but I'm not really understanding how you setup a suitable profile, or where the EtherCAT XML should actually go. I'm also aware there are other XML files for EtherCAT devices.

Can I simply modify the sim profile installation, or should I create a new profile from a new (blank) dir?

I'm aware as part of Rodw's guide, it uses the sample xml by using a halcmd, however does this permanently link the xml to the HAL file?
Or should I be adding some text to the HAL to link to the XML?
How do I reload the XML if I make edits?

Do all the sample XMLs need to get copied+pasted or linked to a single XML?
Is there a combined list of available EtherCAT XMLs?

I do apologise for all the newbie questions, but I'm just struggling to understand how I actually configure LinuxCNC, as I can't see anything in the documents or wiki that provides any kind of overview of how everything interacts. I can find plenty on specific parts of LinuxCNC, but nothing on a general overview of how all those parts work together and should be configured :/

Edit - I do understand the EtherCAT stuff is relatively new to LinuxCNC so things will change, but I just seem to be stuck not sure how to even start configuring LinuxCNC
Last edit: 27 Nov 2022 22:21 by mwc.

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

More
27 Nov 2022 22:25 #257782 by rodw
You need to add the read and write calls to your hal file.
Dominic has an example which also includes a component for cia402 compliant drives (most are)
github.com/dbraun1981/hal-cia402

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

More
28 Nov 2022 18:15 - 28 Nov 2022 18:17 #257877 by mwc
I have created a new machine profile using dbraun's sample HAL, but I can't get LinuxCNC to load with the EtherCAT module.

This is the terminal output -

Starting LinuxCNC...
linuxcnc TPMOD=tpmod HOMEMOD=homemod EMCMOT=motmod
Note: Using POSIX realtime
Found file(REL): ./my_EtherCAT.hal
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: cannot open shared object file: No such file or directory
./my_EtherCAT.hal:15: waitpid failed /usr/bin/rtapi_app lcec
./my_EtherCAT.hal:15: /usr/bin/rtapi_app exited without becoming ready
./my_EtherCAT.hal:15: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Running HAL shutdown script

Line 15 is loadrt lcec

If I manually load the xml via the terminal (halcmd loadusr - W lcec_conf ethercat-conf.xml ), LCNC fails to load because the lcec_conf is duplicate -

Starting LinuxCNC...
linuxcnc TPMOD=tpmod HOMEMOD=homemod EMCMOT=motmod
Note: Using POSIX realtime
Found file(REL): ./my_EtherCAT.hal
HAL: ERROR: duplicate component name 'lcec_conf'
lcec_conf: ERROR: hal_init failed
./my_EtherCAT.hal:14: waitpid failed lcec_conf lcec_conf
./my_EtherCAT.hal:14: lcec_conf exited without becoming ready
Shutting down and cleaning up LinuxCNC...
Running HAL shutdown script


I've also tried deleting the loadrt lcec line, and as I'd expect the HAL loads until it gets to the next line (24) that calls lcec.

If I manually load lcec, and run halcmd show pin lcec, it reports 1 master and 4 slaves as per the installation instructions (that's using Rod's sample xml, but dbrauns reports 1 and 1 as I'd expect)
Last edit: 28 Nov 2022 18:17 by mwc.

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

More
28 Nov 2022 21:36 - 28 Nov 2022 22:50 #257897 by mwc
Just realised lcec.so doesn't exist, so I just ran over the relevant section of the installation guide, and I have an error when building the linux-ethercat library -
make[1]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
mkdir -p /usr/lib/linuxcnc/modules
make[2]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
gcc -o lcec_conf.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf.c
gcc -o lcec_conf_util.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf_util.c
gcc -o lcec_conf_icmds.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf_icmds.c
gcc -o lcec_conf lcec_conf.o lcec_conf_util.o lcec_conf_icmds.o  -Wl,-rpath,/lib -L/lib -llinuxcnchal -lexpat
[i]mkdir -p /usr/bin
cp lcec_conf /usr/bin/
make[2]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make[2]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
realtime.mk:33: *** missing separator.  Stop.
make[2]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make[1]: *** [Makefile:12: install] Error 2
make[1]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make: *** [Makefile:11: install] Error 2

Line 33 is-
$(CC) -shared -o $@ $(lcec-objs) -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal -lethercat -lrt

I just done a straight copy and paste from the code in the installation guide, and I don't know enough about this to figure out where the missing separator should be.
Last edit: 28 Nov 2022 22:50 by mwc.

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

More
28 Nov 2022 22:34 #257904 by rodw
m the installation guide, did you edit/replace realtime.mk? Thats probably your error

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

More
28 Nov 2022 22:48 #257909 by mwc
So i tried using the default realtime.mk file, and everything compiled as expected with no errors -
ake[1]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
mkdir -p /usr/lib/linuxcnc/modules
make[2]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
gcc -o lcec_conf.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf.c
gcc -o lcec_conf_util.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf_util.c
gcc -o lcec_conf_icmds.o -Os -g -I. -I/build/linuxcnc-36cfOd/linuxcnc-2.9.0~pre0+git20221105.ffb6bda926/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os -c lcec_conf_icmds.c
gcc -o lcec_conf lcec_conf.o lcec_conf_util.o lcec_conf_icmds.o  -Wl,-rpath,/lib -L/lib -llinuxcnchal -lexpat
mkdir -p /usr/bin
cp lcec_conf /usr/bin/
make[2]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make[2]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/src'
Compiling realtime lcec_main.c
Compiling realtime lcec_class_enc.c
Compiling realtime lcec_class_ax5.c
Compiling realtime lcec_generic.c
Compiling realtime lcec_ax5100.c
Compiling realtime lcec_ax5200.c
Compiling realtime lcec_el1xxx.c
Compiling realtime lcec_el1252.c
Compiling realtime lcec_el1859.c
Compiling realtime lcec_el2521.c
Compiling realtime lcec_el2xxx.c
Compiling realtime lcec_el2202.c
Compiling realtime lcec_el31x2.c
Compiling realtime lcec_el31x4.c
Compiling realtime lcec_el3255.c
Compiling realtime lcec_el40x1.c
Compiling realtime lcec_el40x2.c
Compiling realtime lcec_el40x8.c
Compiling realtime lcec_el41x2.c
Compiling realtime lcec_el41x4.c
Compiling realtime lcec_el5101.c
Compiling realtime lcec_el5151.c
Compiling realtime lcec_el5152.c
Compiling realtime lcec_el6900.c
Compiling realtime lcec_el1918_logic.c
Compiling realtime lcec_el1904.c
Compiling realtime lcec_el2904.c
Compiling realtime lcec_ax5805.c
Compiling realtime lcec_el7041_1000.c
Compiling realtime lcec_el70x1.c
Compiling realtime lcec_el7211.c
Compiling realtime lcec_el7342.c
Compiling realtime lcec_el7411.c
Compiling realtime lcec_el95xx.c
Compiling realtime lcec_em7004.c
Compiling realtime lcec_stmds5k.c
Compiling realtime lcec_deasda.c
Compiling realtime lcec_dems300.c
Compiling realtime lcec_omrg5.c
Compiling realtime lcec_ph3lm2rm.c
Linking lcec.so
cp lcec.so /usr/lib/linuxcnc/modules/
make[2]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make[1]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/src'
make[1]: Entering directory '/home/lcnc/dev/linuxcnc-ethercat/examples'
mkdir -p /usr/share/linuxcnc-ethercat/examples
cp -R generic-complex swm-fm45a /usr/share/linuxcnc-ethercat/examples
make[1]: Leaving directory '/home/lcnc/dev/linuxcnc-ethercat/examples'

However I get the undefined symbol: ecrt_slave_config_sdo error when trying to load linuxcnc, which the modified realtime.mk is supposed to fix.

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

More
28 Nov 2022 22:51 #257910 by mwc
Crossposted there.
Yes, that's with the 'fixed' realtime.mk

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

More
28 Nov 2022 23:04 #257914 by db1981
is this now orginal realtime.mk from github ? Why did you do changes in realtime.mk ?

linuxcnc: Rip Version or full install ? is linuxcnc-uspace-dev package installed?

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

More
28 Nov 2022 23:39 - 28 Nov 2022 23:43 #257917 by mwc
The original realtime.mk (the one that gets pulled down from sittner's github) is the one that make's with no errors, but when I try loading LinuxCNC it generates the undefined symbol: ecrt_slave_config_sdo error

Using the modified realtime.mk as per the rod's pinned installation instructions (which is supposed to fix the ecrt slave issue), it fails to make.

LinuxCNC was a full install via the terminal, following Gnipsel's insturctions for Bookworm - www.gnipsel.com/linuxcnc/debian-12-emc.html and includes linuxcnc-uspace-dev
Last edit: 28 Nov 2022 23:43 by mwc.

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

More
28 Nov 2022 23:47 #257919 by rodw
Very interesting. the changes to realtime.mk came from this thread,
forum.linuxcnc.org/9-installing-linuxcnc...ve-config-sdo#203252
I could not install the driver until I made this modification.

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

Time to create page: 0.099 seconds
Powered by Kunena Forum