Skip to main content

Mach 4 Screw Mapping

Screw Mapping in Mach 4

Mach 4 (after build XXXX) implements symmetric bidirectional screw mapping. Builds after YYYY implement asymmetric bidirectional screw mapping.

DEV: Replace XXXX and YYYY with the appropriate build number.

What is Screw Mapping?

Screw mapping refers to the means by which the CNC compensates for wear, stretch, or other inaccuracies in the mechanical means by which the motors move an axis. It is sometimes called "screw mapping" because CNC machines frequently use ball screws to mechanically link the motor and the axis. The compensation we're discussing works for any kind of mechanical linkage.

The relationship between motor position and axis position is theoretically a linear relationship. In reality, It is not (sufficiently) precisely linear. When the CNC commands the motor to go to position X, we expect that the corresponding axis position, Y. We expect that as X increases, Y will increase in direct proportion (by the encoder counts per unit parameter).

There can be many sources of error that cause this non-linearity.

  • wear on the screw (making the threads farther apart)
  • thread pitch is inaccurate over longer distances

Mapping the Axis

Map Points and Error

Other Parameters

Map Transition Rate (VAL_SCREWMAP_PERCENT_PER)

Mach 4 employs this parameter to determine how quickly the planner transitions from one map to the other (usually when changing directions).

The value the reciprocal of the number of time slices over which the planner should gradually apply more and more of the target map. If you wanted the transition from one map to another to take 50 ms (and your time slice is 1 ms), you would set this parameter to 1 / 50 = 0.02.

Transition Time (ms)Transition RateComment
100.01(Mach 4 default)
20.05 
50.02 
200.005 

The worst case time to transition (to ensure that the transition will not violate the motor velocity/acceleration parameters) can be calculated.

VAL_SCREWMAP_PERCENT_PER__worst_case_formula.pngIf you use this formula, make sure that you use consistent units for time, and then convert the time to milliseconds.

Comparison of Values

Consider what happens when the CNC changes direction and has to switch between two different maps. The G code for this example would look something like

G1 F300
X49
X50
X49

The graphs show motor position (red: no mapping; blue: mapping enabled) as well as velocity, acceleration, and the correction amount applied.

Transfer Time: 100 ms

100 ms

Transfer Time: 10 ms

ScrewMap__Change-Directions__10ms.png

Note: the acceleration of the commanded move is quite high. This would probably cause a noticeable thump in the motion.

Transfer Time: 200 ms

ScrewMap__Change-Directions__200ms.png

Note: the acceleration is lower, but it takes longer to transition to the negative map.