If the fault declares a Z fault error, I would think you do not have continuity on your encoder marker pulse wiring.
If you do not have the wiring schematic, look at copying one of the other axis, which may be a good idea anyway, if this one was full of carbon, then there is a possibility the others need attention.
Remember, new brushes $25.00, new Motor because of poor maintenance, $1000.00+.
Al.
CNC, Mechatronics Integration and Custom Machine Design
“Logic will get you from A to B. Imagination will take you everywhere.”
Albert E.