Steps per mm

From Amber Spyglass Ltd
Revision as of 02:32, 24 February 2021 by Admin (talk | contribs)
Jump to navigation Jump to search

When setting up GRBL, it requires a steps per mm value for each axis.

To move your motors, GRBL (running on the Arduino) generates electrical pulses on the "STEP" input of the drivers. To move one millimetre, it will generate as many pulses as your steps per mm setting. So how many pulses per mm?

In the old days, each pulse would turn the motor one step. It did this by flipping the direction of the current in one of its two windings; the next pulse would flip the polarity of the other winding, then the first one again, and so on. The order of the polarity flips controls the direction of rotation. Common step sizes are 1.8° (200 steps per revolution) and 0.9° (400 steps per revolution). That means there are 200 (or 400) equally spaced positions at which the shaft of your motor can sit, and each step pulse tells the motor to turn to the next position.

Modern drivers, however, support microstepping. This feature gives the driver finer control over the winding currents, beyond full-on and full-on-backwards. By using this finer control, a microstepping driver can position a hybrid stepper motor between steps. For instance, 8× microstepping (also written 1/8) divides each step into 8 equal intervals. Each pulse causes the motor to move 1/8 of a full step, so a 200 step-per-revolution motor takes 1600 pulses (microsteps) for a complete revolution. Microstepping dramatically increases the positioning resolution, but it does not increase the absolute positioning accuracy against a load. A 1.8°-per-step motor at 8× microstepping is not the same as a 0.9°-per-step motor at 4× microstepping, even though both need 1600 pulses per revolution: assuming the same torque rating and the same load, the latter has half the error (deviation from the commanded position). In other words, microstepping increases precision, but not accuracy. Microstepping does not change the torque the motor can generate, but it makes motion smoother and quieter, which is good even if the extra resolution is not needed. There is very little benefit beyond 16×, because the absolute positioning error due to load and sticktion makes the finer positioning resolution irrelevant. That said, drivers exist that can do 256× microstepping, or more, but there are very few applications where that is useful.

The name steps per mm in GRBL is confusing because it actually refers to the microstep pulses, not full steps. It should really be pulses per mm, or maybe microsteps per mm. I'll use the former — it's clearer.

You would probably use the same type of motor and the same type of drive on the X and Y axes. That's not an hard requirement, but it makes sense. However, if your machine has two motors on the same axis (usually the Y), those two must be of the same type. Your Z axis is likely different; even if it's the same motor as the X and Y, the drive is likely different. So you need to calculate a steps per mm setting for the X and Y axes, and a different steps per mm setting for the Z axis.

As an example, assume 400 step-per-revolution (0.9°-per-step) motors on all axes, with X and Y set to 16× microstepping and the Z axis driver to 4× microstepping.

If you have a standard eShapeoko of recent vintage, your X and Y axis pulleys have 20 teeth. The pitch of GT2 belt is 2 mm (the 2 in the name), so one turn of that pulley moves the carriage 40 mm. Your motor driver needs 16 × 400 = 6400 pulses per turn. So, to advance 1 mm, it needs 6400 / 40 = 160 pulses per mm.

On the Z axis, the stock eShapeoko has a Tr 8 × 2 screw. That's a pitch of 2 mm (again, the 2 in the name). One turn of the Z motor moves that axis only 2 mm. The Z motor driver needs 4 × 400 = 1600 pulses per turn, which gives 1600 / 2 = 800 pulses per mm.

In short:

X and Y axes

 start with:  microstepping:   16 pulses /  step
 multiply by:         motor:  400  steps /   rev
 divide by:          pulley:   20  teeth /   rev
 divide by:      belt pitch:    2     mm / tooth
 
 gives:        GRBL setting:  160 pulses /    mm

Z axis

 start with:  microstepping:    4 pulses /  step
 multiply by:         motor:  400  steps /   rev
 divide by:     screw pitch:    2     mm /   rev
 
 gives:        GRBL setting:  800 pulses /    mm

Please change these calculations to suit your settings. For the eShapeoko, 16× microstepping on X and Y and 4× on the Z is a good starting point. If you have 400 step-per-revolution motors, X and Y can also be 8×. On the Z axis, if you have a 200 step-per-revolution motor, or you need finer vertical positioning, 8× works well too. Too high microstepping limits the maximum speed (GRBL can generate only about 30,000 pulses per second) and does not improve anything.