LinuxCNC S-Curve Accelerations

More
5 years 8 months ago #199974 by robertspark
Replied by robertspark on topic LinuxCNC S-Curve Accelerations
reading this topic with interest to expand what little I know and what I thought about tradjectory planners and why stuff is programmed the way it is plus the evasive S-curve that regularly crops up over the years on various forums and requests for integration.

does it really change the finished part in the hand at the end of the job?

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

More
5 years 8 months ago #199977 by rodw
Replied by rodw on topic LinuxCNC S-Curve Accelerations

robertspark wrote: does it really change the finished part in the hand at the end of the job?


Yes I believe so. Imagine a plasma cutter cutting at 10.24 m/min with 5 m/sec/sec acceleration (0.5G). It will get to speed in 30 milliseconds.... the inertia results in a massive jerk when it stops and starts and also when it gets to speed and stops accelerating. Oscillations in the cut are inevitable.

For a milling machine at a more leisurely pace, its probably not so much an issue but I have heard of users doing retrofits complaining about jerk on big heavy machining centres...

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

More
5 years 8 months ago #199980 by chris@cnc
Replied by chris@cnc on topic LinuxCNC S-Curve Accelerations
To bridge the gap until the developers have something. Many good servos already have this function. Example from the Delta manual

Attachments:

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

More
5 years 7 months ago #201500 by grijalvap
Replied by grijalvap on topic LinuxCNC S-Curve Accelerations
It seems to be veri good solution however no sure if this can be sincronized for at least 2 axis.

I was reading this interesting article about bezier curver
www.drdobbs.com/forward-difference-calcu...-of-bezier/184403417

and I think it can be helpfull to solve the maths

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

More
5 years 7 months ago #202966 by arvidb
Replied by arvidb on topic LinuxCNC S-Curve Accelerations
I've done some more work on this. I worked through the remaining equations and ended up with something I simply don't know how to solve. I believe it's a cubic equation, but it contains the root of a sum of the squared dependant and other variables:

t2^3 = 1/6*(6*a0^2*j0*t2 - 2*a0^3 + 6*j0^2*s_target - 6*(2*j0^2*t2 - a0*j0)*v0 - 3*(2*j0^2*t2^2 - a0^2 + 2*j0*v0)*sqrt(j0^2*t2^2 - 1/2*a0^2 + j0*v0))/j0^3, where t2 is the variable to solve for.

Anyway, I tired of banging my head against these equations, and decided to try a numerical solution for the remaining cases instead:
Code:
$ cargo test Compiling smooth1d v0.1.0 (/home/arvidb/tmp/linuxcnc/smooth1d) running 31 tests test path::tests::alim_continued_move_pos ... ok test path::tests::alim_continued_move_neg ... ok test path::tests::alim_inc_vel_novmax_pos ... ok test path::tests::alim_dec_vel_pos ... ok test path::tests::alim_move_all_limits_neg ... ok test path::tests::alim_move_all_limits_pos ... ok test path::tests::alim_null_move ... ok test path::tests::alim_move_no_vmax_neg ... ok test path::tests::alim_inc_vel_pos ... ok test path::tests::alim_move_no_vmax_pos ... ok test path::tests::alim_shortened_move_neg ... ok test path::tests::alim_reversed_move_pos ... ok test path::tests::alim_reversed_move_neg ... ok test path::tests::alim_shortened_move_pos ... ok test path::tests::alim_stop_pos ... ok test path::tests::alim_stop_neg ... ok test path::tests::jlim_continued_move ... ok test path::tests::jlim_complex ... ok test path::tests::jlim_move_all_limits_neg ... ok test path::tests::jlim_move_no_amax_neg ... ok test path::tests::jlim_move_no_amax_pos ... ok test path::tests::jlim_move_no_vmax_nor_amax_neg ... ok test path::tests::jlim_move_all_limits_pos ... ok test path::tests::jlim_move_no_vmax_neg ... ok test path::tests::jlim_move_no_vmax_nor_amax_pos ... ok test path::tests::jlim_move_no_vmax_pos ... ok test path::tests::jlim_stop_at_amax ... ok test path::tests::jlim_stop_at_vmax ... ok test path::tests::jlim_stop_not_at_limits ... ok test path::tests::jlim_stop_switch_v ... ok test path::tests::alim_stop_interrupted ... ok test result: ok. 31 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Of course a numerical (iterative) solution is not great in a real time system. I benchmarked the code - and got a bit of a shock when it reported ~100 ms for a solution! That's eons of computer time! Then I realised I had a lot of debug printouts. Rmoving them brought it down to ~7 ms. Still way too much. Maybe I should try an optimised build instead of a debug build? That gave another factor 10 improvement - but still too slow. Then I realised that maybe I don't need picometer accuracy *lol*. Changing it to 0.1 µm brought the calculation time down to less than 50 µs on my i5-3470 CPU. Still not great but at least it's in the realm of usability. For comparison, the cases where I have an analytical solution benchmarks at about 2-3 µs.

It should also be possible to optimise the algorithm to converge faster. And I haven't given up hope on an analytical solution, either. Maybe there's help to find at Mathematics Stack Exchange or even the local university, if needs be.

I still have a few test cases unaccounted for, but they should be variants of the ones I already have so should not present any huge difficulties. (One can hope, at least. :)) Then it's off to integration with linuxcnc. One positive thing about using a numerical solution is that it doesn't need the cubic solver from the GNU Science Library, which removes the GPLv3 "taint".

Here's the output of the "jlim_complex" test. It's supposed to model jogging with a (course) MPG. It sets the target position to 0.01 m at t = 0.0; 0.02 m at t = 0.1; 0.03 m at t = 0.2, 0.04 m at t = 0.3 and then back to 0.03 m at t = 0.5:

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

More
5 years 7 months ago #202986 by Hakan
Replied by Hakan on topic LinuxCNC S-Curve Accelerations
Ohh that one is easy to solve

I more wanted to point at a tool you might want to use.
Attachments:
The following user(s) said Thank You: arvidb, Nico2017

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

Time to create page: 0.184 seconds
Powered by Kunena Forum