In order to compensate current harmonic in oil drilling power system, the design, development and experimental investigations of an APF were considered. Based on Fourier transform, a direct harmonic analysis algorithm was designed to identify and track harmonics. Compared with traditional FFT, the proposed algorithm was less dependent on hardware and could be used to for selective harmonic compensation. The laboratory prototype of the APF system was designed and implemented, which was tested in different operating conditions with nonlinear loads to demonstrate its effectiveness and capabilities for harmonic elimination. All experimental results are given and discussed in detail, which validate the proposed APF.