LinuxCNC S-Curve Accelerations

More
05 Jan 2026 19:47 - 05 Jan 2026 20:36 #341022 by PCW
Replied by PCW on topic LinuxCNC S-Curve Accelerations
Yes, the error spike at the beginning and end of motion cannot be eliminated without jerk control.
 This is because without jerk control you have a step function in acceleration=force which is physically
impossible as that requires infinite motion control bandwidth.
Last edit: 05 Jan 2026 20:36 by PCW.
The following user(s) said Thank You: endian

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

  • grandixximo
  • grandixximo's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
05 Jan 2026 22:32 #341027 by grandixximo
Replied by grandixximo on topic LinuxCNC S-Curve Accelerations
Endian, you should use or2 gates, not and2, if for example only X is homing you still want planner 0
Also the mux2 values I think are reversed.

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

More
05 Jan 2026 23:03 - 06 Jan 2026 07:54 #341028 by endian
Replied by endian on topic LinuxCNC S-Curve Accelerations
I just need to home with 3phase planner (because of my own code) and then after each joint is hommed I want to use the scurve 7phase stuff..

 It is just quick setup and forum is my external notepad ... 

Luca can I ask you about your ideas of optimalization of the code to avoiding the spikes? 

Which rabbits do you have in your hat btw?
Last edit: 06 Jan 2026 07:54 by endian.

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

  • grandixximo
  • grandixximo's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
06 Jan 2026 00:10 #341029 by grandixximo
Replied by grandixximo on topic LinuxCNC S-Curve Accelerations
Can you compare with PLANNER_TYPE = 0
can you share your testing g-code?

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

More
06 Jan 2026 07:52 - 06 Jan 2026 08:07 #341047 by endian
Replied by endian on topic LinuxCNC S-Curve Accelerations
I think there is no simple answer now.. but from testing last few days its waaay good to control any hardware and smoothness is uncomparable...

I will share testing gcode in comming days .. but basically I go through all examples in nc_file folder and then my code.. my code will be avaible here

I am now searching the best solution of testing and validation ...there is not space for one lady said..

To prove all main stuff but idea is basicaly simole.. step by step test all avaible G code which I have from real machine but there is some limition of my time 

Btw 杨阳 is mika-net at forum? If am I wrong?
 
Last edit: 06 Jan 2026 08:07 by endian.

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

  • grandixximo
  • grandixximo's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
06 Jan 2026 08:35 - 06 Jan 2026 09:04 #341049 by grandixximo
Replied by grandixximo on topic LinuxCNC S-Curve Accelerations
Yes, I think he is

Edit:
Don't really have any tricks up my sleeves or anything, YangYang or Mika-net here on the forum coded the S-curve, I did most of the testing, we have not till now found anything better, performance and accuracy wise, it's possible some Algo is out there that is better we just have not come across it.
About the spikes, no idea we run 1ms servo and have not noticed realtime errors, I wasn't looking at servo thread in the scope during testing, I'd like your test codes to compare the spikes, possibly try some optimization, but the current code in the PR is best we got today.
Last edit: 06 Jan 2026 09:04 by grandixximo.
The following user(s) said Thank You: endian

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

More
06 Jan 2026 09:54 #341055 by endian
Replied by endian on topic LinuxCNC S-Curve Accelerations
Optimalization of RT code is fundamental but I am not expert of them .. golder standard of industrial grade cycle is 250us(which i am facing from my experiences) therefore from before posted scurve planners I have noticed some lagging even at 2ms which is many times bigger...

I saw that many division like "temp/2" in the code, which divider is constant can be replaced by multiply of 0.5 if it is possible ..same but faster?

I am now optimizing the postprocessor and generating the gcode but I am moving to new house and its little bit tricky now .. i have just one working hardware benchtop example with 2ms scan time which is at limit of the RT.. but i have noticed that lagging at starting/stopping of movement is away .. 

Every native cycle as driling turning I need to check too ...

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

More
06 Jan 2026 11:04 #341057 by rodw
Replied by rodw on topic LinuxCNC S-Curve Accelerations
I don't think it makes sense to manually optimise for execution speed in this day and age. Instead use GCC compiler options -03 or -0fast and possibly native optimisations march=native and possibly mtune=native. This may increase code size and possibly memory usage but I don't see that current hardware has constraints in this area. Gone are the days of massaging code to save every byte to fit in a 64k terminal! I did find using the C ternary operator was more efficient than if-else during that exercise.

I had a brief look at the code and it seemed to be well written and efficient.

In some benchmarking I did some time ago on an i5 with bookworm, the 1ms (1000 ns) servo thread executed in about 200 ns and slept for 800 ns so I don't think you will have issues if the s curve code increases execution time.

Of course it goes without saying the PREMPT_RT kernel needs tuning and that's been hard to articulate even after hours of study. My best effort covered in my recent video which has got jitter down to 6 ns according to one viewer. 


@endian, there is a recent PR from grandixximo on the Ethercat hal driver to sync the servo thread to the Ethercat loop which may help you if committed. github.com/linuxcnc-ethercat/linuxcnc-ethercat/pull/465
 
 
The following user(s) said Thank You: akb1212, endian

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

More
06 Jan 2026 11:52 #341061 by endian
Replied by endian on topic LinuxCNC S-Curve Accelerations
Thank you Rod.. I think it will help everybody with low latency and ethercat jitter...

What i can tell from my observation... If anybody using CSP driver over ethercat.. position is sending but there is everytime single cycle lag because of no feed forward observer FF1 like during compensation in the PID overc command velocity ...
There will be best if the planner will have allready positionCommand(t) and positionCommand(t+1) for direct position control setup .. this will directly avoid lagging just for this purpose .. do you think about it?

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

  • grandixximo
  • grandixximo's Avatar Topic Author
  • Away
  • Premium Member
  • Premium Member
More
06 Jan 2026 12:45 - 06 Jan 2026 13:02 #341063 by grandixximo
Replied by grandixximo on topic LinuxCNC S-Curve Accelerations
I looked at some optimization routes today, nothing sticks, as rodw said modern compiler do already an excellent job. /2 or *.5 does not matter, the compiler does not actually call the division in assembly, /2 stays for code readability. please first give me a code that I can run, that spikes with our scurve, and does not spike with trapez acc. And then we could seriously look at what operations that we introduced might be spiking the servo-thread, and see if optimization is viable/necessary.
Last edit: 06 Jan 2026 13:02 by grandixximo.
The following user(s) said Thank You: akb1212, endian, Unlogic

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

Time to create page: 0.121 seconds
Powered by Kunena Forum