If only it were that simple. Backlash compensation motion cannot happen in zero
time, so you have to figure out what to do with the other axes while the reversing
axis is making the compensation move, and then keep the system happy while
accomplishing this non-zero time event that was not planning for by Mach4.
Even if you can pull it off, this will only work if the only thing moving the machine
is the axis motors. If cutting forces react with the machine to cause motion
across the backlash distance where the axis motor cannot control where the machine
is positioned, then nothing the software can do will fix this. Likewise any pauses
inserted by the correction attempt will allow for the cutter to remove extra
material at that position while the forces stored in the springs of the elements
of the machine that have flexed will get the chance to relax during the pause as
the cutter removes material. This can result in divots or burn marks in the workpiece.
Backlash compensation can help in some cases, but it is no replacement for a properly
designed and built machine.
Surely Backlash is not that complex:
GetNextCoordinate(Coord, dirChange);
if dirChange
then
ApllyComp(Coord)
fi;
MakeMove(Coord);