EtherCAT + RPi build log along with questions

08 Feb 2023 07:22 #264010 by LAUSCH
Hi pseudo,

Now I'm the one with the late answer - sorry for that, but I've been really busy with work over the last few months.
The setup and fine-tuning of the drives not only took a lot of time, but also had its ups and downs. In the meantime, I have a working setup (you can find all the files attached to this post), but there were many lessons to learn and there are still many things to learn and optimize.

1.) I have also come to the point that Pr0.02 must be 1 for "Velocity Mode".
2.) The machine works when Pr0.00 is set to 1 for all axes, but your comment is correct and I missed that statement in the manual. I will try 0 or 100+ and report back on the results.
3.) Regarding my experience with PID: As you can see in my INI/HAL, there is a PID put in place. Initially the parameters were set to achieve the lowest possible following error (<0.01mm) while still keeping the machine stable at higher speeds (10m/min). But when operating the machine, cracking noises could be heard. At first I thought these were coming from the mechanics, later I found out that this was coming from the PID. Then the PID was disabled by setting all parameters to 0 except FF1 which is set to 1. The machine worked although having larger follwing errors and the results were amazingly good! BUT - and of course there has to be one - I had another strange problem. When the machine was switched off after moving to any position, the current set position was set equal to the commanded position, thus ignoring/overwriting the feedback from the abosolut encoder! Since there is always a small difference between the commanded position and the target position, there were growing deviations when several parts were machined in succession without a zero point being set in between, or when the machine was switched off and on several times for a single part.
Therefore, you can now find very low values for the integral part of the PID with P=5.

As the machine is running and the first projects were granted higher priority there was not much more fine tuning and optimization the past months. But knowing there is someone working on the same setup is motivating me againg to look deeper into the topic. I hope that we can find the best setup for this sort of setup and can post it soon.

Many thanks for your input!

PS: Please apologize for the messy HAL/INI file with german and english comments all mixed up.
PPS: I am very curious about your machine and would be happy to know more about it. You can find a picture of mine in the attachments (the first to be uploaded at all)

Cheers Christian

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

09 Feb 2023 00:07 #264081 by pseudo
Hi Lausch, no need to apologise, I've been pretty busy too.

Setting up the drives took a while: yeah... they're capable but I suspect that there's a bunch of 'smart' things happening that are making them useless in position mode (eg they'd settle with a huge steady state error etc) and the documentation/software isn't clear on what might be doing that... but PID back to LCNC in vel mode works well. I guess that's the difference between a $10k yaskawa setup and these :shrug:

PID: yeah, I have mixed settings:
  • Z axis has a ~1:1 inertia ratio (aka ~100 in the software), but is horizontal (ie not impacted by gravity) and has the least mass to move. It only needed ff1=1 and a P of 40
  • Y axis has a ~1:1.5 but has ~10-15kg to lift on a 10mm pitch screw so gravity has a huge impact. I couldn't figure out the bias value in time for a deadline so it's got a less than ideal tune but still does very well, P=70, I=0.5, D=1.2. FF1=1. Bias is 0 but it needs one I think, very asymmetric load.
  • X axis is another story... I'm not sure what the inertia ratio really is... the software craps out around the 1000 mark (ie 1:10) but prior to the LCNC PID change I got it to tune with 888 value though with less than ideal following error. This axis is a 400W servo directly into a dual output 5:1 very low backlash servo gearbox, with a shaft running to either side of the gantry to a pulley. The axis drives itself along a pair of ATL5 belts in omega configuration (ie fixed belt, pulley crawls along the belt, basically the quiet version of a rack and pinion). The LCNC PID for this axis is... also not great, but vastly better than it was. I haven't been able to get a tight tune though I'll revisit it before the prototype goes to its owner. The issue I have is oscillations, both high frequency ones and very low frequency ones. Low P value relative to the others, and Fortunately this application has the X axis predominantly doing long swooping back and forth motions (4m travel) so it works well with lower accelerations and a slightly looser tune (following error is still <0.5mm on 60m/min rapids)... I've since done a test cut at 40m/min in the cut (foam) and it cut perfectly... finally. P=70, I=15, D=0.15. FF1=1. Lotta room for improvement on this one though.
One of the issues with tuning the LCNC PID is you're competing with the drive's PID/other settings. One thing I realised halfway through my tune (with deadline looming that day...) is I still had some command smoothing and filtering on the drives... which made tuning much easier once I disabled. I actually tuned the drives with a laptop plugged into the drives and was playing with the leadshine tune simultaneously; for example I was able to increase stiffness on the drive without adding noise while in this velocity mode.
There's still a lot of drive-side tuning I could do, need to dig through the manual with velocity mode in mind to find it all though. If the budget could stretch to a bigger gearbox (400W rated one was $500) to suit my spare 750w motor I'd change over X and solve a bunch of issues.

Your deviation problem is interesting.. I don't have absolute encoders on mine so I haven't had that issue, I need to home before use. I vaguely recall seeing something in one of the ethercat threads about updating lcnc using the absolute encoder but I can't find it nor remember enough to give you a good search term.

Do you have an email I can send you links to video of my machine? I can't post it here yet for business reasons outside of my control, but once it's released I will update on the forum. Feel free to edit your post to remove your email once I've sent you one.
The following user(s) said Thank You: LAUSCH

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

14 Feb 2023 11:20 - 16 Feb 2023 09:43 #264498 by LAUSCH
Hi Pseudo,

The exchange with you is very valuable to me - thanks for that. I came to the very same conclusion namely that the drives control is competing with LinuxCNC but without any PID in Linux it will also not work properly...
Maybe I find some spare time during the weekend so I can try optimizing my configuration.

Last edit: 16 Feb 2023 09:43 by LAUSCH.

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

18 Feb 2023 20:23 #264771 by LAUSCH
Hi Pseudo,

Today I spent some time on optimizing the drive setup:
Initial Setup:
  • Pr0.00 = 1 (set bandwith automaticall)
  • Pr0.02 = 1 (velocity mode)
  • Pr1.15 = 0 (mode of position control - fixed to first gain)
  • PID within LinuxCNC was basically the same for all axes with P=5; I=0; D=0; FF1=1
Then I was entering LinuxCNC and opened the hal-scope in order to check on the following error.
The speed was set to 10m/min and I moved the axis.
Following errors were about 0.35mm.

Afterwards I have changed the parameters of the drives to
  • Pr0.00 = 0 (inactive)
  • Pr0.02 = 0 (inactive)
  • Pr1.XX Gain adjustment values set to default
  • Inertia Ratio values remained unchanged
(PS: with these settings I cannot recommend to use the jogging command of Motion Studios)
The results in hal-scope basically did not change - which admittedly was a bit unexpected.

But the big game changer was that from now on I was able to adjust my PID parameters freely without any strange interferences from the drives (in the past I got rattling noises and vibration as soon as the PID parameters became to "strong").

The procedure was as follows:
  1. ​​​​​​​Increase P until some oscillation is visible and slighlty lower the value again (velocity set to 10m/min)
  2. Then I tried to use I and D to adjust the remaining error as well as overshoots without satisfying results - so I kept I = 0 and D =0
  3. Increase FF1 very slightly and got the effect that was expected from integral part
  4. Put FF2 into action to remove overshoots as expected from differential part
As you can also see in the attached pictures this helped to extremely lower the following error to values below 0.07mm at 10m/min. With these values I seem to reached a limit. Typically I am machinng with velocities of less then 3m/min. At these velocities I get following errors which are ridicolously low.
I used these settings to mill a few parts and I am really happy with it!

Attached you will find my latest settings. 

Maybe you can try this approach with your machine setup and report if you also get good results?



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

25 Feb 2023 00:50 #265295 by pseudo
Hi Lausch,

As usual you've solved a problem just when I needed it ;) I'm going to implement this today and report back, I only have one question: "Inertia Ratio values remained unchanged" as in you reset them to defaults, or left them as they were after inertia ratio identification?

Also, your observation that I and D don't seem to behave how you expect matches my observations too, I ended up leaving the motors with a very sub-optimal tune as a result. I did play a little with the FFs but had crazy results - I suspect that once I implement your recommended changes and the drive is no longer fighting linuxcnc I'll get much more predictable results.

One other question: What is your setup for homing? Are you using CIA402 homing and a separate halcomponent? I'm using linuxcnc's basic homing currently but need to set my max ferror to 10mm so they don't following error during homing (for some reason they stop reporting position for some stages of homing?). I've noticed in some threads they mention the complexities of using CIA402 homing but as the issue is changing rapidly and a lot of the posts on it are a year old I've put that in the 'not right now' pile for a bit.

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

27 Feb 2023 04:19 - 27 Feb 2023 04:21 #265481 by pseudo
Quick update:

Did what you suggested and it definitely improved things. A couple other things I played with that you might find useful:
  • Manually tuning: X axis is flawed (dual fixed 4m ATL5 steel core belts the gantry crawls up like a rack, is effectively a spring, resonance issues) so I ended up manually tuning pr1.00-04, and pr1.12 while linuxcnc was simultaneously tuning the PID on linuxcnc. I started with setting the drive's stiffness to give some good starting values, then switching the auto modes off as you recommended, then playing with the settings manually. I didn't bother doing this for the other axis as they were fine without it. I managed to halve the following error this way (but likely only because it's such an odd kinematic setup)
  • 3.12 and 3.13 accel/decel: These values limit drive's responsiveness but do prevent jerk, I reduced the from the defaults (100) to 20
  • 3.14 - Sigmoid accel/decel: given the springiness of the X axis I added a tiny bit of S curve via this parameter which smoothed out the bounce and allowed smoother movement/tighter pid.
  • 3.16 Zero speed clamp: I'm unsure if this had any impact during PID testing but I suspect it will in use. Basically it sets what RPM the drive should consider 'stopped' and try and clamp the speed at 0. Given the very low reduction on X (one revolution of the motor is 6.3mm of travel) I dropped this to the lowest value of 10 for this axis. I think it'll have an impact when the drive is accelerating from stop etc.
  • 4.37-39: for the axis with a brake (Y in my case) tweaking these settings improved smoothness when the drive is enabled - previously the axis would drop a small amount when the motor turned off leading to a shock load on the brake. You might find it useful also
  • 6.08/09 torque compensation: It took forever to find a parameter to bias for gravity, turns out it's these two. My Y is on a 10mm ballscrew and pushing ~15kg, if you disconnect the motor from the screw it falls pretty quickly (all axis are set up for high speeds and small loads). I noticed that the drive would always lag going up and then overcompensate, by tweaking this I got it to behave symmetrically.

    One thing I haven't been able to figure out is vibration suppression... I previously got it to work (in one of the videos I sent you) but I haven't been able to get it to work with the velocity mode change (with drives set to auto or manual), not sure what's going on there. Also never got the adaptive auto filter to do anything (in position or vel mode), did you ever play with those features?
Last edit: 27 Feb 2023 04:21 by pseudo. Reason: Mistake

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

28 Feb 2023 07:17 #265533 by LAUSCH
Hi pseudo,

Good to hear that you are making continuous progress. And thank you for sharing all your experiences.
Unfortunately I cannot help you with the homing aspect. As my drives are equipped with multiturn absolute encoders there is no need to home the system at all.
It seems that due to the low acc. and vel. of my machine many standard parameters work sufficiently for me.
I will for sure try some of these parameters.

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

26 May 2023 14:47 #272217 by buzzFab
Hey pseudo and LAUSCH, I recently picked up some Leadshine EL8 and ELM2 motors and absolute encoders, I will probably start bench testing next week. how are your builds coming along? have you made any progress improving the response of the drives and motors?. I'm going to use Orange Pi 5 Plus instead of a RPi4 as it has dual 2.5g ethernet ports.  

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

Time to create page: 0.093 seconds
Powered by Kunena Forum