The harmonic compensation algorithm proposed injects as the difference of source voltage through a series transformers after creating the harmonic compensation voltage by detecting only the harmonic as from the instantaneous active power and instantaneous reactive power passing through the high pass filter which had been applied with the p-q transformation.