You need to earth everything, as for hifi, e.g. take all earth wires/ground wires back to a solid, common star point. Used screened cable, but ensure that the screening/shield is only grounded at one end of the cable. If you're using limit switches, operating at ttl levels, disconnect them, see if things improve.