*How to calculate motor steps and update your firmware settings.*

We recently posted some of our custom stepper motors for sale. They are 0.9 degree NEMA 17s and we've been fantastically pleased when using them for our own projects, but we have had several people ask - "How do I make these work with my printer?". The reason is this - despite having higher step accuracy, 0.9 degree steppers are somewhat less ubiquitous than 1.8 degree steppers, so the default settings for most firmware assumes you are using 1.8 degree steppers.

Being able to change the stepper motors, or your extruder for that matter, requires that you configure something called the Steps per Unit of that specific axis. Generally speaking, Steps per Unit means the number of steps it takes to travel, well, one 'unit', which is normally one millimeter - in the case of the extruder this is the number of steps it takes to push one millimeter of filament through the print nozzle.

### What to Change in the Firmware

In the current version of Marlin, the line you are looking for is in the 'Configuration.h' file:

`#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1}`

What does this mean? Well there are four values. The axis steps per unit of the x, y, and z axes, respectively and the steps per unit of the extruder. Broken out, it would look something more like this:

`#define DEFAULT_AXIS_STEPS_PER_UNIT {AXIS_STEPS_PER_UNIT_X, AXIS_STEPS_PER_UNIT_Y, AXIS_STEPS_PER_UNIT_Z, AXIS_STEPS_PER_UNIT_E}`

Each of these values is calculated separately. For belt driven axes (usually x and y), the steps per unit is determined by the number of steps per revolution divided by the idler teeth, divided by the belt pitch (ie the spacing between teeth):

`Steps per Unit (X and Y Axes) = Motor Steps per Revolution / Idler Teeth / Belt Pitch`

For threaded rod driven axes, steps per unit is calculated as steps per revolution divided by the pitch of the rod:

`Steps per Unit (Z Axis) = Motor Steps per Revolution / Rod Pitch`

For geared extruders, the calculation is steps per revolution times the gear ratio divided by the pinch wheel diameter times pi:

`Steps per Unit (Extruder) = `

`Motor Steps per Revolution * Extruder Gear Ratio / (Pinch Wheel Diameter * Pi)`

### Decoding Steps per Motor Revolution

The variable in these equations that is determined by your motor is 'Steps per Motor Revolution' which is the number of steps it takes for the motor to make one, full, three-hundred sixty degree turn. For a 0.9 degree stepper this would be 360°/0.9°, or 400 full steps. But wait! We also have to factor in microstepping - this is usually done in 1/8 or 1/16 increments (Pololu drivers are 1/16th).

So 400 full steps divided by 1/16 microstepping would be 6400, which represents the number of microsteps it takes for the motor to make a full revolution. A 1.8 degree motor at 1/16th microstepping would take 3200 microsteps to make a full revolution.

### Putting it all Together

For a 0.9 degree motor using 1/16th microstepping with a 5mm pitch belt and a 8 tooth gear, the steps per unit would be: 6400 steps per revolution, divided by 5, divided by 8, or 160 steps per unit (in this case millimeters).

Once you've set the steps per unit in the firmware and loaded the updated firmware onto your board you'll want to do a calibration print to ensure that you've got everything right. This 20mm x 20mm x 20mm Hollow Calibration Cube does the trick nicely.

Even in the context of putting together a 'vanilla' build of a RepRap printer it can be a good idea to take a look at the Steps per Unit settings to make sure it aligns with your own hardware. For example, the difference in the required settings between metric 5mm belting and 0.2" XL belting is subtle enough that you probably wouldn't notice it offhand, other than as that nagging feeling we often encounter - "It seem like this print could be better...".

In the interest of clarity, in our firmware branch - MatterPrint3D, we have replaced the following line:

`#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1}`

With:

`#define STEPS_PER_REVOLUTION_X 3200`

`#define STEPS_PER_REVOLUTION_Z 3200`

`#define STEPS_PER_REVOLUTION_E 3200`

`#define STEPS_PER_REVOLUTION_Y 6400`

`#define IDLER_TEETH_X 8`

`#define IDLER_TEETH_Y 8`

`#define BELT_PITCH_X (.2 * MM_PER_INCH)`

`#define BELT_PITCH_Y (.2 * MM_PER_INCH)`

`#define PITCH_OF_Z_ROD 1.25`

`// makergear extruder box`

`#define EXTRUDER_GEAR_RATIO 13.0`

`#define PINCH_WHEEL_DIAMETER 11.59`

`#define AXIS_STEPS_PER_UNIT_X (STEPS_PER_REVOLUTION_X / IDLER_TEETH_X / BELT_PITCH_X)`

`#define AXIS_STEPS_PER_UNIT_Y (STEPS_PER_REVOLUTION_Y / IDLER_TEETH_Y / BELT_PITCH_Y)`

`#define AXIS_STEPS_PER_UNIT_Z (STEPS_PER_REVOLUTION_Z / PITCH_OF_Z_ROD)`

`#define AXIS_STEPS_PER_UNIT_E (STEPS_PER_REVOLUTION_E * EXTRUDER_GEAR_RATIO / (PINCH_WHEEL_DIAMETER * PI))`

`#define DEFAULT_AXIS_STEPS_PER_UNIT {AXIS_STEPS_PER_UNIT_X, AXIS_STEPS_PER_UNIT_Y, AXIS_STEPS_PER_UNIT_Z, AXIS_STEPS_PER_UNIT_E}`

**UPDATE:**

Don't feel like calculating all this yourself? Josef Prusa has created two excellent web-calculators: