Project: ArangoDB (App Definition and Development / Database)
File: stepper-motor.pdf

(http://www.designcon.com/santaclara/?_mc=AD_DC16_BCS_RBN)
(http://www.embedded.com)CONTACT US (/CONTACTUS) • SUBSCRIBE TO NEWSLETTERSSUBSCRIBE TO NEWSLETTERS loginregisterDEVELOPMENTESSENTIALS & EDUCATIONCOMMUNITYARCHIVESABOUT USSearch
>>>>Home (/)MCUs, Processors & SoCs Development Centers (/development/mcus-processors-and-socs)Design How-To (/development/mcus-processors-and-socs/articles)
4Tweet
 (mailto:?subject=Generate stepper-motor speed proﬁles in realtime&body=http://www.embedded.com/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-proﬁles-in-real-time)Generate stepper-motor speedproﬁles in real timeDavid AustinDavid AustinDECEMBER 30, 2004
A new algorithm for stepper-motor acceleration allows speed proﬁles toA new algorithm for stepper-motor acceleration allows speed proﬁles tobe parameterized and calculated in real time. This algorithm can run on abe parameterized and calculated in real time. This algorithm can run on alow-end microcontroller using only simple ﬁxed-point arithmeticlow-end microcontroller using only simple ﬁxed-point arithmeticoperations and no data tables. It develops an accurate approximation foroperations and no data tables. It develops an accurate approximation forthe timing of a linear ramp with constant acceleration and deceleration.the timing of a linear ramp with constant acceleration and deceleration.It's commonly thought that the timing of a linear speed ramp for a stepper motor istoo complex to be calculated in real time. The exact formula for the step delay is inEquation 8. The solution has been to store the ramp data in precompiled arrays, butthis method is inflexible and wastes memory. The alternative has been to use amore powerful and expensive processor than otherwise needed or a high-levelstepper-control IC. This article develops an accurate approximation that has beenimplemented in C using 24.8 fixed-point arithmetic on a mid-range PICmicrocontroller.Motor step signals can be generated by a 16-bit timer-comparator module ascommonly integrated in microcontrollers. On the PIC, the CCP(capture/compare/pwm) performs this function. It allows steps to be timed to theresolution of one timer period. Each step advances the motor by a constantincrement, typically 1.8 degrees on a hybrid stepper motor.Share
25LikeLike
SPONSOR VIDEO, MOUSEOVER FOR SOUNDSPONSOR VIDEO, MOUSEOVER FOR SOUNDMOST READ06.26.2007Building Bare-Metal ARM Systemswith GNU: Part 1 - Getting Started(/design/mcus-processors-and-socs/4007119/Building-Bare-Metal-ARM-Systems-with-GNU-Part-1--Getting-Started)12.30.2004
The timer frequency should be as high as possible while still allowing long delays asthe motor is accelerated from stop. A timer frequency of 1MHz has been used. Amaximum motor speed of 300rpm is then equivalent to a delay count of 1,000. It'snecessary to have high timer resolution to give smooth acceleration at high speed.Notation and basic formulasNotation and basic formulasDelay (sec) programmed by timer count c:
 Equation 1f = timer frequency (Hz).Motor speed ω (rad/sec) at fixed timer count c:
 Equation 2α = motor step angle (radian).1rad = 180/π = 57.3deg. 1rad/sec = 30/π = 9.55rpm.Acceleration ω' (rad/sec2) from adjacent timer counts c1 and c2:
 Equation 3Equation 3 assumes fixed-count speed (Equation 2) at the midpoint of each stepinterval (Equation 1), as on a linear ramp, Figure 1. Note that ω' resolution isinversely proportional to the cube of the speed.
Figure 1: Figure 1: Ramp geometry: move of Ramp geometry: move of m=12 steps=12 stepsLinear speed ramp—exactLinear speed ramp—exactOn a linear ramp, acceleration ω' is constant, and speed ω(t) = ω'.t. Integration givesthe motor shaft angle θ(t):
 Equation 4n ≥ 0 step number (real). When the shaft is at θ = n.α, (integer n) it's time for thenth step pulse:
 Equation 5The exact timer count to program the delay between the nth and (n+1)th pulses (n≥ 0) is:  
 (/videos)video library (/videos)Generate stepper-motor speedproﬁles in real time(/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-proﬁles-in-real-time)10.31.2013Altera’s Stratix 10 makes Cortex-A53 an extreme performanceplayer (/electronics-news/4423607/Altera-s-Stratix-10-makes-Cortex-A53-an-extreme-performance-player)
MOST COMMENTEDEMBEDDED (/VIDEOS)TV (/VIDEOS)
 Equation 6The initial count c0 factorizes out to give Equations 7 and 8:
 Equation 7
 Equation 8Note that c0 sets the acceleration, proportional to (1/c0)2 .In real-time, Equation 8 would require calculation of a square-root for each step,with the added problem of loss of precision by subtraction.Approximating linear rampApproximating linear rampRatio of successive exact timer counts from Equation 8:
 Equation 9Taylor series:
 Equation 10Equation 11 is the second-order approximation to Equation 9 using Equation 10:
 Equation 11Equation 11 can be rearranged for faster calculation:
 Equation 12Finally, we can disconnect the physical step number, i, from the step number n on aramp from zero, to give the general-purpose ramp algorithm shown in Equation 13.Here n determines the acceleration and increments with i for constant acceleration.To ramp up from stop, ni = i, i=1,2, . . . :
 Equation 13Negative n-values give deceleration. In particular, Equation 14, with ni = i - m, canbe used to ramp any speed down to stop in the final steps of a move of m steps:Datasheets.com(http://www.datasheets.com)Currently no itemsRELATED CONTENT12.30.2004 | DESIGNGenerate stepper-motor speedproﬁles in real time(/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-proﬁles-in-real-time)11.01.2010 | SOURCE CODEMotor.c(/design/embedded/source-code/4210291/Motor-c)03.18.2005 | DESIGNTricks with PICs(/design/prototyping-and-development/4006445/Tricks-with-PICs)08.07.2007 | NEWSMicrochip launchessemiconductor Wiki (/electronics-news/4135755/Microchip-launches-semiconductor-Wiki)04.01.2009 | DESIGNLinear motor control without themath (/design/prototyping-and-development/4008259/Linear-motor-control-without-the-math)PARTS SEARCH
185 MILLION SEARCHABLE PARTSKNOWLEDGE CENTERpowered by DataSheets.com  Equation 14Table 1: Table 1: Accuracy of the step-delay approximationAccuracy of the step-delay approximationStep nExact (9)Approx (11)Relative error10.41420.60000.448520.76730.77780.013630.84300.84620.0037040.88100.88240.0015250.90410.90487.66E-460.91960.92004.41E-4100.95110.95129.42E-51000.99500.99509.38E-81,0000.99950.99959.37E-11Accuracy of approximationAccuracy of approximationTable 1 shows that the approximation is accurate even at low step number n andrelative error decreases with n3. However, n=1 has a significant inaccuracy. Theinaccuracy at n=1 can be handled in two ways:Treat n=1 as a special case. Using c1 0.4056 c0 compensates for theinaccuracies at the start of the ramp and allows Equation 7 to be used tocalculate c0.Ignore the inaccuracy. In place of Equation 7 use Equation 15:
 Equation 15The first alternative gives an almost perfect linear ramp. The second alternativestarts with a fast step. This is to the good, as it helps keep the motor movingbetween step pulses 0 and 1-and establishes the angle error needed to generatetorque. It also allows a wider range of accelerations to be generated with a 16-bittimer and has the advantage of simplicity. It's therefore recommended to ignore theinaccuracy at n=1.
Figure 2: Stepper-motor speed rampFigure 2: Stepper-motor speed rampFigure 3: Start of ramp detailFigure 3: Start of ramp detail
Figure 4: End of ramp detailFigure 4: End of ramp detailFigures 2 through 4 compare the options for a target ramp from 0 to 120rpm in1sec. For clarity, step changes in speed are shown, calculated from Equation 2. Thetrue profile should be close to a straight line.2.c/(4.n+1) in Equation 12 could be approximated by c/2.n. Some effects would be:The algorithm would still produce a linear ramp.c0 would be closer to the "exact" value shown in Equation 7: 88.6%instead of 67.6% for the same ramp acceleration.A single equation like Equation 13 could no longer be used for bothacceleration and deceleration.Changes of accelerationFrom Equations 4 and 5 we can obtain an expression for the step number n as afunction of speed and acceleration:
 Equation 16Thus the number of steps needed to reach a given speed is inversely proportional tothe acceleration:
 Equation 17This makes it possible to change the acceleration at a point on the ramp by changingthe step number n in the ramp algorithm Equation 13. Moreover, using signed ω'values results in signed n-values that behave correctly in the algorithm. Only ω' = 0needs special handling.The n-value given by Equation 17 is correct for tn. However cn represents an averagefor the interval tn .. tn+1. Equation 17 is usually adequate, but it's more accurate toadd a half-step to n-values for use in the ramp algorithm:
 Equation 18The numerical example shown in Table 2 changes acceleration from 10 to 5 and to-20rad/sec2 from step 200. Complex speed profiles can be built up piecewise in thisway.Table 2: Table 2: Acceleration changesAcceleration changesStepinici (13)ω'(3)notes1981982,813.067 
199199398.5-100.252,806.0081010.(199+.5) =5.(398.5+.5) =-20.(-100.25+.5)200399.52,803.4985
201400.52,799.0015200-99.252,820.180-20
201-98.252,834.568-20Deceleration rampDeceleration rampFor a short move of m steps, where the up-ramp at ω'1 meets the down-ramp at ω'2before max speed is reached, the step number m at which to start decelerating is,from Equation 17:
 Equation 19ω'1 = acceleration, ω'2 = deceleration (positive). Round n to integer and calculate cn.. cm-1 using Equation 14.In other cases, Equations 17 or 18 can be used to calculate the number of steps n2needed to stop at deceleration ω'2, given that the present speed was reached at stepn1 with acceleration ω'1. Round n2 to integer and calculate cm-n2 .. cm-1 using Equation14.Smooth shift to max speedSmooth shift to max speedThe ideal speed profile would make a smooth transition from ramp acceleration ω' tomax speed ωmax. Higher speed is possible by reducing the acceleration near the topof the ramp, and you can avoid possible undesirable effects of a discontinuity inacceleration.There are several ways to achieve a smooth transition while still allowing real-timecomputation on a low-end processor:Reduce ω' in stages, giving a piecewise linear transition.Add a power term to the denominator of the ramp algorithm.Scale the change from ci-1 to ci by a linear factor.Now let's compare these methods.Piecewise linearPiecewise linearThis method, shown in Figure 5, is very flexible. Any number of breaks can be used.A set of ω-values is chosen at which ω' is successively reduced. The ramp algorithmin Equation 13 is used. At each step, n is incremented, and if ω (or c) crosses abreak value, n is recalculated.Figure 5: PiecewiseFigure 5: PiecewiseFigure 5 results from the jth break given by (c)j=0 = 3.cmin, (c)j = ((c)j- 1+cmin)/2,(ni)j = 1.375.(ni- 1+1), j = 1,2,..,7. (c)j = delay count at jth break, cmin, = delaycount at ωmax.Power termPower termEquation 20 adds a power term to the denominator of the ramp algorithm (Equation12):
 Equation 20At low speed (low step-number n), the power term k·np is negligible, so accelerationis constant. As speed rises, k·np starts to dominate, eventually reducing theacceleration to zero. A higher power p produces a sharper "knee." The approach toωmax is asymptotic.The transition occurs around k·np = 4.n. This can be used to calculate anapproximate value for the constant k from initial acceleration ω' and required maxspeed ωmax:
 Equation 21The graphs in Figure 6 use Equation 21 to calculate k for p=2,3,4,5. The curve fallsshort of ωmax for p=2 but k is good for higher powers.
Figure 6: Power term, Figure 6: Power term, p=2,3,4,5=2,3,4,5Linear factorLinear factorIn this method we run the ramp algorithm (Equation 12) up to step n1 and thenscale the changes in c by a factor that reduces from 1 at step n1 to 0 at step n2:
 Equation 22
Figure 7: Linear factorFigure 7: Linear factorThe acceleration curve is fairly linear and symmetrical over the transition. ωmax isreached in about twice the time taken with no transition, as shown in Figure 7. ωmaxcan be estimated by integrating a continuous version of Equation 22,
. We obtain:
 Equation 23Equation 23 is accurate for a wide range of parameters, including n1=0. It thensimplifies to Equation 24 (compare with Equation 16):
 Equation 24In Figure 7, the linear factor method is applied with transition ranges starting at 0and 30%, 50%, and 70% of ωmax.A linear-factor transition can also be applied to the downramp:
 Equation 25Step-number n3, the start of the transition from max speed to the down-ramp, iscalculated as in the previous example. For a short move, n3=n2, calculated byEquation 19.Figure 8: Linear factor: dual transitionsFigure 8: Linear factor: dual transitionsFigure 8 shows examples with and without a section at ωmax: m=700, ω'1 =10, ω'2= -20, n1=0, n2=432, n3=484; and m=500, n2=n3=333, other parametersunchanged.Transition methods in sumTransition methods in sumThe form of the transition curve is assumed to be less important than ease ofcalculation and control of parameters, particularly ωmax and the size of the transitionregion.The piecewise-linear method is flexible and can be arranged to require no morecalculation than a simple ramp, and give a visually smooth speed profile. It may notwork with some sets of parameters, though.In the power-term method, the k-parameter is easily calculated from ωmax.Calculating the power term creates problems in fixed-point arithmetic, as valuesvary over a wide range.The linear-factor method is recommended as reliable and easy to calculate in fixed-point arithmetic. Because ωmax is reached at a known step number, the method isgood for short moves and can transition from acceleration to deceleration with nodiscontinuity, as Figure 8 demonstrates. Starting the transition at n1=0 gives anarrow transition region, and it's straightforward to calculate n2 from ωmax.The methods are compared in Figures 5 through 7.ImplementationImplementationYou can implement this stepper-control algorithm using a PIC18F252 and a L6219.The L6219 stepper driver IC performs the following functions:Provides diode-protected H-bridge drives capable of 46V/750mA to thetwo motor windingsTranslates digital signals from the PIC to current direction in the motorwindings (PHASE1, 2 inputs)Limits each winding current to 0, 33%, 67%, or 100% of a preset value bychopping the drive to the H-bridge transistors (inputs I01, I11, I02, I12)The maximum current is set by a current-sense resistor for each winding.The L6219 doesn't have "step" and "direction" control lines like some stepper controlICs. The winding phase sequence must be provided by the PIC. This makes controlslightly more complicated but gives extra flexibility and reduces cost. It also meansthat the phase can be restored easily on power-up.By using the I-inputs, the L6219 can be used for half- and quarter-step operation.For full-step, they can be tied together and driven by one GPIO from the PIC.Microchip's PIC18F252 is a 28-pin device with the same footprint as the PIC16F876.The more powerful core of the '252 makes it easier to program in C. Figure 9 showshow the internal timing resources were configured for controlling the L6219.Figure 9: PIC18F252 timer conﬁguration for L6219 interfaceFigure 9: PIC18F252 timer conﬁguration for L6219 interfaceAn 8MHz crystal and the PIC's ×4 PLL frequency multiplier are used to generate a32MHz processor clock. This is divided by four to clock the timers at 8MHz. Drivingthe motor involves the following sequence:1. Get parameters: step count, direction, delay count c0, max speed and soforth.2. Set up hardware: initialise CCP1 and CCP2, enable motor current, enableCCP1 interrupts.3. Service CCP1 interrupts: count the steps and execute a state machine toreconfigure the CCPs and calculate the next timer value.4. Clean up: after the last step, disable CCP1 interrupts, current off, flag themove done.The listing (online at http://www.eetimes.com/design/embedded/source-code/4210291/Motor-c (http://www.eetimes.com/design/embedded/source-code/4210291/Motor-c)) is a minimal demo of these steps, with linear ramps, fixedmaximum speed and accelerations. The author used the CCS compiler. Minorchanges will be required for other compilers.Stepping outStepping outThe real-time algorithms I've explained here significantly reduce the processingpower needed for smooth speed control of stepper motors. The linear rampalgorithm can be adapted to piecewise linear speed profiles and smooth transitionsfrom ramp to max speed.David AustinDavid Austin is a freelance software engineer from Durham, U.K. You can reachhim at dave@slotech.fsnet.co.uk (mailto:dave@slotech.fsnet.co.uk).ResourcesResourcesAcarnley, Paul. Stepping Motors— A Guide to Theory and Practice, 4th edition.London: Institution of Electrical Engineers, 2002.Kenjo, Takashi and Akira Sugawara. Stepping Motors and their MicroprocessorControls, 2nd edition. Oxford University Press, March, 1995.Control of Stepping Motors— A Tutorial www.cs.uiowa.edu/~jones/step/(http://www.cs.uiowa.edu/%7Ejones/step/)4Tweet
 (mailto:?subject=Generate stepper-motor speed proﬁles in realtime&body=http://www.embedded.com/design/mcus-processors-and-socs/4006438/Generate-stepper-motor-speed-proﬁles-in-real-time)Suppliers' Web sites:Suppliers' Web sites:PIC18F252 www.microchip.com (http://www.microchip.com)L6219 www.st.com (http://www.st.com)PIC C compiler www.ccsinfo.com (http://www.ccsinfo.com)Stepper motors www.rotalink.com (http://www.rotalink.com)Mathcad (graphs) www.mathsoft.com (http://www.mathsoft.com)Share
25LikeLike
14 COMMENTSDeepak_K (/User/Deepak_K) POSTED: JUN 12, 2015 6:52 AM EDTHi, After equation 12, I could not understand the approach. I think I veered awayfrom the point..I failed to understand this part: "Finally, we can disconnect the physical step number, i, from the step number n on a ramp fromzero, to give the general-purpose ramp algorithm shown in Equation 13. Here n determines theacceleration and increments with i for constant acceleration. To ramp up from stop, ni = i, i=1,2,. . . :" Can anyone please try to explain what is "i" and why did it come in? Also what is the difference between n and i?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Deepak_K (/User/Deepak_K) POSTED: SEPT 4, 2014 5:09 AM EDTHi, What if we just modulate the frequency of the pulse train to the motor with asine function (0 to 90 degrees)? Wouldn't that give a smooth s shaped curve?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jorick23 (/User/Jorick23) POSTED: AUG 14, 2014 3:56 PM EDTMy application has a very simple way of ramping quickly up to speed. Every stepinterrupt, I take the timer count (based on a 120 MHz clock) and shift it right(divide by power of 2) by a set amount and subtract the result from the timercount to get a new timer count for the next step. This results in a somewhatlinear increase in speed. This also works for speed decreases where the shiftedvalue is added to the timer count. For slower ramps of over a second, I have the starting and ending rates in a 64-bit integer,something like billionths of a revolution per second. Prior to the ramp, I ﬁgure out how much ofa rate increase or decrease needs to be done every millisecond (the tick count rate). Then Iconvert the rate to a timer count inside the tick interrupt with one divide by a precomputedconstant.REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jupiik (/User/Jupiik) POSTED: MAY 4, 2011 10:21 PM EDTI tried it the way altronics suggested and I got nonlinear speed proﬁle (blue line in graph) thatsbecause (speed = distance / time) and time is below "/" so it has nonlinear function in speed butif you keep whole time in memory reversed value (1/time) and every step add constat value andWRITE A COMMENTTHEN reverse it and set to counter you will get nice linear speed proﬁle (red onein graph) and i didnt have to use any hard Equations. But to be honest this articlewas base for whole my work/study about stepper motor speed proﬁlesgenerating. (btw sorry for slovak in graph but anyway its obvious and I was lazyto translate it..) http://dl.dropbox.com/u/545374/rychlostny%20proﬁl.jpg(http://dl.dropbox.com/u/545374/rychlostny%20proﬁl.jpg)REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Sunil.Singh_#3 (/User/Sunil.Singh_%233) POSTED: JUL 24, 2011 12:43 PMEDTHi Jupiik, I tried to understand your comment but probably don't understand it fully.I would appreciate if you may elaborate "whole time in memory reversedvalue (1/time) and every step add constat value and THEN reverse it and set to counteryou will get nice linear speed ". Thanks sunilREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Cch1955 (/User/Cch1955) POSTED: MAR 12, 2012 7:41 PM EDTHi Jupiik, i have project where you simpliﬁed computation for trapazoidal rampcalulation would be helpful. Is it possible to see you paper or the equationor code involved? Thanks so much. CCHREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Altronics (/User/Altronics) POSTED: MAR 13, 2011 5:37 AM EDTCouldn't that same linear ramp be more easily implemented by simply using asmall set delay time (say 1ms) multiplied by a start delay factor and a decreasingloop between each step? Example: Start delay time =100 //100ms decrement factor = 2 for (x=100; x=0; x=x-2) { move_motor_1_step(); delay(x); } get the idea? REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Triﬃd Hunter (/User/Triﬃd%20Hunter) POSTED: APR 10, 2011 10:59 PMEDTI wish it were that easy! acceleration is dv/dt. your algorithm increases dv while decreasing dt,giving an exponential change in velocity rather than linear. Thus, you either cannot attain high speeds because the motor can't supply enoughtorque, or your acceleration from slow speeds or stop is infuriatingly low. There will be asweet spot around the knee of this exponential curve, where you won't notice thedifference much, but if you're ramping signiﬁcant mass from zero to some high speedyou'll be signiﬁcantly affected. EMC2 simply has a constant velocity, and updates that velocity from a separate timerevery 10mS or so. It's a simple approach, albeit far less elegant than the one described inthis article.REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Susan.rambo (/User/Susan.rambo) POSTED: NOV 1, 2010 1:40 PM ESTI reposted the Motor.c code in our new source code library. You can ﬁnd it herehttp://www.eetimes.com/design/embedded/source-code/4210291/Motor-c.(http://www.eetimes.com/design/embedded/source-code/4210291/Motor-c.)(The link in this article is also now up to date.) I'll be updating all the ESD/ESPmagazine source code archive links in the next month to make sure all sourcecode from Embedded Systems Programming/ESD magazine is connected to an article and viceversa. --Susan Rambo Managing editor, ESD magazineREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jamesyn (/User/Jamesyn) POSTED: JAN 10, 2014 4:13 PM ESThi miss. your link is not working . i can't download.pls give me another link.thak youREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Greatfog (/User/Greatfog) POSTED: NOV 1, 2010 12:39 PM ESTMs. Rambo, Managing Editor of Embedded Systems Design, has ﬁxed the link tothe code. Thank you, ma'm!REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Dandumit (/User/Dandumit) POSTED: NOV 1, 2010 8:58 AM ESTGreat Info. I would like also to access the ﬁle motor.c but it seems to rejectanonymous login. Maybe someone can help ?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Tumnao (/User/Tumnao) POSTED: OCT 11, 2010 9:52 AM EDTGreat article! What are the credentials to download the example ﬁle (motor.c)?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)SUNMY (/User/SUNMY) POSTED: OCT 11, 2009 9:49 AM EDTgood job!REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Deepak_K (/User/Deepak_K) POSTED: JUN 12, 2015 6:52 AM EDTHi, After equation 12, I could not understand the approach. I think I veered awayfrom the point..I failed to understand this part: "Finally, we can disconnect the physical step number, i, from the step number n on a ramp fromzero, to give the general-purpose ramp algorithm shown in Equation 13. Here n determines theacceleration and increments with i for constant acceleration. To ramp up from stop, ni = i, i=1,2,. . . :" Can anyone please try to explain what is "i" and why did it come in? Also what is the difference between n and i?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Deepak_K (/User/Deepak_K) POSTED: SEPT 4, 2014 5:09 AM EDTHi, What if we just modulate the frequency of the pulse train to the motor with asine function (0 to 90 degrees)? Wouldn't that give a smooth s shaped curve?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jorick23 (/User/Jorick23) POSTED: AUG 14, 2014 3:56 PM EDTMy application has a very simple way of ramping quickly up to speed. Every stepinterrupt, I take the timer count (based on a 120 MHz clock) and shift it right(divide by power of 2) by a set amount and subtract the result from the timercount to get a new timer count for the next step. This results in a somewhatlinear increase in speed. This also works for speed decreases where the shiftedvalue is added to the timer count. For slower ramps of over a second, I have the starting and ending rates in a 64-bit integer,something like billionths of a revolution per second. Prior to the ramp, I ﬁgure out how much ofa rate increase or decrease needs to be done every millisecond (the tick count rate). Then Iconvert the rate to a timer count inside the tick interrupt with one divide by a precomputedconstant.REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jupiik (/User/Jupiik) POSTED: MAY 4, 2011 10:21 PM EDTI tried it the way altronics suggested and I got nonlinear speed proﬁle (blue linein graph) thats because (speed = distance / time) and time is below "/" so it hasnonlinear function in speed but if you keep whole time in memory reversedvalue (1/time) and every step add constat value and THEN reverse it and set tocounter you will get nice linear speed proﬁle (red one in graph) and i didnt haveto use any hard Equations. But to be honest this article was base for whole my work/studyabout stepper motor speed proﬁles generating. (btw sorry for slovak in graph but anyway itsobvious and I was lazy to translate it..) http://dl.dropbox.com/u/545374/rychlostny%20proﬁl.jpg(http://dl.dropbox.com/u/545374/rychlostny%20proﬁl.jpg)REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Sunil.Singh_#3 (/User/Sunil.Singh_%233) POSTED: JUL 24, 2011 12:43 PMEDTHi Jupiik, I tried to understand your comment but probably don't understand it fully.I would appreciate if you may elaborate "whole time in memory reversedvalue (1/time) and every step add constat value and THEN reverse it and set to counteryou will get nice linear speed ". Thanks sunilREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Cch1955 (/User/Cch1955) POSTED: MAR 12, 2012 7:41 PM EDTHi Jupiik, i have project where you simpliﬁed computation for trapazoidal rampcalulation would be helpful. Is it possible to see you paper or the equationor code involved? Thanks so much. CCHREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Altronics (/User/Altronics) POSTED: MAR 13, 2011 5:37 AM EDTCouldn't that same linear ramp be more easily implemented by simply using asmall set delay time (say 1ms) multiplied by a start delay factor and a decreasingloop between each step? Example: Start delay time =100 //100ms decrement factor = 2 for (x=100; x=0; x=x-2) { move_motor_1_step(); delay(x); } get the idea? REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Triﬃd Hunter (/User/Triﬃd%20Hunter) POSTED: APR 10, 2011 10:59 PMEDTI wish it were that easy! acceleration is dv/dt. your algorithm increases dv while decreasing dt,giving an exponential change in velocity rather than linear. Thus, you either cannot attain high speeds because the motor can't supply enoughtorque, or your acceleration from slow speeds or stop is infuriatingly low. There will be asweet spot around the knee of this exponential curve, where you won't notice thedifference much, but if you're ramping signiﬁcant mass from zero to some high speedyou'll be signiﬁcantly affected. EMC2 simply has a constant velocity, and updates that velocity from a separate timerevery 10mS or so. It's a simple approach, albeit far less elegant than the one described inthis article.REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Susan.rambo (/User/Susan.rambo) POSTED: NOV 1, 2010 1:40 PM ESTI reposted the Motor.c code in our new source code library. You can ﬁnd it herehttp://www.eetimes.com/design/embedded/source-code/4210291/Motor-c.(http://www.eetimes.com/design/embedded/source-code/4210291/Motor-c.)(The link in this article is also now up to date.) I'll be updating all the ESD/ESPmagazine source code archive links in the next month to make sure all sourcecode from Embedded Systems Programming/ESD magazine is connected to an article and viceversa. --Susan Rambo Managing editor, ESD magazineREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Jamesyn (/User/Jamesyn) POSTED: JAN 10, 2014 4:13 PM ESThi miss. your link is not working . i can't download.pls give me another link.thak youREPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Greatfog (/User/Greatfog) POSTED: NOV 1, 2010 12:39 PM ESTMs. Rambo, Managing Editor of Embedded Systems Design, has ﬁxed the link tothe code. Thank you, ma'm!REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Dandumit (/User/Dandumit) POSTED: NOV 1, 2010 8:58 AM ESTGreat Info. I would like also to access the ﬁle motor.c but it seems to rejectanonymous login. Maybe someone can help ?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)Tumnao (/User/Tumnao) POSTED: OCT 11, 2010 9:52 AM EDTGreat article! What are the credentials to download the example ﬁle (motor.c)?REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)SUNMY (/User/SUNMY) POSTED: OCT 11, 2009 9:49 AM EDTgood job!REPLY (/LOGIN?ASSETID=203&SUCCESSFULLOGINREDIRECT=HTTP%3A%2F%2FWWW.EMBEDDED.COM%2FDESIGN%2FMCUS-PROCESSORS-AND-SOCS%2F4006438%2FGENERATE-STEPPER-MOTOR-SPEED-PROFILES-IN-REAL-TIME)
DEVELOPMENTCENTERSAll Articles(/development)Conﬁgurable Systems(/development/conﬁgurable-systems)Connectivity(/development/connectivity)Debug & Optimization(/development/debug-and-optimization)MCUs, Processors &SoCs(/development/mcus-processors-and-socs)Operating SystemsESSENTIALS &EDUCATIONProducts (/products/all)News (/news/all)Source Code Library(/education-training/source-codes)Webinars (/education-training/webinars)Courses (/education-training/courses)Tech Papers(/education-training/tech-papers)COMMUNITYInsights (/insights)Forums(http://forums.embedded.com)Events (/events)ARCHIVESEmbedded SystemsProgramming /Embedded SystemsDesign Magazine(/magazines)Newsletters(/archive/Embedded-com-Tech-Focus-Newsletter-Archive)Videos (/videos)Collections(/collections/all)ABOUT USAbout Embedded(/aboutus)Contact Us (/contactus)Newsletters(/newsletters)Advertising(/advertising)Editorial Contributions(/editorial-contributions)Site Map (/site-map)Subscribe to RSS updatesSubscribe to RSS updates  or all articles (/rss/all)category ▼(/development/operating-systems)Power Optimization(/development/power-optimization)ProgrammingLanguages & Tools(/development/programming-languages-and-tools)Prototyping &Development(/development/prototyping-and-development)Real-time &Performance(/development/real-time-and-performance)Real-world Applications(/development/real-world-applications)Safety & Security(/development/safety-and-security)System Integration(/development/system-integration)GLOBAL NETWORK EE Times Asia (http://www.eetasia.com/) EE Times China (http://www.eet-china.com/) EE Times Europe (http://www.electronics-eetimes.com/) EE Times India(http://www.eetindia.co.in/) EE Times Japan (http://eetimes.jp/) EE Times Korea (http://www.eetkorea.com/) EE Times Taiwan (http://www.eettaiwan.com/) EDN Asia(http://www.ednasia.com/) EDN China (http://www.ednchina.com/) EDN Japan (http://ednjapan.com/) TechOnline India (http://www.techonlineindia.com/) ESC Brazil(http://www.escbrazil.com.br/en/) ESC India (http://www.esc-india.com/)
(http://ubmcanon.com/)UBM Canon Electronics Engineering CommunitiesEE Times (http://www.eetimes.com/) | EDN (http://www.edn.com/) | EBN (http://www.ebnonline.com/) | DataSheets.com (http://www.datasheets.com/) | Embedded (http://www.embedded.com/) | TechOnline (http://www.techonline.com/) | Design News (http://www.designnews.com/) | DesignCon (http://www.designcon.com/) | ESC (http://www.embeddedconf.com/)Working With Us: About (http://ubmcanon.com/) | Contact Us (http://ubmcanon.com/design-and-manufacturing/) | Media Kits (http://ubmcanon.com/design-and-manufacturing/)Terms of Service (http://ubmcanon.com/terms-of-service/) | Privacy Statement (http://ubmcanon.com/privacy-policy/) | Copyright © 2015 UBM Canon All Rights Reserved (http://legal.us.ubm.com/copyright-notice/)