Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

S-Curve Equations?

  1. Sep 27, 2010 #1
    S-Curve Equations??

    Hi All,

    Am new to this but here goes.

    I am trying to model a 7 segement S-Curve Motion Profile (see http://en.wikipedia.org/wiki/File:Third-order_motion_profile.svg" [Broken]) with VBA. I am wanting to use a linear encoder value to determine the switching points between the segments.

    I am using the following equations:

    A = A + J * t
    V = V + (A * t) + (0.5 * J * t ^ 2)
    X = X + (V * t) + ((A / 2) * (t ^ 2)) + ((J / 6) * (t ^ 3))

    x = displacement
    v = velocity
    a = acceleration
    j = jerk
    t = time interval

    I am struggling with the final change over from segment 6 to 7 (constant negative acc to non constant negative acceleration) as I want to use distance to Target (X_Target - X) as a trigger.

    The constraints I have are:
    • current velocity (V)
    • final velocity (V_f =0)
    • current acceleration (A)
    • final acceleration (A_f =0)
    • current displacement (X)
    • final displacement (X_f =X_Target)

    The variables are:
    • Time (t)
    • Jerk (J)

    Hope this makes sense.

    Any suggestions/help would be appreciated.

    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Sep 27, 2010 #2
    Re: S-Curve Equations??

    It’s highly probable JayD that I do not operate at your level. I am not an academic, I’m just an engineer who has worked with servo applications. My first impression is that your problem really ought not to be so difficult to solve. The particularities you wish to operate within shouldn’t really present too much difficulty to anyone who is comfortable with a little algebra. There is a fairly generic set of base formulae for specifying an ‘s-curve’ motion profile. Somewhere, I have an Excel spreadsheet I made that allowed me to generate motion profiles from a small number of input parameters. Mine was generating an ‘x-y’ look-up table of master axis position against slave axis position, but again, I think you’ll see quite easily that adapting it to your requirements is not so much of a challenge. The first problem is that, if I remember correctly, I can’t attach an Excel spreadsheet to a post. I may just have to post the base formulae and then, if necessary, work with you to produce the result you need. My second problem is that I don’t have the spreadsheet or the formulae to hand. The information you want is almost certainly out there in motion control text books, and I dare say even on-line somewhere. If you find them, or someone else posts with what you need, then all well and good. If you are interested in what I have, I should be able to supply it later on today.
  4. Sep 27, 2010 #3
    Re: S-Curve Equations??

    Right JayD, I have found all of my old data on S-curves, and inevitably, it’s all a bit more involved than I had remembered – it is nearly ten years since I was actively working on this lot! I not only have spreadsheets, I also have some word documents explaining it all, but as far as I understand, I can’t attach them to a post. Detailing all the formulae using Latex would take a while. I suppose that the first thing I need is some feedback from you on whether you think what I have is of any use to you. Let me just try to explain it as best I can.

    The input parameters are acceleration time, starting velocity, velocity change and smoothing. Now in my case, smoothing was specified as a proportion. A value of zero gave you pure linear acceleration. A value of 1 meant that the increasing acceleration phase would blend directly into the decreasing acceleration phase, with no linear phase at all. A value of 0.5 would mean that the first quarter of the acceleration phase was increasing acceleration, the middle half was linear acceleration and the final quarter was decreasing acceleration. A value of 0.333 would give three phases of equal time. The formulae do allow for a non-zero starting velocity, and do also cope with a profile that begins with deceleration. The acceleration and deceleration phases are purely symmetrical in these profiles, but again adapting it to specify different acceleration and deceleration parameters should not be too hard. From the input parameters the formulae calculate velocity against time and also distance travelled against time.

    Does this sound like it might be useful to you? If so, I’ll try to figure out the most efficient way to communicate it to you.
    Last edited: Sep 27, 2010
  5. Mar 2, 2011 #4
    S-Curve Equations??

    I am also beginner in S-Motion curve. I do know velocity, accl, jerk. i want to know the time t for a particular displacement S. can any one tell me the formula for 7-segment and 5-segment curve.
  6. Mar 3, 2011 #5
    Re: S-Curve Equations??

    hello Ken Natton this is devendra jain. i am beginner in s-motion curve. I just start study on that but finding the proper way to start. i am just referring some website and some ebook. will you pls suggest me a proper way to start the study and can you send me some other document which you have on my mail id
    << e-mail address deleted by Mentors >>

    Thanks in advance and regarda
    devendra jain
    << e-mail address deleted by Mentors >>
    Last edited by a moderator: Mar 3, 2011
  7. Mar 3, 2011 #6
    Re: S-Curve Equations??

    Hi Devendra,

    I have sent some documents to the e-mail address you supplied. I hope they are useful for you! Anything further you wish to discuss, I am happy to do so. And perhaps, in the spirit of the forum we should conduct that discussion here on the forum, in case what we discuss is of interest to anyone else.

  8. Mar 3, 2011 #7
    Re: S-Curve Equations??


    I did not understand fully your question.
    "S-Curve motion" means nothing to me.

    However, I have the feeling that you might be interrested by cubic splines.
    Have a look at these Googlies:

    And specially this extract from NR (http://www.nr.com/" [Broken]):

    If cubic splines is what you need, then you will have no difficulty to find code for that in almost any language, including VBA.
    NR is not available in VBA edition.
    However, the cubic spline routine in NR is very short, and it would not be a big job to translate it.
    (less than 30 lines)

    As an NR fan, I have not used http://www.alglib.net/" [Broken] yet.
    You light enjoy, since a lot is available in various languages including VB6.
    Last edited by a moderator: May 5, 2017
  9. Mar 3, 2011 #8
    Re: S-Curve Equations??

    Not exactly certain of your degree of interest, lalbatros, but here is a paragraph from my document that explains exactly what an 's-curve' is in the context of motion profiling:

    ‘S’ curve is the term used for a velocity profile using smoothed acceleration and deceleration. When no smoothing is applied, wherever the profile changes from constant speed to linear acceleration or deceleration represents a sudden shock application of force. Equally, wherever the profile changes from acceleration or deceleration to constant speed represents a sudden removal of force. If, wherever force is to be applied or removed, it is fed in gradually and pulled back gradually, the velocity profile will form a curve where the force is being applied and removed. This is called smoothing. The resulting curve tends to resemble an approximate ‘S’ shape, hence the term ‘S’ curve.

    Another perspective that perhaps helps to understand it is that, if velocity is rate of change of position in metres per second, and acceleration is rate of change of velocity in metres per second squared, then jerk or smoothing is rate of change of acceleration in metres per second cubed. I think you will see it is something quite different from what you are talking about.
  10. Mar 3, 2011 #9
    Re: S-Curve Equations??

    Thanks for the clarification, Ken.
    If I understand correctly, the discontinuities are shifted from the acceleration to the jerk.
    I think there might be other good reasons to go for cubic splines, specially because of the boundary conditions that they allow.
    Note that I still can't understand what the "trigger" means in the original question.
    I also don't understand what the "linear encoder" is and why it is mentioned, as well as if the "switching points" are those points defining the constant-jerk segments.

    My guess, however, is that the segments (with constant jerk) are not pre-defined and would be determined according to some objectives.
    These hypothetical objectives are unknown to me, and I can't help a lot to solve them.
    Maybe it is about minimizing the time spend on a trajectory, I don't know.
    This reminds me of another https://www.physicsforums.com/showthread.php?t=462501".

    I reacted because I saw a cubic equation for x as well as "7 segments".
    I thought that it was maybe about a piece wise cubic smooth curve,
    and that would be the splines that I used often in the past.

    In addition, I saw that JayD had a problem on a boundary.
    This could be related to solving the boundary conditions for the splines, which is explained in NR (3.3 p 115) .
    If JayD tries that sort of thing for the first time, this may be not totally obvious.
    The algorithm is rather simple and fast, but it might not be so obvious to derive it.

    If a layer of optimization needs to be put on top if the specific problem submitted by JayD, then it might be useful to delay to solution and to see how the whole formulation fits for an optimization.
    Last edited by a moderator: Apr 25, 2017
  11. Mar 25, 2011 #10
    Re: S-Curve Equations??

    1. Could you please share the source for these equations? I am looking for some literature which discusses these equations.

    2. Also, I am wondering why a 7 segment curve is needed. Wouldn't a sinusoidal curve suffice?

    Last edited by a moderator: May 5, 2017
  12. Mar 26, 2011 #11
    Re: S-Curve Equations??

    Well, pfuser01, I suppose the ultimate source is the standard speed / time diagram formulae well known to many a high school physics student:

    [tex]v = u + at[/tex]

    [tex]v^2 = u^2 + 2as[/tex]

    [tex]s = ut + \frac{at^2}{2}[/tex]

    v = final velocity m/s
    u = initial velocity m/s
    t = time s
    a = acceleration m/s^2
    s = distance travelled m

    These formulae would give you a trapezoidal profile. The smoothing portions are essentially parabola and thus specified by the standard quadratic equation

    y = ax^2 + bx + c

    but in this case, x is time and y is velocity of course.

    All the actual formulae are essentially derived from these.

    You could have a sinusoidal profile, that would essentially mean that there was no linear acceleration or deceleration portion, and I suppose no constant velocity portion either. The reason that is not the usual solution is because the imperative to use smoothing does not require that the smoothing is as extreme as that. Linear acceleration and deceleration is not what smoothing seeks to avoid, it is the shock application of force represented by the transitions from constant velocity to acceleration and vice versa that smoothing is intended to avoid. It is perhaps easiest to conceive the force / time diagram. With the trapezoidal speed / time diagram, the force / time diagram is essentially rectangular. When smoothing is employed, the force / time diagram itself becomes trapezoidal. Don’t know if that makes any sense to you.
    Last edited: Mar 26, 2011
  13. Mar 26, 2011 #12
    Re: S-Curve Equations??


    Thanks. I was looking for some motion control book which would also discuss the higher order modes that might result in selecting a certain profile over the other. I am obviously interested in faster settling time.

    Also, if I wasn't clear, the jerk profile will be something like [sine 0 0 0 0 sine]. So, this will result in a constant velocity.

    Thanks again.

  14. Mar 26, 2011 #13
    Re: S-Curve Equations??

    I must confess pfuser01, I have no idea what you mean by that. A constant velocity profile would be a horizontal line.

    And perhaps we are on different wavelengths, but to me settling time would be a question of the tuning of your position control loop. S-curve profiling is simply a question of the position command to that loop.

    I’m afraid I have no books I can recommend. There is some material available on the web.

    http://www.pmdcorp.com/downloads/Mathematics_of_Motion_Control_Profiles.pdf [Broken]

    http://www.pmdcorp.com/news/articles/html/Mathematics_of_Motion_Control_Profiles.cfm [Broken]
    Last edited by a moderator: May 5, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook