Re: Code issue, please help. This stopped being fun a few days ago.
Since you have the motor out anyway, pull the encoder off of the motor and rotate the shaft by hand. If it feels rough at any spot, then that may be the problem. Sometimes the bearing gets sticky and will cause what you are seeing.
In some encoders, the actual encoder is mounted on a spring plate inside the housing and if the bearings are sticky, it will bounce in certain spots. On some of the machines that I used to work on, just a small ''tick'' noise as the encoder is rotated was enough to fowl up the whole system. You had to have the encoder right up against you ear to hear this.
It seems that the Datametrics encoders are not available, it would be easy to replace the them with another brand, and the good news is that they are reasonably inexpensive. If it comes to the point of replacing encoders I'll be happy to recommend something if you like. All of the needed information should be on the data plate on the encoder.
I suspect the z-axis picture of what you thought was the encoder, is actually a lubrication tube, protected by a flex conduit.
By the time you get done with this, you are going to be a CNC trouble shooting expert.