The encoder reading of 0-1-0-1 means you have a loose connection to the encoder. When you move the gantry way over, the strain is pulling on the connectors. Most likely right where the main harness connects to the motor harness. The sockets may be spread open a little. Use a jewelers screw driver or a pick to squeeze them down. It will not be the encoder since it works sometimes.
Your computer has a low voltage parallel port and changing cables and things won't change that.