Programming S-curve motion profiles

TurkSaleh

Member
Join Date
Dec 2016
Location
Nijmegen
Posts
6
Hello all,

I need to write a code for S-curve motion profiles (7 segments) to control speed of motor via PLC. however, I cannot find the equations applies for each segment. So I need help.
I need to be able to control the time, which means that if I ramp lineary or with S-curve I have to reach the setpoint with same time in both cases.

I know that my drive support this function (Siemens G120) but for my application I have to S ramping inside the PLC.

Regards
 
Hello all,

I need to write a code for S-curve motion profiles (7 segments) to control speed of motor via PLC. however, I cannot find the equations applies for each segment. So I need help.
I need to be able to control the time, which means that if I ramp lineary or with S-curve I have to reach the setpoint with same time in both cases.

I know that my drive support this function (Siemens G120) but for my application I have to S ramping inside the PLC.

Regards


This is too difficult to do in a PLC. There are too many odd ball cases that can occur. Not all moves will have 7 segments. For instance, what if the move is short so that the velocity does not reach the commanded velocity? In that case there is no constant velocity segment but what is the peak velocity? What if the velocity is low so the acceleration does not reach the commanded acceleration? In that case ramping up will only need 2 segments but what will be the peak acceleration? If neither the commanded acceleration or velocity is reached because the move is short then there are only 3 segments but solving this problem is so difficult that only a few have managed to do it correctly.


What happens if the ramp takes 99.3 milliseconds but you are scanning every 1 millisecond? Will your PLC run all the required code in 1 millisecond?
 
This is too difficult to do in a PLC.
It's not too difficult. If the calculation needs 10 seconds but it's needed only every 20 seconds and the movement takes 5 seconds, then it's ok. I all depends on your requirements.

I've seen turbine controls with variable guide vanes done in a S5 where floating point calculation where done in software without hardware support and heron's method square roots, 3d map interpolation, which took 20 seconds for the calculation of the new positions. But if it's ok in this time and you know how to do it and where the limits are, you can do in in a cheap controller.
 
Quote:
Originally Posted by Peter Nachtwey View Post
This is too difficult to do in a PLC.
It's not too difficult

I agree. This is not even remotely “too difficult” to do in a PLC.

You need to calculate your points for time, position, velocity and accel. Depending on the parameters, some of these points may be the same. No big deal. The calculations are much easier if you can live with symmetric jerk and accel values, but it’s certainly possible to do for asymmetric profiles also.

Then run the profile. For each scan, check where you are in time, look up where you are in the profile, and apply the appropriate equation within that segment for the instantaneous velocity. This is your velocity feed forward.

Then compare the expected profile position to the actual position. This is your position error you’ll tune the control loop for. To be honest, proportional gain by itself usually works fine here.

Done.

Edit: this is assuming the PLC can update fast enough for the application. I have some profiles that need to update at 4kHz. Those get offload to drive hardware. And then there are some that can update at between 20 and 100Hz. These are fine in the PLC, although I generally leave out the Jerk term unless I find it’s needed.
 
Last edited:
Let’s see what the OP comes back with.
A G120 is not a servo drive. So he can’t be doing fast moves and high accuracy positioning
 
Let’s see what the OP comes back with.
A G120 is not a servo drive. So he can’t be doing fast moves and high accuracy positioning

I think it’s unlikely that the drive will be the limiting factor if the motion profile is being run in the PLC*.

I do lots of PLC based motion profiles with just open loop drive control on an induction motor. It really depends on the application.

But there aren’t many application details at the moment.

*The exception would be drive communication limitations. There was one VFD from Parker I was trying to use over EtherNet/IP. The motion profile ran at 10ms in the PLC, which was fine for the application...but the drive always lagged by 200+ms. I tried to work with Parker on the issue, but didn’t get anywhere. I added some latency offsets to the motion profile and detuned the speed some. There wasn’t much else I could do with it.
 
This is too difficult to do in a PLC. There are too many odd ball cases that can occur. Not all moves will have 7 segments. For instance, what if the move is short so that the velocity does not reach the commanded velocity? In that case there is no constant velocity segment but what is the peak velocity? What if the velocity is low so the acceleration does not reach the commanded acceleration? In that case ramping up will only need 2 segments but what will be the peak acceleration? If neither the commanded acceleration or velocity is reached because the move is short then there are only 3 segments but solving this problem is so difficult that only a few have managed to do it correctly.


What happens if the ramp takes 99.3 milliseconds but you are scanning every 1 millisecond? Will your PLC run all the required code in 1 millisecond?

I know the Delta controllers are some sweet motion controllers and very fast and capable. We have a RMC150 in one of our machines and I absolutely love the thing. I might love the RMC Tools software even more. When it comes to "motion", I think the Delta controllers with the RMC software are the best, in my opinion. I like the product so much, that I've talked the powers that may be into designing our next machine around the RMC200, married to an "X-brand" PLC.

With all that said, I don't think a PLC is incapable. It mainly depends on the PLC and the communications protocol being used. For instance, we have a machine that does not use a dedicated motion controller. It just has one PLC that does everything - machine control, IO, motion, high speed data acquisition, NVH analysis. In there, I have a task set up that I've dedicated for motion only, and set for 100µS scan time (10 kHz). I've got what I feel is a fairly good amount of code in that task, along with several motion commands, function block calls, For Loops, and it all executes without a problem, never overrunning the task time. I haven't had an opportunity yet, but one of these days I'll set the task for 50µS scan time (20 kHz), just to see if it can still do it without overrunning. It should also be noted that the communications protocol used is EtherCAT.
 
Last edited:
Long moves are easy because the target trajectory will reach the command acceleration and velocity. But what do you do when the command acceleration and velocity are not reached.


There was a thread over a year ago where cheeco ( a German engineer working for ESA in Lieden NL ) showed off some of his software for generating optimal motion profiles using 3rd order polynomial segments. Initially I found a bug which Cheeco corrected quickly.



Cheeco is the only person to solve what I call the "problem from hell" correctly besides me. It is a test I do on competitor controllers to see how good they are. The test is to go from any PVA ( position, velocity, acceleration ) to any PVA in optimal time. This is usually easy unless the commanded velocity and acceleration are not reached.



This problem is so difficult that a professor from Fordham University used my example problem in one of his presentations. His program, Fermat, could solve the problem but the answer is too long to solve in real time.



Mathematica can also solve the problem but the answer is not usable because it takes too long to execute.


Search the forum for Cheeco. There are two threads.


I have a program that will test combinations of moves from any starting PVA to any destination PVA. I ran 200 trillion iterations or combinations of moves. When I started out I found lots of flaws. I save the moves that found the flaws in my software. Finally I ran 200 trillion moves without flaws. I know how to find the flaws in motion controllers.

Delta is going to add Ethercat capability sometime this year. It will be used mostly to control output devices like valves and drives.
The problem I have with Ethercat is that the packets are essentially CAN Open packets on Ethernet. The CAN Open packets have 8 bytes of data. 8 bytes permit sending a 32 bit float and some command bits that tell what the float is. Usually the float is a position. While it is possible to move from position to position every 50 microseconds there is no feed forward data or target velocity and acceleration, just a target position. This is why I think Ethercat is great for sending output values to valves and drives but not so good for sending motion profiles to multiple controllers.
 
...I cannot find the equations applies for each segment. So I need help.

The Google appears to have many answers for the OP:

xxx.png
That neither solves the edge cases many are bringing up, nor tells the OP whether any of OP's (as yet undeclared) constraints put the problem beyond what OP's (as yet undefined) PLC can do, but it does answer the question in the OP.
 
Thanks for all of you.

Its good to give more details. I use Siemens 1515 CPU and the drive also from Siemens (G120).
My application is simple and should be achievable. the ramp up/down time will be 20sec + and for this application, the setpoint will not change during the ramp up/down. The drive has the extended ramp function, which what I need to achieve but inside the PLC. the extended ramp function has the option to setup initial and final rounding time. so instead of having linear ramping, it will ramp with s-curve.
I have found few SRamp functions such as the one from oscat library. but what I see from these functions that the time is not a setpoint that can be set. It always needs basic experience to achieve what required. means that its difficult for the operator if he wants to change the ramping time.

@Peter Nachtwey I found the discussion between you and Checco, although its very advanced for my application but it would be nice if I can program it. btw, the links are not working.
 
@Peter Nachtwey I found the discussion between you and Checco, although its very advanced for my application but it would be nice if I can program it. btw, the links are not working.

If you are starting from a velocity of zero and stopping at a velocity of zero, you do not need everything Peter is referencing. It’s ridiculous and overkill for that type of application.

If the the parameters can change, then you do have to check if the maximum velocity can be reached and (if not) additionally whether the maximum accel can be reached. But once you have the maximum velocity and accel for the profile, you can calculate the profile points from there. If either the velocity or accel get limited, then one or more segments will drop out and some of the points will be the same.

You probably need some understanding of basic calculus to do this task though.
 
My application is simple and should be achievable. the ramp up/down time will be 20sec + and for this application, the setpoint will not change during the ramp up/down. The drive has the extended ramp function, which what I need to achieve but inside the PLC.

Do you actually have to run a motion profile or do you just need to generate a speed reference as an s-ramp from the PLC? Can you provide more information about the actual application?
 
Is the application jerk-limited or acceleration-limited?


The OP mentions 7-segment profiles, which implies the former.
 

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,639
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,857
I'm been deciphering a program for a press here. I've gotten most of it deciphered using the manual to understand the instructions (first mitsu...
Replies
2
Views
22
Hello colleagues, Some time ago I started my adventure with programming. With your help and the courses, things are starting to come together...
Replies
13
Views
594
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
82
Back
Top Bottom