Hi Karl - I am new to this forum and was just looking at your thread routine. I have written a couple of multipass thread routines for camsoft lathes, including one that will cut taper threads like NPT. It looks like my routine is a little simpler that yours - I don't know if that's good or bad? To get away from having to use fudge values (because they will be slightly different for each pitch) you need to make the ratio for x and z the same. This can be accomplished by gearing the encoder to the ballscrew and calculating a gear ratio to get the ratio setting in cncsetup the same for both axes.
Just curious - what is the diameter and pitch of the threads you are using this code for, and what RPM do you thread at?