## Real life stepper speed

9

2

I am wondering about the speed that my steppers should achieve in regular operation and what the determining factors are, from theoretical hardware facts/limits to software limitations that can influence performance.

I do know about the basic properties of stepper motors such as the torque relation with speed, which I read some while ago from this source (for anyont stumbling into this question later): https://www.geckodrive.com/gecko/images/cms_files/Step%20Motor%20Basics%20Guide.pdf

So far Wikipedia (https://en.wikipedia.org/wiki/Stepper_motor) easily turns up the following statements with regard to my question:

Thus when controlled by an L/R drive, the maximum speed of a stepper motor is limited by its inductance since at some speed, the voltage U will be changing faster than the current I can keep up.

and for chopper drivers:

This requires additional electronics to sense winding currents, and control the switching, but it allows stepper motors to be driven with higher torque at higher speeds than L/R drives

Obviously the amount of steps/revelation will change the speed, too

However, all this does not help me to determine what the real life speed of my stepper should be. Additional firmware parameters clutter up my (beginner's) brain even more (and I haven't had a too deep dive into that yet). In general I understand that the frequency we use to send the steps to the stepper is the main determining factor, also 'reduced' by microstepping, if applied. We cannot keep the current up as much as needed due to timing/inductive/electronic properties of the motors, so we lose torque or finally steps. A higher voltage helps to bring the current up faster, so the steepness of the current increase can also limit the maximum applicable frequency. The frequency itself is given from the controller board to the motor driver, hence is set in firmware.

All in all, apart from what makes sense to utilize in a 3D printer setup, what are the determining factors of the stepper speeds that can be realized and how to they transform into real life values for our printers? Also I'd be interested in how the determining factors influence the reliability and print quality regardless of the mechanical difficulties that arise with print-speed.

However, I think the question here is relevant and specific enough for 3D printing to exist here alongside.

## Answers

12

The four main motor speed limits in a 3d printer are:

• Firmware step generation frequency limits
• Firmware motion planner effects
• Loss of torque and precision due to motor coil inductance and back-EMF effects
• Mid-band resonance

Step generation rate limits will depend on the firmware and controller board used. There is a significant range, particularly when 32bit firmwares and RTOS-based platforms like MachineKit are compared to 8bit firmwares running on Atmega AVRs. Some examples:

• Marlin on a 16 MHz 8bit Atmega can only run the stepper interrupt at 10,000 hz without bogging down the processor and blocking other critical algorithms (like motion planning). It can fire step rates up to 40,000 hz by pulsing the step line two or four times per interrupt, which effectively drops the microstep level in software and runs the motors rougher/louder.
• Repetier on the same Atmega can run the stepper interrupt at 12,000 hz, because it is optimized more for execution speed than Marlin.
• Repetier on an 84 MHz 32bit ARM Cortex-M3 can run the stepper interrupt at 80,000 Hz.

These limits typically only affect actual stepper speed when relatively fine microstepping is used. Consider an example based on a very typical Marlin printer configuration. Microstepping of at least 1/4 is strongly recommended to avoid resonance issues, so let's start with 1/16 stepping. This allows quad-stepping to effectively output 1/4-steps. Starting with finer microstepping will drop our top speed, and coarser microstepping will be louder and may encounter resonance, so this is a good starting point. Then asssume a typical 32mm-per-rev pulley on a 1.8 degree (200 steps/rev) stepper motor. This system has a resolution of 200*16/32= 100 steps/mm. At 40,000 Hz total stepping rate (quad-stepping at 10,000 Hz) we can theoretically travel at 400 mm/s before hitting Marlin's hard cap. That's probably going to be a higher RPM than we want to run the motor anyway, so it's not a very impactful limit.

In comparison, if we started at 1/128 stepping (such as with the THB6128 driver chip) our top speed with 8bit Marlin would be 50 mm/s. That's quite slow.

Firmware motion planners can further limits motor speed by ramping up and down to traverse turns and corners. If the model geometry has lots of sharp turns, the target speeds commanded by the gcode are likely to never actually be reached. Only long, straight line paths will have enough ramping time to hit the speed target. You can see this yourself by printing a very small model at a variety of feedrates and timing the actual print duration: at a certain point, increases in the commanded speed will make no difference on actual print times.

Another constraint some firmwares enforce is requiring the ability to safely decelerate to a stop within the length of all the motion commands in the planner queue. This allows the printer to gracefully handle a sudden loss of input, such as as if the host computer stops transmitting USB commands, or if the SD card experiences a series of read errors. If the printer just abruptly stops from full speed when it runs out of commands, it is likely to lose position and ruin the print. Whereas if it can decelerate to a safe stopping speed, it may be able to resume after the command stream resumes.

In terms of actual motor behavior, the inductance and back-EMF introduce significant limits because they decrease motor torque at higher RPMs. This produces a torque/RPM curve that drops off at higher speeds:

Note in the picture that there is a flat "constant current" region on the left side at low speeds. This is the range where the chopping driver is limiting coil current. On the right side of the curve, current is not able to reach the target before it must be switched back off for the next step. That reduces field strength and thus torque.

There are two separate effects to consider here:

• Motor coils are inductors, which means there is a first-order lag between applied voltage and coil current. A standard bipolar stepper motor with a microstepping driver must raise the coil current from zero to max or from max to zero every full step (eg every sixteen 1/16th microsteps). At high step rates, there is not enough time to fully charge the coil to its max current before the next step requires dropping the current back down. Without developing full coil current on each step, torque is lost.
• Every motor is also a generator, and spinning the rotor generates back-EMF voltage within the motor coils. That voltage waveform gets overlaid on top of the drive voltage waveform with a phase shift dependent on the rotor position relative to the coil energization position. In simple terms, this voltage attempts to brake the motor: it always does whatever will slow the motor down. This means it opposes the applied drive voltage when the motor is applying forward torque, or assists the applied drive voltage when the motor is applying brake torque.

For a practical discussion of speed limits, we can simplify the situation by assuming back-EMF voltage opposes the drive voltage applied to the coils. This means there is less effective voltage raising/lowering coil current, and it takes longer for the current to change, and less coil current is developed than would be the case without back-emf. This further depresses the torque/RPM curve of the motor. And when the back-EMF voltage is around the same magnitude as the drive voltage, significant motor instability can result because of complex feedback effects between rotor position and effective coil voltage.

You can play with these effects using different motor configurations and speeds for a few popular 3D printer stepper drivers using my stepper driver simulator: https://github.com/rcarlyle/StepperSim

In closed-loop applications with position feedback and high-end drivers that can damp various instability modes, it may be ok to run the stepper all the way down the torque curve at very high RPMs. In more typical open-loop 3D printer applications, it's generally best to stick to the low-RPM part of the torque curve before inductance and back-EMF really take over the motor behavior. Losing too much torque can easily mean skipping steps and losing position, ruining the print.

Another important effect for steppers is mid-band resonance. This is not a normal mechanical resonance, but actually an electromechanical resonance effect. It's quite complicated, but the short explanation is that a stepper has an intrinsic 90-degree phase shift between position and torque, and when speeds rise to a point where coil inductance introduces an additional 90-degree phase shift between coil current and applied voltage, the electromechanical system has a highly-unstable 180-degree phase lag and thus creates a negative feedback loop. This can rapidly drop motor torque until the motor loses synchronicity with the driver's applied voltage and stalls.

Mid-band resonance only occurs when coil current is limited by inductance. It cannot occur in the constant-current drive range because there is not enough phase lag between applied voltage and coil current.

Unfortunately, measured torque curves available from manufacturers almost never show resonance zones, because the curves are produced by loading motors with friction-brakes that damp any kind of resonance effect from building. Whereas a 3D printer drivetrain load is almost entirely inertial (accelerating a mass) which is much more prone to resonance.

High-end drivers can automatically detect and damp mid-band resonance, but typical low-cost 3D printer drivers do not have this capability.

It is generally prudent to avoid entering an RPM range where mid-band resonance may occur. This is easily accomplished by sticking to the left side of the torque curve, in the constant-current operating region. This ensures high torque and good stability.

For a concrete example, consider the popular Kysan 1124090 stepper with a 24v power supply.

To maintain high torque and avoid mid-band resonance, we would want to keep the RPM to about 400 or less. For the same 32mm-per-rev pulley mentioned above, that would limit speeds to around 200-240 mm/s. Higher speeds are possible, but may encounter reliability issues.

This speed, of course, assumes a 24v PSU is used, to match the measured torque curve: a 12v PSU would have a significantly lower top speed before inductance starts to limit coil current, around half as fast. Higher supply voltage greatly increases the top effective speed for the motor.

Again, you can easily simulate this effect (using https://github.com/rcarlyle/StepperSim). This simulator output chart shows how inductance and back-EMF are keeping coil current from reaching the target:

For practical drivetrain design, a motor/driver simulator is really the best tool in the toolbox for finding the point where performance will start to degrade due to inability to hit current targets. It's simply too complex to apply simple equations or rules of thumb with any accuracy. These electrical effects and the firmware step generation limits are likely to be the two main restrictions on motor speed for most printers.

Of course, how fast you can melt plastic will tend to limit printing speeds significantly below the true motor speed limits, but that's a different discussion. For the moment, we can simply say that top motor speed tends to be unimportant for print moves in typical Cartesian printers. However, there are a few instances where they are likely to drive printer performance:

• Linear Deltas, where carriages may need to run several times faster than the effector for certain move directions
• Geared extruders with high reduction ratio (eg much over 5:1) for high retraction speeds
• Short-pitch lead screws (or all-thread) that need high rotation speeds to achieve moderate linear speeds

++ Thanks, this helped me understand what's going on a lot better than I did before! – TextGeek – 2018-08-16T11:51:39.227

This answer is epic. The link to the XLSX calculator as well! I was going to ask a question about repurposing my old stepper, after putting the values in the XLSX I got my answer already. – FarO – 2019-11-20T14:26:59.690