Dual PID loops and appropriate pins for feedback to the Trajectory Planner et al

More
27 Jun 2026 03:56 #347359 by Becksvill
hey guys

just wanted to report back on this dual feedback thread

I have a large cnc with 0.1mm backlash on the z axis.  so i put a scale on it and the results are awesome

i have accuracy within 0.002mm (compared to the scale accuracy at least assuming that is  good)

i tried both 1 PID loop and 2 PID loops that have the outputs summed together.

with the single loop i had the velocity PID input coming from the motor rotary encoder and the final position from the linear encoder.  and it worked but was really rough and kept bouncing back and forth with the 0.1mm backlash  

the two summed loops are really smooth and awesome  the trick is the first loop has the high resolution encoder on servo drive and that has really good performance and of course no backlash.  and I can change all the normal PID values except Integral  and the 2nd PID loop only has the linear encoder input.  and only PID setting is Integral.  so i get nice and smooth motor but still backlash from first loop and then once the axis gets close the Integral moves the last 0.1mm over a second or so.
so by the time i am cutting the machine is perfectly where it should be.  this is probably not so good for high speed surfacing stuff for that you need to remove the physical backlash.  but for a slightly slower machine its awesome.

have a look at this thread where i show some more photos of it.  its working most days now and running hard in production.


forum.linuxcnc.org/show-your-stuff/58689...ing-running-linuxcnc

cheers

 
The following user(s) said Thank You: tommylight

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

More
27 Jun 2026 23:48 #347361 by akb1212
Thanks for sharing! This is great stuff. My mill is from the same time period, so same problems as yours I guess. It's a 1989 Maho MH600E.

One thing though, would you mind sharing your actual config files? That whould be the absolute best way to help us others who are also trying to wotk out how to make this work. And since my machine have much the same issues as yours I'm hoping to be able to have a closer look at a config file which is actually working, and have solved this problem.

Thanks for sharing! I hope you see this and are willing to share your config files too!

Cheers

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

More
02 Aug 2026 07:16 #348368 by Becksvill
hey logged on to linuxcnc and just saw this now i will get my config

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

More
02 Aug 2026 07:22 #348369 by Becksvill
hey let me know if you get this ok 

File Attachment:

File Name: fil_test_s...8-02.zip
File Size:17 KB
Attachments:
The following user(s) said Thank You: rodw, NWE

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

More
03 Aug 2026 00:06 #348400 by cmorley
I wanted to add this to our docs some where for a guide to others.
When I looked at this and it seems you have both encoders connected to index-enable.

This seems wrong in my head, as it would depend on which encoder index fired first.

Any opinion or insight?
Thanks
The following user(s) said Thank You: NWE

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

More
03 Aug 2026 05:50 #348402 by NWE

When I looked at this and it seems you have both encoders connected to index-enable.


 

I agree this sounds off. I suspect it will very likely always find the one index first, and I expect that to be the servo index, unless home switch is quite near to scale index. I think ideally you'd want to use only the scale index.

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

More
05 Aug 2026 02:59 #348455 by cmorley
I think this shows the basics of the summed PIDs.
 
Attachments:
The following user(s) said Thank You: tommylight, NWE

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

More
06 Aug 2026 19:57 #348506 by NWE
Perfect. I always thought I had to cascade them, which seems to multiply the tuning time and effort.
@cmorley I printed that and am hanging it on my wall for future reference 

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

More
07 Aug 2026 01:27 #348518 by cmorley
Excellent. I will add it and a little writeup in the official docs.

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

More
08 Aug 2026 10:35 #348553 by Becksvill
Chris there is a bug with the index enable stuff i think when summing the PID loops like this. I forget exactly why i connected both encoder index pulses to index enable

i read i think earlier in this thread that you can connect both encoders to index enable and also connect them with a physical wire so the first index to fire triggers the homing. but i couldn't get it to work. rereading my post it sounds like i just messed this up but i really do think there is a bug. I could test if you want to go through with me and prove the issue. we have messaged off forum on messenger before..

so i tried just one PID loop with the velocity input coming from the encoder and the position input coming from the scale. and that homed to index enable fine but the tuning was really rough. i couldn't believe how bad it was. it was like there was a stuffed bearing on the ballscrew. and the axis kept bounching back and forth around the 0.1mm backlash which was unusable. and after i had just tested the other way with a smooth as silk axis that always stopped perfectly within 0.002mm I wasn't going back I talked about the mesa index enable issue with PCW a bit but i ran out of time to fully prove it was a bug. But i definitely think that having the 2 separate PID loops breaks the index enable logic.

anyway after all that i read somewhere on the forum that someone else had the same issue for some reason and the really inelegant solution is to run the home switch through classic ladder and have it trigger on the home switch first and then look for the change in homing state and on the next state when the encoder is searching for index pulse use classic ladder to feed it the encoder physical index pulse from rotary motor encoder on end of ballscrew. this means that you have to home that last little bit extra slow as it can miss the pulse. and it is not that best. But in saying that i haven't had it miss the pulse yet and it's not that much slower to home.

But i would like to fix this as this is the last annoyance that if it was fixed i would probably go crazy and put scales all over my machines lol

So Chris your classic ladder is still getting used all the time by people keep up the good work.

cheers andrew

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

Time to create page: 0.185 seconds
Powered by Kunena Forum