Automatic calibration for servo