Biomagnetic fields--in particular in the low-frequency range--are subject to environmental interference, which cannot be adequately reduced by most passive shielding methods. However, the signal-to-noise ratio can be increased by active compensation. For this purpose, the interference is detected by reference sensors and fed back through integrated compensation coils. To establish deviation of normal directions between reference sensors and compensation coils, an angle encoder was developed. The rotation of the reference sensors about two axes at right angles to each other, is converted into voltage pulses by means of codewheels and photoelectric beams. The pulses are counted by incremental encoders, and represent a measure of the angles. A cardanic suspension and a plumb-line act as a reference system. The pulses counted are converted into binary angle values, which are used for coordinate transformation of the interfering fields. The angle encoder can determine the tilt of the reference sensors with an accuracy of 1 degree within a range between -45 and +45 degrees. The noise level of the system remains unaffected during a biomagnetic measurement. Magnetic signals of up to 5 pT arising during the oscillation of the plumb-line can be neglected because of the static nature of the angular measurement.