Optical Table CNC Lathe - Spindle Encoder for Threading

I want to be able to do threading on the lathe. To do this, some synchronization between the spindle and axes is required. I chose to mount an encoder on the spindle motor directly. It has a tachometer built-in, and the motor drive is using that to maintain constant speed regardless of load. But that won't help with threading. I want to be able to do the threading either with the spindle driven by the motor, or manually rotated, like this:


That will help in using the lathe fix gnarled threads, and to re-chuck.

The motor has no provision to mount an encoder, but luckily has a dual shaft:

So I started by designing an adapter in Fusion360:

This is a snug press-fit on those carbon brush screws. I made it with a 3D printer from PETG, and put the encoder, a BEI MX216 with 1000 lines, on the shaft using its mounting instructions.

Everything felt well connected, but one never knows in an environment with vibration, so I secured it all in place using lacquer.

I connected it up to a channel on the Kflop/SnapAMP and it worked right away, with the KMotion showing the counts as I rotated the motor spindle by hand. I thought configuration was going to be difficult, but literally the only thing I had to do in KMotionCNC was to add the encoder data in the KMotionCNC Tool Setup Screen, like this:

Immediately, the G32 sample program that comes with KFlop, ThreadingG32FrontV2.mgc, worked. I could move the motor axis back and forth and the cutter tracked back and forth in lock step. Unfortunately, when trying to actually cut the thread, the synchronization did not work perfectly:

I suspect that the problem is slip on the v-belt that is connecting the motor to the spindle. I ordered some timing belts and pulleys to fix that.

So, I replaced the v-belt sheaves with HTD 5M timing pulleys. I decided to get a 24 and a 12 tooth pulley to get a bit more torque out of the motor. I got an extra 12 tooth pulley in case I need a faster speed in the future.

Of course, that required a change on the encoder setting:

And the result is a nice cut thread:

I can also confirm that the feature I sought at the top of this post works in this way. Here a video of me running part of the threading cycle by hand and then turning on the spindle motor: