EtherCAT + RPi build log along with questions

More
23 Sep 2021 03:01 #221397 by pseudo
Hello all.
I'm building a product around LCNC and ethercat (still in prototype phase, long way to go yet) and thanks to a lot of the detailed posts of others I've made some excellent progress which I felt I should share so others can skip some of the fumbling in the dark that I did. Plus I have a few questions but I'll get to them in a sec.

Firstly, the hardware:
  • Raspberry Pi 4, set up folling Hakan's excellent guide, worked flawlessly. Link to that thread Thanks Hakan, your youtube vid popped up in my recommendations just as I was struggling to figure out my options for an ethercat master for the product and saved the day. 
  • The pi is running off an M.2 drive instead of an SD card, vital for long term use, and it's in an 'Argon ONE M.2' Case I wouldn't normally consider the case worth mentioning but I can't recommend this enough, sleek little aluminium case with all the boards etc needed to run an m.2 drive and break all the ports out in a useful way. Cheap too.
  • Leadshine ELP-EC400Z drives and ELM0400FM60H-HH2 MS20 motors, which are 220v AC servos and drives, 400w. So far the leadshine ELP-EC drives seem pretty good, everything appears to be exceptionally high quality for the money, these definitely appear to be a sweet spot for cost/quality. (side note, for those who struggled to find a price for these I paid (USD) $85 for the motor, $145 for same with brake, and $224 per drive, I purchased directly from leadshine.)
    • One important tip for others working with these drives: Leadshine's motion studio did not want to run under windows 10, it took a bunch of sleuthing with windows event viewer to figure out that it wants a C++ redistributable from 2008 and it needs to be run as administrator. I've attached a screenshot of the redistributable version properties, it's pretty hard to find as microsoft doesn't officially want you to download one that old but some google fu found me a viable official MS download link eventually. I'd link that here but it was a while ago. If anyone's desperate PM me and I'll share the file... if you trust exe's from strangers on the internet :)
Work related to LCNC/EtherCat so far:
  • Followed Hakan's guide, got a pi running ethercat in a few hours.
  • Set up the cia402 element. I didn't understand what this bit was for at first until i figured out that CIA402 is an industrial standard for addressing drives, basically a standard set of instructions/responses relating to position/vel/torque etc.
  • If you're not using the same drives as Hakan or similar you won't be able to address your device in the xml like they do <slave idx="0" type="EK1100"/> you'll need to create one with 'type=generic', see my xml for example
  • Fumbled about for a while trying to get the drives to move. Some troubleshooting tips for those in a similar position:
    • Run linuxcnc from terminal with the verbose flag in the directory of your config, 'linuxcnc -v configname.ini' This probably sounds really obvious to a lot of you but I'd mostly just launched from the desktop shortcuts sim/pncconf created in the past and yeah, from the terminal gives you a lot more info
    • 'ethercat slaves -v' provided most of the info I needed to modify the example xmls to suit my drives (attached mine for ref too)
    • 'ethercat xml' also provided some useful info for modifying xml examples.
    • Ethercat: dmesg is your friend... I was banging my head against the wall trying to understand what the problems were until I figured out that the ethercat stack (... not sure which bit, LCEC, etherlab, etc) is sending info there. Open a separate terminal and run 'dmesg -wH' (those flags basically give you the tail and update it in real time), Now you can see what the ethercat stack has been quietly crying about in the background all this time....
  • ...dmesg revealed the crucial nugget of info I'd struggled to find for a while: PDO length mismatch. I was modifying Hakan's example config etc and on his drive one of the PDOs was 32bit length where my drive was sending them as 16bit.
    • Side note on PDOs: you may need to configure your drives to send them/which ones to send using the manufacturer's software before any of this will work. If you're using the same drives then open leadshine motion studio with the drive connected via usb (doesn't need power), run the setup wizard (just 'next' everything for now), then go to the ethercat section, open 'object dictionary' then the little 'PDO' button at the top.... that took forever to figure out when I didn't know what a PDO was....
  • Next step was IO... the drives have 14 digital in, 6 out, some of each are differential, all optoisolated as you'd expect and conveniently you can wire them for common+ or common-, basically you can choose the IO bank for the drive to be sinking or sourcing, which is handy as my Z lims are a different flavour to the X and Y (space limitations motivating that decision). This took a while to figure out:
    • On these drives you can use PDO 0x3000 for raw input states, or 0x60FD (side note, leadshine uses xxxxh to denote hex in the manual) for input states with some named (estop, home etc). You'll need to configure in the leadshine software which IO goes to which name first.
    • Next you'll need to configure the drive to send that, see the leadshine pic for info
    • Then you’ll need to edit your xml to have that new PDO in it.
    • and the bit that took forever to figure out: how do I get this 32/16bit number to be something useful for LCNC? The answer is 'haltype=complex'... which as far as I can figure (if I'm wrong link me, I couldn't find it) does not exist in the linux docs.... only in that 130 page thread 'Ethercat Hal Driver'... Via this haltype you can treat a single 32bit PDO as 32 hal pins, or whatever mix you need. See my attached xml for example
Some important notes about my attached configs: They're bare minimum to get elements working, there's still a bunch of hal stuff to connect etc.

Finally my questions:
  1. I think it's possible to have LCNC/ethercat stack configure a drive on connect via SDOs etc, is that correct? How would I do that?
  2. I note that other devices exist already defined in the lcec stack, what benefits does that bring (beyond the obvious of making their definition in your xml a single line)? Also how would I go about creating an entry for my devices?
  3. Leadshine provides a giant xml file for dowload (attached, leadshine400z.xml), is this useful/how do I use this? Is there some tool I can feed it to?

That's all I can think of for now, cheers guys.
The following user(s) said Thank You: PKM, tommylight, LAUSCH

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

More
13 Feb 2022 16:05 #234707 by LAUSCH
Thank you so much pseudo.
I am also building a CNC with a quite similar setup as yours.
RPi 4B 8GB + Beckhoff EK1100 (Digital Input, Digital Output, Analog Output) and Leadshine ELP-EC750Z drives and ELM0750LH80F-SS.
With your instructions I got things running very quickly.

Cheers

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

More
13 Feb 2022 19:06 #234721 by db1981
Finally my questions:

1. I think it's possible to have LCNC/ethercat stack configure a drive on connect via SDOs etc, is that correct? How would I do that?

this can be done by startup commands as xml file or manually in the ethercat_conf file. Search for initcmds or sdoconfig in this forum, there is also an example on ehtercat github. 


2. I note that other devices exist already defined in the lcec stack, what benefits does that bring (beyond the obvious of making their definition in your xml a single line)? Also how would I go about creating an entry for my devices?

the benefit is, that you can put the ethercat configuration for the device  and realtime handling of the values like statusword controlword, velocity, drive config, scaling   together in one component. So you can handle the drives data and translate it to common linuxcnc halpins / structure
The CIA402 Wrapper for example is the realtime part from an ethercat driver without the pdo config.....  

Leadshine provides a giant xml file for dowload (attached, leadshine400z.xml), is this useful/how do I use this? Is there some tool I can feed it to?

With this file you can feed Beckhoff or other master with all information about the drive, sdo dictonary, pdo types/config etc. 
For now at etherlab / lcec  you can only use it to manually read out your drive pdo config. 
 

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

More
03 Mar 2022 15:04 #236265 by LAUSCH
Hi pseudo,

May I ask if you have progressed on setting up your Leadshine drives? As mentioned in my previous post I am in a very similar situtaion besides my drives are the 750W version.
I just got the bare minimum running including the Digital and Analog IOs via the Beckhoff EK1100.

My questions are right now: Do I need to configure dedicated servo Parameters (P, I, D, FF1, FF2, Deadband) within my INI file or is it also possible to simply pass the position and direction to the drive and let the drive take over?
I got things running without the definition of any servo parameters however I get joint.following errors all the times. When running the servos via the manufacturer software "Motion Control" it is possible to easily adjust acceleration parameters and the servos run very smoothly.

Cheers 
Christian
 

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

Time to create page: 0.082 seconds
Powered by Kunena Forum