Basic "S curve" motion control questions

181 views
Skip to first unread message

cncmachineguy

unread,
Jun 18, 2020, 6:17:40 AM6/18/20
to OpenPnP
I need to stop mucking up Mark's thread with my fundumental questions. So here goes:
1: Are the entry and exit curves of the "S" actually arcs of some circle defined by jerk?
2: The first arc of curse start at motion =0, then ends at the tangent of the slope defined by max acceleration?
3: The top arc starts at the tangent of the accel slope, then of course ends at accel =0 velocity = max?

Then this is all reversed for Deceleration.

Above is the simple case where the move distance is long enough to reach all the limits.

the next case is where the distance is too short to hit max velocity, but still makes the full arcs. so V is lower then max.
third case is the move is so short we don't even get out of jerk control, so the first arc feeds directly into the second arc, of course at the tangent point of them both. (can't hit Vmax or Amax)

So Do I have this correct? Of course it is based on the first assumption being the "s" sections are true arcs. So if I have that wrong the rest is fodder.

Arthur Wolf

unread,
Jun 18, 2020, 6:27:01 AM6/18/20
to ope...@googlegroups.com
Speed is +/- position
Acceleration is +/- speed
S-curve ( sometimes called jerk, but jerk in the 3D printing world is a different thing ) is +/- acceleration
You could add more on top of that, that's called "n-th order acceleration".


The only current implementation of s-curve in the open-source CNC world, is tinyg, and it's widely reported their implementation is very buggy.
This is much more difficult than it might seem at first, there are lots of edge cases and weird things to work around.
In the real industrial world, s-curve-capable controllers patent a lot of techniques around this, and they typically don't have a simple algo like you'd expect, but a lot of situation-dependant ways of handling things.



--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/a9ba3206-85c6-490c-a907-9d7b8aba17f5o%40googlegroups.com.


--
勇気とユーモア

bert shivaan

unread,
Jun 18, 2020, 6:40:08 AM6/18/20
to OpenPnP
Thanks Arthur.
Do you know the answers to any of my questions?
I see a lot of `big math being solved here. Yes it is a NOT simple problem. It has been addressed in the machining world for 30 years now - "High Speed Machining" LeBlond was the first at a good working solution as far as I remember. Back then all this big math was NOT done on the machine. just like arcs (G2/G3) are not made using trig functions in industrial machine controls, at least not way back in the 80's.



Arthur Wolf

unread,
Jun 18, 2020, 6:48:26 AM6/18/20
to ope...@googlegroups.com
I don't get the questions ( might be due to a lack of standardized vocabulary for this field ), which is why I started explaining s-curve from the ground up.



--
勇気とユーモア

bert shivaan

unread,
Jun 18, 2020, 6:56:49 AM6/18/20
to OpenPnP
No, It is more likely because I SUCK at asking questions.
My first question, are the "curves" in the S true arcs with a single center point and radius?
So let me try to explain my vocabulary here -
The "S" as I have seen is made up of 3 parts.
the first arc(?) leading from stop to linear accel stage.
then the linear accel stage
then the arc(?) from accel to max speed.

then when we slow down we do it backwards.
arc(?) from max speed to linear decel
linear decel
arc(?) from linear decel to stop.

it is the arc I am trying to understand. is it just truely an arc with 1 radius and center point (as opposed to an ellipse with MANY radi and 2 centers)

bert shivaan

unread,
Jun 18, 2020, 7:01:18 AM6/18/20
to OpenPnP
Also you inspired another question, How does one prove/demonstrate that their controller provides ture "S curve motion" as you say tinyG is the only one that does? Is there a way to plot it on an o-scope or something?

bert shivaan

unread,
Jun 18, 2020, 7:12:24 AM6/18/20
to OpenPnP
Another thought, yes it is extremely complicated when coordinated motion is concerned across multiple axis. My question really only involves a single axis.

Arthur Wolf

unread,
Jun 18, 2020, 7:18:52 AM6/18/20
to ope...@googlegroups.com
No, those are not circles, they'd be closer to something like an exponential function. It's increase in acceleration instead of just acceleration, same difference as f(x)=x compared to f(x)=x²



--
勇気とユーモア

Arthur Wolf

unread,
Jun 18, 2020, 7:19:37 AM6/18/20
to ope...@googlegroups.com
On Thu, Jun 18, 2020 at 1:12 PM bert shivaan <bert.s...@gmail.com> wrote:
Another thought, yes it is extremely complicated when coordinated motion is concerned across multiple axis. My question really only involves a single axis.

That's one complication, but even with a single axis it's much more trouble than normal acceleration.

bert shivaan

unread,
Jun 18, 2020, 7:28:59 AM6/18/20
to OpenPnP
So more of a parabola?
How much actual time is spent in the "curves"? ie getting into and out of the linear accel section? I am trying to wrap my mind around orders of magnitude here.
So like 1 sec
.1sec
10mS
1mS

I know there are lots of variables to drive that time, but in a general sense.
For instance if my Z travel takes 2 seconds to go full stroke, if the accel/decel stage takes .5sec, do you have a feel for how long the curves take?

Why can't they be simple arcs?
Would we loose too much time that way because we could have reached max accel faster? (the linear portion)

Any thoughts on how to view the motion curve in real time in the real world?

Arthur Wolf

unread,
Jun 18, 2020, 7:45:13 AM6/18/20
to ope...@googlegroups.com
On Thu, Jun 18, 2020 at 1:29 PM bert shivaan <bert.s...@gmail.com> wrote:
So more of a parabola?

That'd be close yes.
Speed is increase in position, acceleration is increase in speed, s-curve is increase in acceleration. See the picture I posted above.

How much actual time is spent in the "curves"?

Completely depends on the configuration, can vary wildly.
As long as you are changing velocity ( which is most of the time unless you are doing long moves ), you are in those curves, all acceleration/deceleration is done with those curves.
 
ie getting into and out of the linear accel section? I am trying to wrap my mind around orders of magnitude here.
So like 1 sec
.1sec
10mS
1mS

I know there are lots of variables to drive that time, but in a general sense.
For instance if my Z travel takes 2 seconds to go full stroke, if the accel/decel stage takes .5sec, do you have a feel for how long the curves take?
 
Completely configuration-dependent, can go from close to nothing ( lightweight machine ), to close to all of it ( heavy machine ).

Why can't they be simple arcs?

That wouldn't be a linear increase in acceleration then, it'd be an arbitrary formula with no connection to the physical reality of the job.

The reason we use acceleration, is if we went from speed 0 to speed 100% immediately, it would require too much force, you have to go progressively
The same way, s-curve allows you to not go from acceleration 0 to acceleration 100% immediately, but to progressively increase acceleration.
Doing this ( true for both acceleration and s-curve ) reduces the amount of force the machine has to exert at any one time, this is what this is all about.

You need to think about the force vectors of your machine moving, and consider acceleration and s-curve as ways to keep those vectors under a certain length/force ( because if you were to let those vectors get too big, your machine might not be able to physically handle the effort ).

Would we loose too much time that way because we could have reached max accel faster? (the linear portion)

An actual circle is just unrelated to this.
This is like if somebody asks you to calculate PI, but the only mathematical tool you are allowed is a square root, it's just irrelevant.

Any thoughts on how to view the motion curve in real time in the real world?

ma...@makr.zone

unread,
Jun 18, 2020, 9:37:26 AM6/18/20
to ope...@googlegroups.com

Hi cncmachineguy

it's all about so called Derivatives.

https://en.wikipedia.org/wiki/Derivative

A Derivative is how "something" changes over time. For motion control we are talking about "Location in Space".

The first derivative i.e. the change of Location over time is Velocity:

https://en.wikipedia.org/wiki/Velocity

The second derivative i.e. the change of Velocity over time is Acceleration. That is what presses you in the seat if a vehicle is accelerating. It work the same way as gravity:

https://en.wikipedia.org/wiki/Acceleration

The third derivative i.e. the change of Acceleration over time is Jerk. You can think of it as a measure of how quickly you press down the pedal of a vehicle. If you do it gradually, you have Jerk Control. If you stamp on it, you have no Jerk Control and you get Constant Acceleration motion control (like with Smoothieware):

https://en.wikipedia.org/wiki/Jerk_(physics)

The Derivatives go on and on, but for most practical Motion Control purposes, Jerk Control is the bottom of it.

We usually just switch Jerk on or off to some constant value. It can be negative or positive or zero.

The Jerk value you use is governed by how much vibration happens in your machine and how much vibration your application can tolerate (I'm simplifying).

The important thing is that it's a constant value.

Now we need to go back up the Derivative Ladder. The opposite of a Derivative is an Integral. An integral is equivalent with the "area under the curve".

https://simple.wikipedia.org/wiki/Integral

And that's where the formulas we are using come from.

The Integral of constant Jerk  j  over time t is the Acceleration a. As we have seen it's the "area under the curve" so you can think of it is a rectangle with length t and height j. You know the area of a rectangle is the product, so j*t.

a = j*t

The Integral of Acceleration a over time t  is the Velocity V is more complicated, because it is no longer a constant. Instead it a is rising up with t and the "area under the curve" is a right triangle. We know a right triangle has half the area of its bounding rectangle. So the Integral formula is:

V = 1/2 a*t

and if we substitute the formula for a

V = 1/2 j*t*t

That is written as

V = 1/2 j*t2

The Integral of Velocity V over time t  is the Location s. This time please just believe me :-) the formula is

s = 1/6 j*t3

That gives you the answer to your initial question:

> 1: Are the entry and exit curves of the "S" actually arcs of some circle defined by jerk?

No, these are segments of the Velocity curve (the brown one). As we've seen, it adheres to the formula V = 1/2 j*t2

So what we have in the jerk phases (I, III, V and VII) is a segment of a quadratic function.

https://en.wikipedia.org/wiki/Square_(algebra)#In_real_numbers

> 2: The first arc of curse start at motion =0, then ends at the tangent of the slope defined by max acceleration?

Correct. The slope of course is again the Integral of that max acceleration constant amax so

V = amax*t

A linear function:

https://en.wikipedia.org/wiki/Linear_function_(calculus)


> 3: The top arc starts at the tangent of the accel slope, then of course ends at accel =0 velocity = max?

Correct.

That helps?

_Mark

bert shivaan

unread,
Jun 18, 2020, 7:20:51 PM6/18/20
to OpenPnP
Thanks Mark, and thanks Arthur.

Last thing is does anybody have any suggestions how to test the motion profile? What I am trying to think of is like plotting the produced steps to be sure the shape of the curve. 

Any Ideas?
Anyone?

Mr. Cruz

unread,
Jun 18, 2020, 11:41:16 PM6/18/20
to OpenPnP
Subjectively, a slow motion camera + liquid in a clear glass?

https://www.youtube.com/watch?v=C0XjXqO6Ji8
To unsubscribe from this group and stop receiving emails from it, send an email to ope...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ope...@googlegroups.com.

fšk

unread,
Jun 19, 2020, 9:46:12 AM6/19/20
to OpenPnP
The easiest that comes to mind would be to connect the step and dir outputs from a controller to a logic analyser. 


bert shivaan

unread,
Jun 19, 2020, 9:59:57 AM6/19/20
to OpenPnP
I agree, but that will show the time between pulses. How do we convert that to showing motion?

On Fri, Jun 19, 2020 at 9:46 AM fšk <fsk...@gmail.com> wrote:
The easiest that comes to mind would be to connect the step and dir outputs from a controller to a logic analyser. 


--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.

Arthur Wolf

unread,
Jun 19, 2020, 12:28:19 PM6/19/20
to ope...@googlegroups.com
To dev step generation in Smoothie I simply use a logic analyzer, they are cheap nowadays.



--
勇気とユーモア

Marmelade

unread,
Jun 19, 2020, 4:38:38 PM6/19/20
to OpenPnP
I'm using masking mode on my scope to see the s-shaped move:

scope1.PNG


scope2.PNG

Keith Hargrove

unread,
Jun 21, 2020, 3:28:00 AM6/21/20
to OpenPnP
I thought linuxcnc had it?
As far as i can tell it is the same on modern  camshaft profiles.
In motors it seems to be servos might benefit more than steppers to help with the closed loop drive. Going to hard stop/go can make it oscillate no mater how well the PID is tuned 
I have not done the math but I think you want to look at the G force of the moving parts. 
It has been a very very long time but I think the G force is not 1:1 to acceleration  
And a lot of this it to keep a constant G force on the moving part. The 2nd part to to break free from friction and when friction start to grab. So some of the early parts of the S is to help with that. and 3rd to take up backlash.

Things to note: most curves are mirrored. Most motor controllers only do 1/2 of the curve and just play that back in reverse for the slow to stop. a lookup table is common.
This can be super hard in a CNC as all motors have to be in sync at all times including the spindle so in practice the slowest part drive everything. And no overshoot at all or very bad things happen.
Now for PNP things are very simple any axis needs no info about the others, over shoot is OK as long we are where we need to be when we drop Z but getting there can be what ever. 
I think a simple log until the rate matches the target curve. I think this was done in analoge in the past with just RC networks. Also I think this is bigtime in the life of the system the slow start gives time for gears/belts screw to take up any backlash. Just like the clutch in a car. a hard slam will pound things apart even with the smallest amount of backlash.
Any ways that is my take on it.

I think this shows the the non 1:1 . Or I am off my rocker.. ;)
Acceleration of Gravity and Newton's Second Law

Michael Anton

unread,
Jun 21, 2020, 10:08:57 PM6/21/20
to OpenPnP
Since G force causes the acceleration due to gravity, at 9.8m/s^2, it is exactly one to one with acceleration.  There is drag due to air resistance, so this limits the top speed, which is why during a free fall, you don't continue to accelerate.
Reply all
Reply to author
Forward
0 new messages