The electron density on COMPASS is measured using 2mm microwave interferometer. Interferometer signal is used as an input for the feedback control loop, running under the MARTe real-time framework. Two different threads are used to calculate (fast 50μs thread) and to control (slow 500μs thread) the electron density. The interferometer measures a line averaged density along a measurement chord.This paper describes an approach to control the line-averaged electron density in a real-time loop, using a correction to the real plasma shape, the plasma position, and non-linear effects of the electron density measurement at high densities.Newly developed real-time electron density control give COMPASS the chance to control the electron density more accurately which is essential for parametric scans for diagnosticians, for physics experiments and also for achieving plasma scenarios with H-mode.