You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old May 24th, 2007, 05:26 PM   #1
blperkins
Member
United States

blperkins is offline
 
Join Date: Jan 2006
Location: minnesota
Posts: 66
s-curve math?

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?



  Reply With Quote
Old May 24th, 2007, 05:40 PM   #2
CharlesM
Member
United States

CharlesM is offline
 
Join Date: Aug 2005
Location: Arkansas
Posts: 1,129
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
  Reply With Quote
Old May 24th, 2007, 06:07 PM   #3
TConnolly
Lifetime Supporting Member
United States

TConnolly is offline
 
TConnolly's Avatar
 
Join Date: Apr 2005
Location: Salt Lake City
Posts: 6,152
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.
__________________
True craftsmanship is only one more power tool away.

That's the beauty of processors, they don't have emotions they just run code - The PLC Kid.
  Reply With Quote
Old May 24th, 2007, 08:11 PM   #4
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: United Welfare States of America
Posts: 7,446
What is needed is a s-curve index into the SCP instead of the timer like this:
Code:
frac = time/ramp_time;
f=(3-2*frac)*frac*frac;
f goes from 0 to 1. Now use f to index into the SCP instruction.
Simple.

Fifth order polynomials cost extra.
  Reply With Quote
Old May 24th, 2007, 09:06 PM   #5
TConnolly
Lifetime Supporting Member
United States

TConnolly is offline
 
TConnolly's Avatar
 
Join Date: Apr 2005
Location: Salt Lake City
Posts: 6,152
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:



Peter's solution:


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
__________________
True craftsmanship is only one more power tool away.

That's the beauty of processors, they don't have emotions they just run code - The PLC Kid.
  Reply With Quote
Old May 25th, 2007, 08:50 AM   #6
blperkins
Member
United States

blperkins is offline
 
Join Date: Jan 2006
Location: minnesota
Posts: 66
Awesome folks,

I knew I came to the right place!

Thank you.
  Reply With Quote
Old May 25th, 2007, 09:33 AM   #7
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: United Welfare States of America
Posts: 7,446
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.
  Reply With Quote
Old June 26th, 2011, 01:07 PM   #8
STL???
Member
United Kingdom

STL??? is offline
 
Join Date: Sep 2005
Location: UK
Posts: 879
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
  Reply With Quote
Old June 26th, 2011, 03:07 PM   #9
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: United Welfare States of America
Posts: 7,446
Quote:
Originally Posted by STL??? View Post
Ramping down from full speed
you could utilize the same formula but decrease the time?
That is what the ramptime parameter is for.

Quote:
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.


Quote:
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.

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

Quote:
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*(Constant Velocity-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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old June 26th, 2011, 03:54 PM   #10
STL???
Member
United Kingdom

STL??? is offline
 
Join Date: Sep 2005
Location: UK
Posts: 879
Quote:
This should give you a good start.
Thanks for replying Peter.

Quote:
Let us know how it turns out and how long it took to implement.
no real application yet - just trying to improve my knowledge.
  Reply With Quote
Old May 9th, 2012, 12:38 AM   #11
J sam
Member
India

J sam is offline
 
Join Date: May 2012
Location: Mumbai
Posts: 2
S curve Maths

s-curve math:

What are the different parameter in following equation.

frac = time/ramp_time;
f=(3-2*frac)*frac*frac;
  Reply With Quote
Old May 9th, 2012, 02:05 AM   #12
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: United Welfare States of America
Posts: 7,446
Quote:
Originally Posted by J sam View Post
s-curve math:

What are the different parameter in following equation.

frac = time/ramp_time;
f=(3-2*frac)*frac*frac;
Everything needed is posted above.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old May 9th, 2012, 02:20 AM   #13
J sam
Member
India

J sam is offline
 
Join Date: May 2012
Location: Mumbai
Posts: 2
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.
  Reply With Quote
Old May 9th, 2012, 12:21 PM   #14
Lancie1
Lifetime Supporting Member
United States

Lancie1 is offline
 
Lancie1's Avatar
 
Join Date: Jul 2003
Location: Alabama
Posts: 9,999
Quote:
& what is frac= is factorial?
frac = time/ramp_time (or "fraction = time divided by ramp time".
  Reply With Quote
Old August 17th, 2015, 05:26 PM   #15
JeremyM
Lifetime Supporting Member
United States

JeremyM is offline
 
Join Date: May 2014
Location: Texas
Posts: 496
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 by JeremyM; August 17th, 2015 at 05:59 PM.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
ControlLogix 5000 Minor Math Fault Question rdrast LIVE PLC Questions And Answers 5 August 2nd, 2012 01:27 AM
math errors drewcrew6 LIVE PLC Questions And Answers 2 December 18th, 2006 08:21 AM
Wanting to do math on analog inputs scout76 LIVE PLC Questions And Answers 2 July 2nd, 2006 10:23 PM
simple math with DL06 qlingtime LIVE PLC Questions And Answers 5 June 14th, 2005 08:54 AM
SLC 5/04 Math Error Brian S LIVE PLC Questions And Answers 5 August 26th, 2004 03:20 PM


All times are GMT -4. The time now is 10:49 PM.


.