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. 
May 24th, 2007, 05:26 PM  #1 
Member
Join Date: Jan 2006
Location: minnesota
Posts: 66

scurve math?
Hello,
I’m using a mircologix 1100 and an analog (010 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 scurve math formula to control motion? 
May 24th, 2007, 05:40 PM  #2 
Member
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 
May 24th, 2007, 06:07 PM  #3 
Lifetime Supporting Member

The SCurve 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 (EndingSetpointStartingSetpoint) * 2 * RampTime/ElapsedTime * RampTime/ElapsedTime + StartingSetpoint. Second half equation  while Elapsedtime > RampTime/2 (EndingSetpointStartingSetpoint) * (1  2 * (RampTimeElapsedTime)/RampTime * (RampTimeElapsedTime)/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. 
May 24th, 2007, 08:11 PM  #4 
Member

What is needed is a scurve index into the SCP instead of the timer like this:
Code:
frac = time/ramp_time; f=(32*frac)*frac*frac; Simple. Fifth order polynomials cost extra. 
May 24th, 2007, 09:06 PM  #5 
Lifetime Supporting Member

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: (EndingSetpointStartingSetpoint) * 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. 
May 25th, 2007, 08:50 AM  #6 
Member
Join Date: Jan 2006
Location: minnesota
Posts: 66

Awesome folks,
I knew I came to the right place! Thank you. 
May 25th, 2007, 09:33 AM  #7 
Member

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. 
June 26th, 2011, 01:07 PM  #8 
Member
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 (EndingSetpointStartingSetpoint)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 
June 26th, 2011, 03:07 PM  #9  
Member

Quote:
Quote:
Quote:
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:
Quote:
Velocity=StartingVelocity*(1f)+EndingVelocity*f RampTime=RampTimeFrom0toConstantVelocity*(Constant VelocityStartingVelocity)/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 

June 26th, 2011, 03:54 PM  #10  
Member
Join Date: Sep 2005
Location: UK
Posts: 879

Quote:
Quote:


May 9th, 2012, 12:38 AM  #11 
Member
Join Date: May 2012
Location: Mumbai
Posts: 2

S curve Maths
scurve math:
What are the different parameter in following equation. frac = time/ramp_time; f=(32*frac)*frac*frac; 
May 9th, 2012, 02:05 AM  #12 
Member

Everything needed is posted above.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon 
May 9th, 2012, 02:20 AM  #13 
Member
Join Date: May 2012
Location: Mumbai
Posts: 2

S curve Maths
frac = time/ramp_time;
f=(32*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. 
May 9th, 2012, 12:21 PM  #14  
Lifetime Supporting Member

Quote:


August 17th, 2015, 05:26 PM  #15 
Lifetime Supporting Member
Join Date: May 2014
Location: Texas
Posts: 496

Curiosity Bump
I'm working on a similar Scurve 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. 
Bookmarks 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


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 