A new active power filter and static var compensator is investigated, the digital control algorithm and its software flow chart are given in view of digital signal processor (DSP). The principle of current measurement, the composition and injection of compensation current are discussed in detail. Simulation and calculating results show that the apparatus is valid, and the distorted current can be compensated completely.