A method and apparatus for precisely controlling the rotation of a drill string. A sensor monitors the rotation of the drill string and transmits the rotational information to a computer. The computer controls the rotation of the motor driving the drill string and rotates the drill string through an angle input by the operator. The computer may also utilize the sensor's rotational information to oscillate the drill string between two predetermined angles. The computer may also receive orientation information from a downhole tool sensor. The downhole tool information may be combined with the rotational information to enable the computer to accurately reorient the downhole tool.