The LCL-active power filter can effectively compensate the harmonic of power grid, and capacitive current proportional feedback active damping is the main way to suppress LCL resonance. However, under digital control, the resonant point will change with the grid impedance, which makes it difficult to select the feedback coefficient. To solve this problem, this paper studies the selection method of feedback coefficient to adapt to the wide range of grid impedance variation, deduces the stability conditions of the system under different feedback coefficients and harmonic frequencies, and on this basis, optimizes the design of feedback coefficient to meet the requirements. With the increase of the grid impedance, the LCL resonant frequency becomes smaller and the system bandwidth becomes narrower, When the traditional quasi PR control is used to compensate the high order harmonics, the phase frequency curve of the system is easy to cross the -180o line at the resonance point of the controller, which leads to the instability of the system. In this paper, phase compensation is proposed to improve the phase angle at the gain of the controller, and the detailed design method is given. Theoretical analysis shows that the proposed robust controller optimization design method can improve the operation range of active power filter to 0.5fs while ensuring good harmonic compensation capability. Simulation and experimental results verify the correctness of the theoretical analysis.