Stepper Motors

From ShapeOko
Revision as of 22:04, 13 July 2021 by Willadams (Talk | contribs) (Specifications)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Excellent overview and background of stepper motors and comparison to other options:

Stepper motors are designed to allow discrete rotation in a given number of steps per full rotation. They have the following properties:

  • Step Angle --- The size of each step in degrees is one important rating for a given motor.
  • Micro stepping --- by altering the signal sent to a motor one can coerce a motor to hold at positions in-between steps --- see below for details
  • Polarity
    • Bipolar
    • Unipolar
  • Holding torque
  • Size --- US NEMA standard
    • motor diameter / faceplate size --- this is in decimal inches multiplied by 10, so a NEMA17 is 1.7 inches --- larger diameter motors have the physical advantage of better leverage
    • motor length --- for a given size, there is a direct relation between motor power and length
  • Shaft --- 5mm is typical for the sizes used on Shapeokos, but 0.25" is not unheard of (and typical for the larger NEMA23 motors)
  • Heat --- typical specs are for an 80 °C temperature increase
  • Power and current

Image of a 3D printed motor which explains how they work:


The 58 oz-in motors listed are sufficient to drive the Shapeoko 1 or 2, but larger motors can be used. Forum Discussion. 125 oz in (9000 g cm) is about the maximum holding torque you can make use of with a Shapeoko-class machine (Improbable Construct used 280 oz. motors in his heavily-upgraded machine: User:Improbable Construct) and the new Z-axis design has been used w/ 178 oz. in. motors[1]. With 18-tooth MXL pulleys, that works out to about 34 lbf (15.5 kgf) applied to the carriage (less friction and other losses), which is way more than the belt is rated for; with the slightly larger 20-tooth GT2 pulleys, it's about 30.5 lbf (14 kgf). However, it's not a waste: the torque decreases at higher speed, so having a lot of it to begin with is useful.[2] Further discussion of maximum useful motor size in Re: Mr. JwC's eShapeoko.

1.7--2A would be a good current rating for use w/ a gshield[3]

Please note that NEMA 17 motors are available w/ 1/4" shafts instead of the more typical 5mm which is assumed in these plans --- if such motors, or NEMA 23s are used, you will need to source pulleys and/or a flexible coupler w/ a matching i.d.

The Shapeoko 3 standardized on 125 oz./in. motors:

Typically stepper motors and stepper driver chips are rated for ~10,000 hrs. of operation.

Step Size

Motors will also be rated for the number of steps per revolution, w/ two main options:

  • 0.9° per step (400 steps per revolution)
  • 1.8° per step (200 steps per revolution)

A 1.8° motor is faster and more powerful than a 0.9° motor of the same size and current rating. A 0.9° motor is more accurate, in a way that can not be made up by increasing microstepping. For instance, a 1.8° motor with 16× microstepping has almost twice the positioning error of a 0.9° motor with 8× microstepping under the same load, despite both having the same microsteps size (0.1125°, or 3200 microsteps per revolution).

Grbl will accurately track the machine’s state, and when it has been unable to hold a given position due to said position being in-between steps at point(s) where the machine can’t accurately hold it will include that deviation in the reported machine position.[4]

No cost difference between 200 and 400 step-per-rev motors, but, for the same price, size and rated current, the 200 step-per-rev is going to have about 30% more torque.[5]

Detailed discussion on selecting motors:

Is there any formalized system to determine the power needed for motors?

Yes, there is and it's fairly simple. First, I assume you will be using leadscrews to convert rotary motion (the motor) to linear motion. Power is measured in Watts and mechanical power is force times velocity or torque times RPM.

1) Start by estimating the torque needed. Imagine the machine is manual one with hand cranks and use your experience to estimate how many lbs of pressure you would ever apply to the crank handle for the heaviest load. Multiply that by the radius of the crank handle and multiply again by 16. Your result is the maximum torque (in-oz) you need on the screw.

Example: Let's say it's 10 lbs on a 2" radius crank handle. Torque is 10 lb times 2" times 16 or 320 in-oz on the screw.

2) Have an idea of your feedrate in inches per minute for this load.

Example: You want 30 IPM and you are using a 5 turns per inch leadscrew. Leadscrew RPM equals TPI times IPM so 5 TPI times 30 IPM is 150 RPM.

3) Power in Watts equals RPM times in-oz divided by 1351. Plug in 150 RPM times 320 in-oz and divide the result by 1351. the result is you need 35.5 Watts mechanical at your feedrate.

4) The screw type matters. A ballscrew is 95% efficient while an acme thread is about 50% efficient for a 5 TPI screw. As TPI goes up, efficiency goes down.

5) NEMA-23 step motors are good for about 100 Watts and NEMA-34 motors are good for about 200 Watts mechanical. You need 35.5 Watts so a NEMA-23 motor is a contender at your feedrate.

6) What kind of a rapid IPM can you get? This is governed by your system friction and the screw's critical RPM. System friction can be measured using a fish-scale and a pulley on the leadscrew. Wind a few turns of fine filament fishing line on the temporary pulley and attach the other end to the fish-scale. Pull until you reach break-away force and record it.

Example: You have a 1" diameter pulley and your fish-scale shows 40 ounces at break-way (the screw begins to turn). Torque to overcome friction is 0.5" times 40 oz or 20 in-oz.

Next, re-arrange equation (3) to solve for IPM. The equation becomes RPM equals 1351 times Watts divided by in-oz. Use 100 Watts for the power (that's what a NEMA-23 can deliver when driven hard) and plug in the numbers 1351 times 100 Watts divided by 20 in-oz. The result is a crazy 6,755 RPM or 1351 IPM.

This number is way past your screw's critical RPM and only indicates your NEMA-23 will be 'fast enough'. My guess is your screw's critical RPM will be about 1500 RPM if you are lucky. This will limit your rapids to about 300 IPM.

7) Reliability. Step motors are open-loop (no feedback) so it's prudent to design in at least a 50% torque margin. Let's make it 100% just for fun. You get this by using a larger NEMA-34 or, you can use a 2:1 toothed belt and pulley reduction to the leadscrew.

8) Choice of motor. I would pick a 3.5 amp per phase (about 3mH inductance) NEMA-23 motor in the 400 in-oz holding torque range and run the drive with a 48VDC power supply. This is fairly aggressive (warm to hot motor) but you will get 100 Watts.

9) Choice of motor drive. Don't skimp on the drive; it should be a microstepping drive that has electronic mid-band resonance compensation with adequate supply voltage and phase current ratings. Many bargain drives get all delicate and blow up if you run them near their maximum ratings.

The advantage is vibration damping and the ability to change the gear ratio easily. Finally, gearing better matches the motor to the load by trading in unneeded speed for more torque. I don't recommend direct (1:1) coupling the motor to the screw unless it's absolutely necessary.

Mathematical formulae and numbers for using NEMA 17 w/ ballscrews:

Power supply rating

Stepper motors are rated per coil, so a simplistic calculation (using 2.5A) would yield 20 A for four motors (two coils each). However, both coils aren't driven at the same time at the maximum current (it varies between 2.5 A in one coil and nothing in the other, to 1.75 A each (70% of 2.5 A) through both coils). What's more, the drivers chop the current, so they can take a relatively low-current, high-voltage supply and output a higher current at a lower voltage into the load. The supply current depends on several factors that make it difficult to calculate, and varies with motor speed and load.[6]

The driver acts as two buck power supplies, one for each motor coil (well, more complex than that because they have H-bridges, so they can reverse polarity, but that's besides the point). Such a supply takes a relatively high voltage at a low current, and, by chopping it (turning a switching element on an off very quickly) and using an energy storage element (normally a coil, but the motor's own coils do the job in this case), it turns it into a higher current at a lower voltage.[7]



Thingiverse: Experimental 3D Printable Nema 17 Stepper Motor


Page detailing mathematical formulae for Selecting the Proper Size Stepper Motor.

The Shapeoko 3 is specced for 2.6V motors. Motors with rated coltage: 3V, rated current: 2A/Phase "would be fine"[8]


See this page for information on wiring stepper motors.


Often JST PHR-6 connector (2mm spacing) or JST-XHP-6 (2.54mm) [9]

Colour Coding

There are three prevalent color codings for 4-wire bipolar stepper motors, and one of them is used much more than the other two. If your wires are red, blue, green and black, then red and blue are a pair and green and black are another pair. (The other codings are brown, orange, red, yellow; and red, red with white stripe, green, green with white stripe.)[10] Other colour coding(s) include: red, blue, green, yellow.

Stepper motors connected.jpg


When trouble-shooting stepper motors, one can measure the coil resistance (a few ohms, see the motor's datasheet) between red and blue, and the same resistance between green and black. Any other combination (e.g. red and black) should measure open circuit.[11]

Video which purports to show "how to test bipolar stepper motors without a driver circuit, power source, or multimeter":

From a mechanical standpoint, consider filing a flat in the shaft if the motor shaft doesn’t have one (put a plastic bag over the motor, push the haft through the bag, file the flat using a vise or pliers to hold the shaft, then clean up filings before removing the motor), mark the pulley and shaft so that it is easy to check if the pulley has shifted.


There are several things which can reverse an axis:

  • Z-axis-specific (for the Shapeoko 3) --- having the plate upside down --- the static pulley should be on the left when viewed from the front of the machine
  • Y-axis-specific (for the Shapeoko 3 for axes which have two opposing motors)--- having the two Y-axis connectors swapped at the board --- power down and swap them
  • Wiring --- stepper motors can be reversed in several ways --- review the below and rearrange the errant axis to match the other wires if applicable
    • swapping a pair of wires
    • swapping the wires in a pair (left-most/right-most pair)
    • reversing the order of all four wires
  • Software can be used as --- pre-calculated values at:

Shaft Sizes

NEMA motors can have a lot of different shaft sizes.

Normally, NEMA 17 motors have 5mm shafts, but some rare motors will have 1/4" shafts. NEMA 23 motors have typically 1/4" shafts.

NEMA 23 = Flange size of 2.3", w/ the most common being a NEMA 23D025, with the '25' part indicating a 1/4" shaft, but that's only the DEFAULT shaft number.

A NEMA 23D020 is also a viable motor, and then it has a 0.2" shaft, which is close enough to 5mm that it makes no difference.

Metric NEMA motor definitions start with the shaft diameter rather than the flange size.[12]


Decay c.f., [13]



Further Notes and Discussion

Stepper motors have both permanent and electromagnetic magnets in them, and when turned function as generators. When pushed one will feel the resistance of the various magnets as the belt-driven pulley rotates the motor shaft.[15]

Discussion of bearings:

Comparison w/ Servo Motors:


From the forum thread Re: What Causes Z-axis Motor to Skip Steps?

Here are the physics of stepper motors in great detail:

The steppers have a torque curve that diminishes with speed, for several reasons. The nature of the construction is that the coils exhibit inductance and reactance.

The inductance sets the rate at which the magnetic fields can be saturated with flux. At high speeds the fields don't have enough time to fully saturate. This is compounded when changing directions like your z moves in 3d as the fields have to each load up and unload twice when reversing polarity.

The inductive reactance of the motors affect the driver as speed increases. At low speeds they are driven with current, but as speeds increase they are driven with voltage Instead of current and the driver introduces a phase lag. A 180 degree phase lag driven over unity is the textbook definition of an oscillator. When the motor oscillates and approaches its mechanical resonance it will start growling or buzzing just before it stalls.

The point in the torque curve where constant torque changes to inverse torque with speed is called the mid band resonance. It is also the point wher the driver switches from current to voltage. Resonance also occurs at low speed but is usually minimized with micro-stepping. It also occurs in harmonics of the resonant frequency.

To maximize torque and speed you need to drive the steppers with the highest voltage power supply that your driver can use. The mxl belts help to mechanically dampen the resonance in the Shapeoko design. And IC's Z axis upgrade would be an improvement in several ways.

Every stepper and driver system is going to have limits in feed rate settings before stalling, and the real trick is to find the balance between speed and torque allowing for deeper tool moves at lower speeds, or shallow tool depth with higher feed rates. And taking into account the inertia of the axis and tooling mass with regards to acceleration.


Further discussion here: What is a Microstep?

Microsteps and torque:

An additional view, considering the electronics and other aspects: Excellent overview:

Note that there is an upper limit to the number of steps which a system is able to generate. This means that larger microstepping settings necessarily limit the fastest speed which the machine is capable. Tradeoff of speed for precision.[16]

References [17]


It's a little counter-intuitive, because we think of things getting hot when they are 'working' and not sitting still. However, a stepper motor draws the most current when it's sitting still (to lock it into place). So technically, it's 'working' the hardest when it's not moving. It will get quite warm, but isn't a concern (unless you touch it). One thing you could do (but is not necessary) is adjust the pot on the z-axis driver to reduce the current, which will also reduce the temperature. However, you will be reducing the z-axis's torque at the same time, so some testing will be required to find the optimal position. [18]

The z-axis is also hotter because it's not mounted to what is essentially a giant heat sink! The Y and X-motors' heat gets dissipated through the motor mount plate they are attached to. Whereas the z is just floating with 3 little brass standoffs trying to pull heat away from the tiny surface area they are touching.[19]

Discussion in the Forums


  • Higher torque means that a motor can manage to overcome greater resistance without losing steps.
  • Stepper motors produce more power at lower speeds
  • (For larger machines?) 2--3 turns of the motor for each inch of travel is one suggested guideline
  • Step resolutions higher than 1000, typically place unnecessary limits on the machine.
  • Torque is usually specified as stall torque --- Higher quality motors have lower inductance and maintain a larger percentage of their stall torque at higher speeds. It is possible that a cheaper stepper may be rated for a higher torque but not perform as well as a higher quality stepper rated for less torque.[20]
  • Power supply requirements --- 70% of the total amperage is one guideline, but this interacts w/ the voltage of the power-supply as discussed above.[21]

Alternatives and options

Servomotors --- discussion on reddit:


Connect the stepper motors to the stepper shield as shown below.

ShapeOko Schematic.png

Converting Uni-polar to Bi-polar Stepper Motors

To convert Lin Engineering 5718x-05E-03 from uni-polar to bi-polar stepper motors: my original notes from 3 years ago

  • cut the connector off the end of the leads
  • strip off about 1/2" of coating on all 8 wires
  • connect the red/white wire to the solid blue wire (twist them together, then cover with electrical tape or shrink tubing)
  • connect the black/white wire to the solid green wire (twist them together, then cover with electrical tape or shrink tubing)

Now you are left with four wires:

  • black
  • green/white
  • red
  • blue/white

Coil 1 = Black | green/white Coil 2 = Red | blue/white

Make sure none of the 4 remaining wires are touching each other.

  • Spin the motor shaft with your fingers. It should be pretty easy to turn
  • Now, if you touch the coil wires together (i.e. Black -> Green/White) you will feel resistance when turning the motor
  • Same goes if you touch the Red wire to the blue/white wire and attempt to turn the motor shaft