# Calculating steps

This is an area of setting up a CNC machine that quite often confuses users, so hopefully this guide will help clarify the process behind calculating the number of steps per unit.

Why do you need to calculate steps?

Whenever you command a move within the CNC software, the software needs to know how many steps, or pulses, it has to send to the drives in order to achieve the requested movement. The common name for this setting is “Steps per unit”. The term unit is used, as most controllers can be configured in metric (mm) or imperial (inches).

How to calculate the steps per unit.

This is where things can get confusing, but all it takes is to logically think through each stage of the drive system, which I’ve broken into the following key steps-

1. Lead screw or mechanical drive pitch.
2. Drive ratio
3. Motor Steps
4. Motor driver ratio

For simplicity, this article will use a metric system, so where “unit” is mentioned, it will refer to one millimeter.

1. Lead screw or mechanical drive pitch
For this you need to work out how many turns of the drive mechanism it takes to move one unit.  This is relatively easy for a leadscrew or ballscrew, as the pitch is usually stated, however if you are using a belt or rack drive, it takes little bit more thought and calculation.
For a metric leadscrew system, simply divide 1 by the pitch, so for a 5mm pitch screw, we now know it takes 1/5th or 0.2 turns of the screw to move 1mm.
For a belt, or rack system things are little bit more complicated. If we are using a belt/rack with a tooth spacing of 4mm, and a driving pulley/pinion with 20 teeth, we can calculate that for each turn of the driving pulley/pinion, our machine will move 20 times 4mm or 80mm, which is our effective axis pitch. We then divide our unit by our effective pitch to give us our number of turns per unit, which will be 1/80 or 0.0125 to move 1mm.

2. Drive Ratio
If you’re using direct mount for your motors, or are using toothed belts with identical size pulleys, then you can ignore this, as you’ll be using a direct drive or 1:1 drive ratio.
However if you are using different sized pulleys, or some other method of gearing, then you need to know the ratio between the motor and the drive system.
For belt/gear drives, simply divide the number of teeth on the driving pulley/gear (the one on the drive system) by the number of teeth on driven pulley/gear.
So if we continue the belt/rack example from the previous example, and say we have a 10tooth driving pulley on the motor, with a 40tooth driven pulley, we get a 40/10 or 4:1 ratio.
Now applying those to the previous step, using the direct driven leadscrew, we still have 0.2 turns of the motor shaft per mm.
But using the belt/rack example with it’s 4:1 ratio, we need to multiply the previous figure of 0.0125 by 4, which gives us 0.05 turns of the motor shaft to travel 1mm.

3. Motor Steps
We now need to work out how many motor steps it takes to move one unit.
For your typical hybrid stepper motor, it has a step size of 1.8deg or 200 steps per revolution. There are other step resolution motors available, but for the vast majority of motors sold for CNC use, they are 200step per rev.
If you are using servo motors, then simply substitute motor steps per revolution in the above examples with the servo encoder counts per revolution.
So using our above examples, we simply multiply our motor turns per unit/mm from the previous steps by 200.  For our direct drive leadscrew, that gives us 0.2×200 or 40 motor steps per unit/mm, and for our belt/rack system, we get 0.05×200 or 10 motor steps per unit/mm.

4. Motor driver ratio
For stepper motors, the most common term for this is microstepping. I won’t explain the fully the reasons for microstepping here, just how it applies to our calculations, but in simple form it is the function provided by stepper motor drivers, where rather than the drive moving the motor in whole steps of 1.8deg at a time, it multiplies this and moves the motor gradually in microsteps. The microstep setting is the number of these microsteps it takes to move one complete motor step. So for example with a setting of 8, it will take 8 steps of input into the driver, for it to move the motor one whole step, or 1.8deg for a typical 200 step motor.
For servo systems, things can get a bit more complicated. Some servo systems use the encoder count directly, so this step doesn’t apply (i.e. your motor steps per unit from the previous step is what you would use), whereas other drives allow you to apply a gearing/ratio between the controller and motor encoder. If this is the case, you would then apply that gearing/ratio as you would for a typical stepper driver.
So continuing the examples above, we’ll add a microstepping driver set to 8 microsteps to each system. For out leadscrew system, that means multiplying our 40 motor steps per unit/mm by 8 to give us 320 microsteps per unit/mm, and multiplying out belt/rack system with it’s 10 motor steps per unit, gives us 80 microsteps per unit/mm.

Hopefully this article will of helped clarify this part of the process for setting your CNC controller, but if you’re still unsure of your calculations or need advise regarding any other part of your drive system, feel free to post in the forum for advice.