# Stepper Motor Accel/Decel Ramp for Fixed Frequency Input

I have a reasonable working knowledge of electronics but am trying to find a solution to a puzzle I've come across and have not been able to find a complete answer. This involves a stepper motor and I have not worked with these before, but understand their principle.

I am trying to drive a stepper motor in the following manner. I have an encoder that is running constantly and generating a frequency that is approximately constant. This will drive my motor at a speed proportional to the encoder output frequency. I want to start the stepper motor on a signal from a sensor and stop it on a signal from a second sensor.

I've found details of how to drive a stepper motor, using ICs such as the UCN5804 series.

I've found material on the need to apply ramping to the speed of the motor on startup and shutdown and I've found a circuit on this site that will generate a trapezoidal profile using a 555 timer. (https://m.eet.com/media/1144287/203799f1.pdf)

It seems to me that I would need to use such a circuit to ramp up the motor, then switch over to my encoder signal to drive it, then switch back to the 555 circuit when I want to ramp down. This seems a very cumbersome arrangement.

My question is, how can I ramp up my stepper motor, given that I have a continuous input pulse stream of approximately constant frequency?

• you can't increase frequency if it is constant. Get a CNC shield and use GRBL1.1 with Gerber Panel on full steps. I can accelerate to 1m/s in about 0.2m with an 8mmD belt gear. THis allows custom settings for step rate, max velocity, max acceleration rate with analog Vin and pot adjust I max on driver chips to control power avail. – Sunnyskyguy EE75 Nov 20 '17 at 0:18
• What range of frequencies do you have coming from the encoder? If the frequency is low enough, the stepper motor may come up to speed all by itself. It may accelerate far faster than you might think. Coming up to 1000 steps per second in 1.5 steps is entirely possible if the inertial load is small enough. – whitegreg56 Nov 20 '17 at 1:06
• My maximum frequency will be around 80 kHz, which gives me 400 RPM for a 200 step motor. This is not a hobby type application but an industrial application, using a motor in NEMA 34 frame size, putting out about 6 Nm of torque. Inertial load will not be large in relation to this, but I need high acceleration rates.Many years ago, I used a proprietary controller that did exactly what I'm trying to do, so I know it can be done. – Steve W Nov 20 '17 at 2:18
• Hmmm.....400 RPM times 200 steps/revolution gives 80,000 steps/minute or ~1333 steps/second. That is a lot less than an 80 kHz step rate. Or, for an 80 kHz step rate, you'll be doing a lot more than 400 RPM. – whitegreg56 Nov 20 '17 at 3:02
• Yes correct. I realised after posting that I'd made that mistake. 1333 Hz is correct. – Steve W Nov 20 '17 at 19:36

Accelerating and decelerating stepper motors consistently can be a very challenging adventure.

Accelerate too fast and the motor can stall and just sit there screaming at you. If you are counting steps it can also lag back far enough to skip back a full cycle leaving you out of position.

Accelerate too slowly with a light inertial load and the motor can actually turn around on you during the first few steps. This of course makes it that much harder for the motor to keep up with the ramping step rate.

All this can be further aggravated if the load itself is variable, either short term or long and let us not forget the variability of the motors and drivers.

Because of all that, finding the right acceleration and deceleration profiles that work consistently can be a frustrating effort.

In order to do so it is normal to back off the acceleration and deceleration torques to give the motor some lee-way to correct itself. That is, if you try to accelerate at what you have calculated to be the best torque of the motor, and the motor falls behind, there will be no torque left for the motor to go faster than the demand and catch up.

Ultimately, for best control of a stepper motor it is best to attach a shaft encoder to it that has the same, or a multiple, number of pulses as the motor has steps and closing the control loop. Basically turning your stepper motor into a high pole count BLDC. Properly controlled, such an arrangement lets you extract the most torque, and acceleration/deceleration, out of the motor even under highly variable loads.

• A computer simulation of a (hybrid) step motor and driver is a powerful tool! You can vary the loading (inertial and otherwise) quite easily and see what happens. The state equations are quite simple for a hybrid motor. A reluctance motor is considerably more difficult to simulate. – whitegreg56 Nov 20 '17 at 3:26
• @whitegreg56 got any links/recommendations for those. (those were not available back then I last did SMs.) – Trevor_G Nov 20 '17 at 3:28
• In any case brushless dc motor is always a better choice. – Gregory Kornblum Nov 20 '17 at 3:38
• @GregoryKornblum I would not say always. For cruising BLDCs are great, for passively holding position to within a thou or two, steppers still reign supreme. – Trevor_G Nov 20 '17 at 3:42
• Let's say, i can imagine a situation when one choses a stepper and it's just enough for him, because he doesn't care about performance and can afford "more iron and copper". Yet for absolutely any application bldc can fit and perform better, be smaller (hence cheaper starting from some quantity), and so on. The problem is a mind inertia mostely – Gregory Kornblum Nov 20 '17 at 3:46