A control system (401,501) for compensating electrical harmonics on an electrical grid (202,610), where the electrical grid (202,610) is powered by at least two power generating units (601,602,603) connected to a point of common coupling of the grid, where each power generating unit (601,602,603) includes a power inverter for injecting current to the grid, the control system (401,501) includes, - an impedance detector configured to determine impedance peaks by repeatedly performing a scan of the impedance at the point of common coupling over a frequency range, and configured to determine resonance frequencies from determined impedance peaks, - a first harmonic compensator (210,410) configured to determine first and second control inputs for the inverter of the first generating unit for controlling generation of active and reactive currents by the inverter of the first generating unit, - a second harmonic compensator (210,410) configured to determine first and second control inputs for the inverter of the second generating unit for controlling generation of active and reactive currents by the inverter of the second generating unit, - characterised in that the impedance detector is configured to distribute the information related to the determined resonance frequencies among the two harmonic compensators (210,410), such that the first harmonic compensator receives a first range of harmonics to be compensated and the second harmonic compensator receives a second range of harmonics to be compensated, - the first harmonic compensator is configured such that the control inputs for the inverter of the first generating unit are determined on basis of information related to the first range of resonance frequencies such that the current generated by the inverter of the first generating unit is capable of compensating the first range of electrical harmonics at the first range of frequencies, - the second harmonic compensator is configured such that the control inputs for the inverter of the second generating unit are determined on basis of information related to the second range of resonance frequencies such that the current generated by the inverter of the second generating unit is capable of compensating the second range of electrical harmonics at the second range of frequencies. - an impedance detector configured to determine impedance peaks by repeatedly performing a scan of the impedance at the point of common coupling over a frequency range, and configured to determine resonance frequencies from determined impedance peaks, - a first harmonic compensator (210,410) configured to determine first and second control inputs for the inverter of the first generating unit for controlling generation of active and reactive currents by the inverter of the first generating unit, - a second harmonic compensator (210,410) configured to determine first and second control inputs for the inverter of the second generating unit for controlling generation of active and reactive currents by the inverter of the second generating unit, - characterised in that the impedance detector is configured to distribute the information related to the determined resonance frequencies among the two harmonic compensators (210,410), such that the first harmonic compensator receives a first range of harmonics to be compensated and the second harmonic compensator receives a second range of harmonics to be compensated, - the first harmonic compensator is configured such that the control inputs for the inverter of the first generating unit are determined on basis of information related to the first range of resonance frequencies such that the current generated by the inverter of the first generating unit is capable of compensating the first range of electrical harmonics at the first range of frequencies, - the second harmonic compensator is configured such that the control inputs for the inverter of the second generating unit are determined on basis of information related to the second range of resonance frequencies such that the current generated by the inverter of the second generating unit is capable of compensating the second range of electrical harmonics at the second range of frequencies.