s-curve math?

blperkins

Member
Join Date
Jan 2006
Location
minnesota
Posts
73
Hello,



I’m using a mircologix 1100 and an analog (0-10 vdc) output card to control the speed reference on a dc motor. Normally I use a SCP and TIMER to increment the speed reference I send out.





Does anybody use an s-curve math formula to control motion?



 
Thats how I do it as well. We have some motion control & process people here that should be able to give you some more ideas.

Welcome
 
The S-Curve is most easily done in your ML by using two different equations as a third order polynomial will be a processor hog.

Divide the overall ramp time in half and use the first equation on the first half of the ramp and the second equation on the second half of the ramp.

First half equation - while ElapsedTime < RampTime/2
(EndingSetpoint-StartingSetpoint) * 2 * RampTime/ElapsedTime * RampTime/ElapsedTime + StartingSetpoint.

Second half equation - while Elapsedtime > RampTime/2
(EndingSetpoint-StartingSetpoint) * (1 - 2 * (RampTime-ElapsedTime)/RampTime * (RampTime-ElapsedTime)/RampTime) + StartingSetpoint.

[robot]Danger Will Robinson:[/robot] There is a strong possibility of dividing by zero and faulting your processor (read: bad) if you don't check to make sure that RampTime and ElapsedTime are greater than 0 before executing either of these equations.
 
Peter's solution is a lot easier to write.

That is much simpler. I plotted the two and this is what I got:

My solution:
A52407-2.JPG



Peter's solution:
A52407-1.JPG


As you can see they are very similar, though not identical, but Peter's is much easier to code. I'm definitely making a note of that.


PS, the first half equation from my previous post should read:
(EndingSetpoint-StartingSetpoint) * 2 * ElapsedTime/RampTime * ElapsedTime/RampTime/ + StartingSetpoint.

My lysdeixa must have gotten the better of me ;)
 
Nice graphs and comparison.

Two other things to check when using a ramping scheme algorithm
1. What is the peak acceleration? We judge this as the ratio of the peak to average acceleration. If the peak acceleration is too high the torque/acceleration/force limits could be exceeded.
2. What are the values of the derivatives at the end points, the first derivative ( acceleration ) should be zero. Higher order polynomials allow one to have the jerk be zero too. Think of smooth elevator moves where you barely know you are starting and stopping.
 
Dig up from the Archives!!

Thanks to Alaric & Peter for their posts.

I wrote a little test program using Peters simpler formula which works perfectly.

I'm a motion novice and was wondering how you could apply this to a real application which wasn't using servo's and positioning was done via PLC.

Some of my thoughts

Ramping down from full speed
you could utilize the same formula but decrease the time?

Target position close to current position
terminate the rampup prematurely and then move the accumulated time into the rampdown time?

I noticed Alaric's method utilises (EndingSetpoint-StartingSetpoint)in the equation - but how to utilize similar with peters equation?

Compensation for loadswinging
allow more time - more gentle Ramp?

Minimum Speed
Not necessary to start from 0Hz each time?

I'm thinking i need to factor in the current speed, braking distances and a window tolerance etc

I'm i thinking along the right lines? if not could someone give me a nudge in the right direction?

Thanks
 
Ramping down from full speed
you could utilize the same formula but decrease the time?
That is what the ramptime parameter is for.

Target position close to current position
terminate the rampup prematurely and then move the accumulated time into the rampdown time?
This gets complicated unless starting from a velocity and acceleration of 0. If starting from 0 speed and acceleration then the ramp time up and down is the total move distance divided by the peak velocity.


I noticed Alaric's method utilises (EndingSetpoint-StartingSetpoint)in the equation - but how to utilize similar with peters equation?
You simply need to compute the ramp time from the velocity and the ramp distance. I would use this formula
ConstantVelocity=1.5*MoveDistance/MoveTime
RampTime=MoveTime/3
The motion profile will spend 1/3 of the time ramping up, 1/3 of the time at constant velocity and 1/3 of the time ramping down. The ramp distance will be 1/4 of the total distance and the distance traveled at constant velocity will be 1/2 the total distance.

Compensation for loadswinging
allow more time - more gentle Ramp?
Just make the ramp time and move time longer.

Minimum Speed
Not necessary to start from 0Hz each time?
Assuming that the initial acceleration is 0 then

Velocity=StartingVelocity*(1-f)+EndingVelocity*f

RampTime=RampTimeFrom0toConstantVelocity*(ConstantVelocity-StartingVelocity)/ConstantVelocity.

The math becomes much more complicated if the inital or final accelerations are not 0.

This should give you a good start. Let us know how it turns out and how long it took to implement.
 
S curve Maths

s-curve math:

What are the different parameter in following equation.

frac = time/ramp_time;
f=(3-2*frac)*frac*frac;
 
S curve Maths

frac = time/ramp_time;
f=(3-2*frac)*frac*frac;

This is easiest method to plot the S curve as per your solution.

I want to know How this formula has been derived.
constants 3 & 2 derived from ? & what is frac= is factorial?
f is frequency?
why it is multilpied 2 times frac.
 
Curiosity Bump

I'm working on a similar S-curve with ControlLogix - is there a shortcoming by rolling my own general logistic function, providing raw output with a single CPT instruction? Mathematically this works, but I haven't the hardware on hand yet to measure the scan time impact.

This can be called on RTC pulses at selected intervals to tune output resolution and scan times, I suppose.
 
Last edited:

Similar Topics

Hello everyone, this is my first question in this forum and I'm still learning about these matters. I apologize if I make any mistakes. I am...
Replies
28
Views
4,224
Hi The pump smart PS220 VFD has the ability to estimate pump flow based of pump characteristics and measured motor data. The calculations...
Replies
12
Views
3,694
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...
Replies
56
Views
16,742
Does anyone know of an Add-On Inst. or PAX Block that can be used to develop a characteristic curve? I have a Variable Speed Pump with a Current...
Replies
13
Views
2,617
Hello Forum, I am developing a Pump Control System and one of the most important modes of operation, is to keep the Pump operating inside it's...
Replies
36
Views
14,896
Back
Top Bottom