Ethercat HAL driver

More
06 Feb 2014 07:27 #43594 by lpons
Replied by lpons on topic Ethercat HAL driver

Hi Everybody,

I have some problem getting LinuxCNC + EtherCAT HAL driver properly compiled. I want also add that I'm almost new to the Linux world so the reason it won't compile is probably caused by a my mistake or something I'm not really into. So be prepared for the tons of silly questions I'll post here.

Back to my error. First of all the EtherCAT master is working: I can load the kernel module, unload it and also use the ethercat utility attached to the device file. But when I try to compile LinuxCNC I get an error such as:

In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "New version of jemalloc required"
make[2]: ***[adlist.o] Error 1
make[2]: Leaving directory `/home/jkirkley/gitlocal/ncs/linuxcnc/ethercatBranch/src/redis/redis/src`

I think the problem is or in the makefile the path of jemalloc is not properly set or the version is out of date. But honestly I don't know how to fix it. I try to recompile the jemalloc library but there's no a makefile which works.

If you need more information I'll happy to give what you need.


Thank you so much

LP


I solved the above problem. I was missing some REDIS file (I don't really know why since I'm working on a previous working LinuxCNC machine, but still...). Now I can compile all the LinuxCNC package and finish the install process running also the "sudo make setuid" command after the "make".

But I have another problem. I want to load the EtherCAT HAL driver module but I get the following error:

jkirkley@linuxCNC:~/gitlocal/ncs/linuxCNC/ethercatBranch$ sudo ./scripts/halrun -I -f ../demo/ledDemo.hal
insmod: error inserting '/home/jkirkley/gitlocal/ncs/linuxCNC/ethercatBranch/rtlib/lcec.ko': -1 Unknown symbol in module
../demo/ledDemo.hal:5: exit value: 1
../demo/ledDemo.hal:5: insmod failed, returned -1
See the output of 'dmesg' for more information.

and when I go to see the dmesg buffer I get:

[84661.062574] I-pipe: Domain RTAI registered.
[84661.062580] RTAI[hal]: <3.8.1> mounted over IPIPE-NOTHREADS 2.6-03.
[84661.062583] RTAI[hal]: compiled with gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) .
[84661.062615] RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs DISPATCHED), ISOL_CPUS_MASK: 0).
[84661.062617] PIPELINE layers:
[84661.062620] fd098e20 9ac15d93 RTAI 200
[84661.062623] c085cb20 0 Linux 100
[84661.082274] RTAI[malloc]: global heap size = 2097152 bytes, <BSD>.
[84661.082489] RTAI[sched]: IMMEDIATE, MP, USER/KERNEL SPACE: <with RTAI OWN KTASKs>, kstacks pool size = 524288 bytes.
[84661.082495] RTAI[sched]: hard timer type/freq = APIC/12468620(Hz); default timing: periodic; linear timed lists.
[84661.082499] RTAI[sched]: Linux timer freq = 250 (Hz), TimeBase freq = 1994960000 hz.
[84661.082501] RTAI[sched]: timer setup = 999 ns, resched latency = 2944 ns.
[84661.082570] RTAI[usi]: enabled.
[84661.120848] RTAI[math]: loaded.
[84661.162673] lcec: Unknown symbol ecrt_sdo_request_timeout
[84661.162769] lcec: Unknown symbol ecrt_request_master
[84661.162935] lcec: Unknown symbol ecrt_release_master
[84661.163029] lcec: Unknown symbol ecrt_master_activate
[84661.163203] lcec: Unknown symbol ecrt_sdo_request_read
[84661.163513] lcec: Unknown symbol ecrt_domain_size
[84661.163607] lcec: Unknown symbol ecrt_master_deactivate
[84661.163705] lcec: Unknown symbol ecrt_slave_config_create_sdo_request
[84661.164017] lcec: Unknown symbol ecrt_master_sync_reference_clock
[84661.164111] lcec: Unknown symbol ecrt_slave_config_pdos
[84661.164206] lcec: Unknown symbol ecrt_domain_data
[84661.164300] lcec: Unknown symbol ecrt_sdo_request_data
[84661.164394] lcec: Unknown symbol ecrt_slave_config_dc
[84661.164488] lcec: Unknown symbol ecrt_master_slave_config
[84661.164685] lcec: Unknown symbol ecrt_slave_config_state
[84661.164779] lcec: Unknown symbol ecrt_master_state
[84661.164950] lcec: Unknown symbol ecrt_master_callbacks
[84661.165044] lcec: Unknown symbol ecrt_domain_process
[84661.165211] lcec: Unknown symbol ecrt_master_application_time
[84661.165304] lcec: Unknown symbol ecrt_domain_reg_pdo_entry_list
[84661.165399] lcec: Unknown symbol ecrt_slave_config_watchdog
[84661.165638] lcec: Unknown symbol ecrt_slave_config_complete_sdo
[84661.165732] lcec: Unknown symbol ecrt_master_sync_slave_clocks
[84661.166015] lcec: Unknown symbol ecrt_domain_queue
[84661.166111] lcec: Unknown symbol ecrt_sdo_request_state
[84661.166205] lcec: Unknown symbol ecrt_master_send
[84661.166375] lcec: Unknown symbol ecrt_slave_config_sdo
[84661.166473] lcec: Unknown symbol ecrt_master_create_domain
[84661.166724] lcec: Unknown symbol ecrt_master_receive
[84725.526583] RTAI[math]: unloaded.
[84725.555601] SCHED releases registered named ALIEN RTGLBH
[84725.584293] RTAI[malloc]: unloaded.
[84725.684062] RTAI[sched]: unloaded (forced hard/soft/hard transitions: traps 0, syscalls 0).
[84725.686567] I-pipe: Domain RTAI unregistered.
[84725.686603] RTAI[hal]: unmounted.

It looks like some header file is missing or something similar. Again I'm not an expert so I can't say exactly. Some has an idea of the origin of the problem?

Thank you so much

LP


Again, problem solved! I don't know why but I was giving for granted that the EtherCAT master starts when I load the EtherCAT HAL driver, but it wasn't. Once I started the EtherCAT master manually the HAL driver loads properly!!

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

More
11 Mar 2014 09:29 #44649 by narogon
Replied by narogon on topic Ethercat HAL driver
Hi everyone,

I've just started to try to connect 4 omron servo drives (accurax g5 R88D-KN-ECT) via ethercat.

For now I've installed the etherlab master and I've obtained response when I make ethercat slave...

The PDO mapping of the servos is fixed for now. And I see it when I execute ethercat pdo

Even I could reset the fault state sending bit 7 = 1 for 0x6041 (statusword)
ethercat download 0x6041 0x0 128
getting the "switch on disabled" state.

However i've not been able to change the state to "ready to switch on" sending for example ethercat download 0x6041 0x0 6

May I continue with the driver integration to LinuxCNC? I'm not very sure how could i do that even though I've read some manuals about it.

Regards

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

More
12 Mar 2014 04:41 #44703 by roschi
Replied by roschi on topic Ethercat HAL driver

However i've not been able to change the state to "ready to switch on" sending for example ethercat download 0x6041 0x0 6

May I continue with the driver integration to LinuxCNC? I'm not very sure how could i do that even though I've read some manuals about it.

Regards


Hi,

Have you changed/checked the Bus State? INIT, PREOP, SAFE OP, OP mode? I did not know excatly about Omron drives but I guess that the bus state should be OP Mode before you change/send commands for enabling the drive or somthing like that.

- Think also about the point that perhaps a cyclic operation or some parameters should be changed/set during a change in the bus state
- I advise to check this with the Software 'EtherCAT-Configurator' from Beckhoff on Windows machine (you need the device config XML-File)
- If all works like you except within the EtherCAT-Configurator, go a head with the tool 'ethercat' on commandline and try to get the bus state to op mode or use the generic driver config with the EtherCAT HAL driver and a simple setup within commandline tool 'halcmd'

Perhaps the link to the little tutorial some posts before (from me) could give some more hints

Regards Andreas
The following user(s) said Thank You: narogon

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

More
28 Mar 2014 03:18 #45322 by narogon
Replied by narogon on topic Ethercat HAL driver
Hi roschi,

I have done all what you said to me.

At the moment I have been able to control the motors using TwinCAT.

Via commandline I couldn't get the drives to OP mode because when I do "ethercat state OP" it produces a Communications Setting Error. I've not setting any parameter (I don't know how to change ethercat commandline tool configuration) so I suppose they aren't correct for my drives.

Moreover I have create a xml file following your example. You could see the original xml file and what I've created here . Is it correct?

I tried to start the realtime program but I obtained the same error as Ipons

root@Nacho-linux:/home/linuxhal# . scripts/rip-environment
root@Nacho-linux:/home/linuxhal# halrun
halcmd: loadusr -W lcec_conf ethercat_config_n.xml
halcmd: loadrt lcec
insmod: error inserting '/home/nacho/Descargas/linuxcnc-add-hal-ethercat/rtlib/lcec.ko': -1 Unknown symbol in module
<stdin>:2: exit value: 1
<stdin>:2: insmod failed, returned -1
See the output of 'dmesg' for more information.

nacho@Nacho-linux:~$ dmesg | grep -i lcec
[ 5950.334047] lcec: Unknown symbol lcec_el5101_init

I think I have the ethercat master started due to I can see the slaves when I make "ethercat slaves"

Could you help me?

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

More
28 Mar 2014 20:30 - 28 Mar 2014 20:53 #45337 by roschi
Replied by roschi on topic Ethercat HAL driver
Hello,

Via commandline I couldn't get the drives to OP mode because when I do "ethercat state OP" it produces a Communications Setting Error.

This is a normal/expected reaction of the drive. Because some parameters have to be configured druing change the states of the bus. I guess that you have to set the operation mode to value 8. --> ethercat download -t uint8 -p0 0x6060 0 8 (see the normed drive profile scheme CIA 402 and also the original XML at the end, also the 'startup' tab in TwinCAT)

EDIT:
ethercat download 0x6041 0x0 6 --> This does not work (see post #44649) because the drivecontrol word has address 0x6040!
Perhaps there is no need to put the bus state to OP for simple non cyclic testing (see Video for ESTUN drive)

EDIT

nacho@Nacho-linux:~$ dmesg | grep -i lcec
[ 5950.334047] lcec: Unknown symbol lcec_el5101_init

Which source have you used? From github.com/sittner or from github.com/aschiffler. Right now I can not get on the problem. Just some ideas: Is the file lcec_el5101.c compiled during build. Perhaps there went somthing wrong with the makefile or the linker commands.

Moreover I have create a xml file following your example. You could see the original xml file and what I've created here. Is it correct?

yes. But in the next step you have to think about the scaling/type conversion for example for
...
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="poscommand" halType="S32"/>
...
you need this if you want to connect the HAL pins to the motion controler which sends e.g. pos cmd in 'mm'
see Post #40199 from me in this thread.

I hope I can help a little bit.

Regards Andreas
Last edit: 28 Mar 2014 20:53 by roschi.
The following user(s) said Thank You: narogon

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

More
02 Apr 2014 13:19 #45496 by Belerafon
Replied by Belerafon on topic Ethercat HAL driver
Hi. I have compiled ethercat-1.5.2 and linuxcnc with EtherCAT driver. What do next? I'm a newbie in linuxcnc. On wiki wiki.linuxcnc.org/cgi-bin/wiki.pl?EtherCatDriver "Configuration" part is empty. Can anybody wrote some basic steps what need to do next? What manual, readme or config files I need?

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

More
03 Apr 2014 20:22 #45537 by narogon
Replied by narogon on topic Ethercat HAL driver
Roschi wrote a tutorial for IndraDrives. LINK

Maybe you can start on reading it ;)
The following user(s) said Thank You: Belerafon, Nico2017

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

More
05 Apr 2014 01:27 - 05 Apr 2014 01:54 #45566 by narogon
Replied by narogon on topic Ethercat HAL driver
First of all thank you for your replies. You are helping me a lot.

Hello,
This is a normal/expected reaction of the drive. Because some parameters have to be configured druing change the states of the bus. I guess that you have to set the operation mode to value 8. --> ethercat download -t uint8 -p0 0x6060 0 8 (see the normed drive profile scheme CIA 402 and also the original XML at the end, also the 'startup' tab in TwinCAT)


It seems I can only change the state to OP in real time. I check that with TwinCAT and it gives an error if I try to change to OP in config mode.
Also in the manual they say that the operation mode (0x6060) must be changed in OP.

EDIT:
ethercat download 0x6041 0x0 6 --> This does not work (see post #44649) because the drivecontrol word has address 0x6040!
Perhaps there is no need to put the bus state to OP for simple non cyclic testing (see Video for ESTUN drive)

EDIT

It was my mistake typing here, I mean 0x6040!!. For this drive I think it is needed to put the bus state to OP like I said before.

Which source have you used? From github.com/sittner or from github.com/aschiffler. Right now I can not get on the problem. Just some ideas: Is the file lcec_el5101.c compiled during build. Perhaps there went somthing wrong with the makefile or the linker commands.

I use github.com/sittner. There is a mistake in the makefile, they forgot to include "hal/drivers/ethercat/lcec_el5101.o \". Now I can load lcec without problem.


Now I'm stuck with the real time functions. I see that it recognizes the slave (lcec.0.slaves-responding = 1 or lcec.0.state-op = true for example) but it doesn't update the pins (drivestatus lcec.0.0.drivestatus-0..., pos: lcec.0.0.pos)

What functions must be attached to the servo-thread?

How could I test the drive?

Could you explain me something about all of it?

Thanks again!
Last edit: 05 Apr 2014 01:54 by narogon.

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

More
05 Apr 2014 16:04 #45581 by roschi
Replied by roschi on topic Ethercat HAL driver
Hello narogon,

first of all I think you are not far away from success!

In the "original" OMRON XML File for TwinCAT there is a entry for the "Startup". That means this are the commands which are send/configured when you want to activate the state transition preop -> op. You see this in TwinCAT GUI under the Tab "startup"
For LinuxCNC and EtherCAT HAL setup this means to add this commands on the XML File.
....
<sdoConfig idx="6060" subIdx="0">
      <sdoDataRaw data="08"/>
</sdoConfig>
...
All data under the "sdoConfig" is send/configured during the state transition preop --> op via Mailbox protocol CoE (this will function for all drives which use the normed drive profil CIA 402 see here )

The state machine will change automaticlly from preop--> op if the HAL componente lcec is loaded and the slaves will acknodledge the state change (see LED/Display indicators of the drive). There is no button/value at HAL driver/pins to manually change the state.
---The next lines are just for details
Within the source of lcec.c component (as in every HAL component) there is the init function (called once) and during this function call the sdo, pdo, dc, watchdog is configured. At the end of the lcec init function the master is started ( ecrt_master_activate(master->master) see EtherLab doc fore more details ).

Additionally you have to add the functions
addf lcec.read-all servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf lcec.write-all servo-thread
....(some other needed)
in the HAL configuration. (Base Period is not needed set it to zero)

Alternativlly you can configure the operation mode (0x6060) within the cyclic data (=pdo)
...
<pdoEntry idx="6060" subIdx="00" bitLen="8" halPin="opmode" halType="bit"/>
...
this enables you to change the operation mode during the machine is running. If the drive uses the CIA 402 this could be nessesary to change the op-mode to "homing".
(I have prorammed some PLC code in the classic ladder to switch to homing mode in the case homing sequence is requested--> axis.N.homing = 1)

If you want to configure other values during startup for the drive
-EXAMPLE-
    <sdoConfig idx="6099" subIdx="1">
      <sdoDataRaw data="E8 03 00 00"/>
    </sdoConfig>
    <sdoConfig idx="6099" subIdx="2">
      <sdoDataRaw data="64 A2 00 00"/>
    </sdoConfig>
Be prepared that for the example above 0x6099 subIdx 1 = 0x3E8 and 0x6099 subIdx 2 = 0xA264. You have to write the data from right to left byte-wise (!) and include all zeros correponding to the bit length of the register (0x6099 --> 32 bit, 0x6060 --> 8 bit)

I check that with TwinCAT and it gives an error if I try to change to OP in config mode.

Have you activated the "cylic-mode" in TwinCAT configurator? This is the button with the circle arrow.

Hope that will help. Please give some little report on success.
Up to now we (= community) know that: IndraDrive from Bosch Rexroth, ProNet-E drive from ESTUN and drives from Stoeber will function at LinuxCNC with EtherCAT.

Best Regards Andreas
The following user(s) said Thank You: Nico2017

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

More
06 Apr 2014 00:19 #45589 by Coyote
Replied by Coyote on topic Ethercat HAL driver


Additionally you have to add the functions
addf lcec.read-all servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf lcec.write-all servo-thread
....(some other needed)


Hi Andreas,

As you're the best expert of ethercat on linuxcnc I am not the one who can give better solution than you, so take it as suggestion or idea for everything I will write, that it could be also wrong:

What is begging me is the fact that you read inputs first, you process and then you output the new states. In some literature this is so called IPO cycle (input/process/output). From what I understood a single frame of ethercat consists of output that is sent from master and slave encodes the into the same frame on the fly its inputs.
If we look breifly:
1. at time t(n) master sends output that will be activated with delay at time t(n+1)
2. at time t(n) slave encodes a frame that has an information of inputs, latched at time t(n-1)
(This is only my understanding, not the fact)

From my point of view at time t(n) you should perform:
1. output actions that will execute at time t(n+1)
2. read latched inputs taken at time t(n-1)
3. compute outputs

No matter of jitter all drives will be scnchronized, the lag is always present and it is deterministic 2 cycles between input and output.

I gave a look in lcec.c, but I was not able to find such mechanism (I'm not a c++ expert), I would expect that write command sends outputs and receives data from slaves at the same time. I also looked at IgH manual, but I couldn't find anything to proove my hypotesis.

www.iebmedia.com/index.php?id=5794&paren...sdbdisi17g3lao0j06n7

www.vaeprosys.cz/dokumentace/ac500/Engli.../EtherCAT-Basics.htm

Regards, Marko.

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

Time to create page: 0.162 seconds
Powered by Kunena Forum