This paper presents a new control algorithm for an active power filter (APF) to compensate harmonic and reactive power of a 3-phase thyristor bridge rectifier under non-ideal mains voltage scenarios. Sensing load current, dc bus voltage and source voltages compute reference currents of the APF. APF driving signals are produced with these signals via a hysteresis band current controller. Matlab/simulink power system toolbox is used to simulate the proposed system. The proposed method's performance is compared with conventional instantaneous power (p-q) theory. The simulation results are presented and discussed showing the effectiveness of the control algorithm. The proposed algorithm is found quite satisfactory to compensate the reactive power and harmonics under non-ideal mains voltage conditions. The increased performance of the active power filter under different non-sinusoidal mains voltage and dynamic load conditions are extensively demonstrated. (c) 2005 Elsevier B.V. All rights reserved.