Automatic thread calibration