An algorithm to diagnose ball bearing faults in servomotors running arbitrary motion profiles