We describe a simple method for high-precision rotary angle encoder calibration for long-range angular errors. By using a redesigned electronic nulling autocollimator, an optical-polygon artifact is calibrated simultaneously with determining the encoder error function over a rotation of 2π rad. The technique is applied to the NIST vacuum double crystal spectrometer, which depends on precise measurement of diffraction angles to determine absolute x-ray wavelengths. By oversampling, the method returned the encoder error function with an expanded uncertainty (k = 2) of 0.004 s of plane angle. Knowledge of the error function permits the instrument to make individual encoder readings with an accuracy of 0.06 s (k = 2), which is limited primarily by the least count and noise of the encoder electronics. While the error function lay within the nominal specifications, it differed from the intrinsic factory curve, indicating the need for in situ calibration in high-precision applications.