Programming S-curve motion profiles

  • One of many possible approaches
  • Only solves for 7-segment-capable cases
  • If t56 is negative, invert sign of all PVA knowns and repeat (I think)
  • There will almost certainly be at least one sign error, but the basic form is correct.
xxx.pngQED
 
  • One of many possible approaches
  • Only solves for 7-segment-capable cases
  • If t56 is negative, invert sign of all PVA knowns and repeat (I think)
  • There will almost certainly be at least one sign error, but the basic form is correct.
View attachment 57845QED
Those 7 equations for position are correct but you need to compute the times too. t56 should always be positive unless the deceleration rate is so low that the peak decel ( negative accel ) is not reached. In that case t56 is 0 and that segment does not exist. The same can happen with t12.
t34 could be 0 too. In that case the there is no constant velocity segment. What is the peak velocity that is reached?
 

As should be obvious, peak velocity magnitude is V, the max input parameter, because that formula as written is only for the easy cases (non-negative values for t34, t12, t56): where there is a variable time (t34) at a velocity with a magnitude of V, and max accel/decel (+/-A) is always reached (t12 and t56, as initially calculated, are non-negative).

As should also be obvious, that post is not meant to solve the general cases; it was only meant to end the persistent requests for 17 equations. Deriving optimal solutions for all general case is based on those 17 equations, or a subset of same, plus a boatload of bookkeeping.

Look at the [Order of solution] box in the lower right: I did compute the times; the times are the only outputs used for a seven-segment profile.

If t34 (not t56 - there is a typo in post #31) is negative, it means one of two things:

  1. The 7-segment profile should start with a negative jerk instead of positive, which is why I said invert the sign of the PVA inputs.
  2. It needs to limit the peak velocity i.e. it's a 5- or 3-segment profile (jerk=+J,0,-J,0,+J and t34=0 and t23 is combined with t45, or jerk=+J,-J,+J and t12=t34=t67=0 and t23 is combined with t45).
It should be possible to figure out whether to start with a negative or positive jerk, but inverting the PVAs is probably simpler to code.


t56 and or t12 could also be negative, especially if peak velocity magnitude is less than parameter V.


Oh, and by the way, there are only four equations:


xxx.png


The rest is bookkeeping.
 
Deriving optimal solutions for all general case is based on those 17 equations, or a subset of same, plus a boatload of bookkeeping.
The problem is too hard for most to solve by hand but it can be done. However, you should use the simply package of python.

If t34 (not t56 - there is a typo in post #31) is negative, it means one of two things:

  1. The 7-segment profile should start with a negative jerk instead of positive, which is why I said invert the sign of the PVA inputs.
  2. It needs to limit the peak velocity i.e. it's a 5- or 3-segment profile (jerk=+J,0,-J,0,+J and t34=0 and t23 is combined with t45, or jerk=+J,-J,+J and t12=t34=t67=0 and t23 is combined with t45).
It should be possible to figure out whether to start with a negative or positive jerk, but inverting the PVAs is probably simpler to code.
When moving in the positive direction the INITIAL jerk should always be positive.
t12, t34, t56 can NEVER be negative. If you get a negative solution for t34 that means segment 4 doesn't exist and the commanded velocity is not reached.

The only case the initial jerk should be negative is if the actuator needs to slow down. This happens when a command is given while moving. We haven't even touched calculating/changing motion profiles on-the-fly.

Oh, and by the way, there are only four equations:
NO! I listed the 17 unknowns above. You need 17 equations to solve for the 17 unknown and that solution only works for the case where all 7 segments exist.
The target generator must determine which segments will exist and each case will require a different set of equations.

You guys should know I am trolling all of you because of the comments about how easy this should be to program in a PLC.

A good motion controller is much more than a PID between an encoder or MDT rod and an output. The PID and feed forward parts are such a small part of the program. It is the target generator that really separates the the good, the bad and the ugly.
 
You guys should know I am trolling all of you because of the comments about how easy this should be to program in a PLC.

Yep, we figured that much. :ROFLMAO: I certainly trust what you're saying Peter. You know way more about motion than I do, or probably anyone else here!! I wasn't one that suggested it was easy, only that I believe a PLC is capable, depending on the PLC being used. That doesn't necessarily mean I think its "easy" with a PLC. It's one of the reasons on our next machine build, I'm going with an RMC controller married with a PLC. That, and the RMC software makes it so much easier for a technician to create his/her own programs without me having to write PLC code and/or create special software for them, every time they require a new motion program, which will be rather frequently.

I love the product. If/when it gets full EtherCAT support, it will be perfect. But not until then. :). Oh, and being able to create motion programs, add/omit motion commands via .NET would be really nice too. :)
 
Last edited:
Oh, and by the way, there are only four equations:
Troll complete. Thank you ;).

Peter, you really gotta come to Rochester some time so we can meet.

Although to be fair, those integrals, plus the discrete jerk function, do represent the same system and are the basis for the 17 equations. And OP did say it was great to know the math and physics. That said, I agree the integrals are in a somewhat less than solvable form.
 
busarider said:
only that I believe a PLC is capable,
Obviously the OP found a solution but it is not perfect and is not optimal. I started a thread over a year about PLC vs motion controllers over a year ago where I listed many reasons one should use a motion controller. I/we often get asked, "can your motion controller do this"
My first thoughts are can you? Can you designed a machine that will do this or that?

BTW, do you know about RMCLink? It is a .NET assembly that lets you program the RMC using Excel, C, Visual Basic, python etc.

drbitboy said:
Peter, you really gotta come to Rochester some time so we can meet.
We can meet using Skype. We can share screens. I did this MANY Saturday mornings with forum member Pandiani. We would often talk for an hour or more. Pandiani first came to the forum when he was a college student. He had a control problem that I knew that was contrived. I helped him through getting his masters degree. He now is in charge of the controls for the power plants in Tuzla, Bosnia. Pandiani bought Mathcad and has followed me on my Peter Ponders PID YouTube channel.

Although to be fair, those integrals, plus the discrete jerk function, do represent the same system and are the basis for the 17 equations. And OP did say it was great to know the math and physics. That said, I agree the integrals are in a somewhat less than solvable form
The problem is how do you generate the 17 equations?

I said at the beginning of this thread that only Cheeco's 3rd order target generator has passed my tests.
 
busarider said:
only that I believe a PLC is capable,
Obviously the OP found a solution but it is not perfect and is not optimal. I started a thread over a year about PLC vs motion controllers over a year ago where I listed many reasons one should use a motion controller. I/we often get asked, "can your motion controller do this"
My first thoughts are can you? Can you designed a machine that will do this or that?

BTW, do you know about RMCLink? It is a .NET assembly that lets you program the RMC using Excel, C, Visual Basic, python etc.

drbitboy said:
Peter, you really gotta come to Rochester some time so we can meet.
We can meet using Skype. We can share screens. I did this MANY Saturday mornings with forum member Pandiani. We would often talk for an hour or more. Pandiani first came to the forum when he was a college student. He had a control problem that I knew that was contrived. I helped him through getting his masters degree. He now is in charge of the controls for the power plants in Tuzla, Bosnia. Pandiani bought Mathcad and has followed me on my Peter Ponders PID YouTube channel.

Although to be fair, those integrals, plus the discrete jerk function, do represent the same system and are the basis for the 17 equations. And OP did say it was great to know the math and physics. That said, I agree the integrals are in a somewhat less than solvable form
The problem is how do you generate the 17 equations?

I said at the beginning of this thread that only Cheeco's 3rd order target generator has passed my tests.
 
BTW, do you know about RMCLink? It is a .NET assembly that lets you program the RMC using Excel, C, Visual Basic, python etc.

Yes, I'm aware of RMC Link and I have used it on one machine that we have with an application that is interfacing with the RMC controller. That is how, as far as I know and last I checked, there is no mechanism/method for adding and or omitting steps in a RMC program via .NET. Mistakenly, I didn't specify that in my last post, but that is what I was referring to. Not a big deal and certainly not a deal breaker by any means, just something that would be a "nicety" for Delta to add to their RMC Link library, if its possible.

There is sort of a workaround, but ehhh......not really going to work for what I was hoping for.
 
You mean only for a full 7- or 5-segment move, right?

I am pretty sure I was wrong that changing the signs would be a cheap trick to deal with a negative initial jerk.
Short moves require only 3 segments.


Below is a .png of the directory of all the different cases a 3rd order motion target generator must handle to be complete.
Part of the trick is determining which case applies to the current situation.

seg.png
 
Short moves require only 3 segments.


Hey, a really short move could require but one segment.


But anyway, to ask again, that rule about the initial jerk always being in the direction of the move (I assume Pfinal > Pinitial is a positive move), applies to

  • 7-segment moves (+J,0,-J,0,-J,0,+J)
  • 5-segment moves (+J,0,-J,0,+J) i.e. 7-segment with middle 0 (t34) dropped out and t23 and t45 combined
  • 3-segment move (+J,-J,+J) i.e. 5-segment with remaining 0s dropped out
Somehow that rule does not seem (to me*) like it should be universal, if PVAintial and PVAfinals can be anything.


* That said, I have not come up with a counter case yet.
 
... heron's method square roots, 3d map interpolation, ...you can do in in a cheap controller.
I've used a lookup table with 1024 entries for square roots. If the input is > 1024 then you simply scale up the inputs an outputs by factors of 4 and 2 (i.e by bit shifting) It's all integer arithmetic, but the encoder is only integer after all.
 

Similar Topics

Hey everyone, I have a sensor that gives a 4 - 20 mA signal that is not perfectly linear. There is a bit of a curve in it. I would like to hook...
Replies
27
Views
4,751
Does anyone can explain me how to do s-curve (for increasing and decreasing speed of the process ) programming in siemens simatic S7. If...
Replies
1
Views
1,884
Dear all, I have fx2n plc on my hand but I don't have the programming cable sc-09 and it would not be easy for me to get one. I need the cable...
Replies
3
Views
98
Hi all, i am the new controls guy at the plant and i have inherited a pc from the previous controls guy with Siemens tia portal version 16 and 17...
Replies
20
Views
874
I need to pull the program off of an old 90-30 so I can convert it to Allen Bradley. This is my first time messing with GE and I don't have the...
Replies
2
Views
84
Back
Top Bottom