A wave shaping, filter and residual voltage removing circuit, consisting of: a comparator, a second voltage divider consisting of a series connection of a third resistor and a fourth resistor and comprising a first, a second and a third terminal, a capacitor comprising a first and a second terminal, a fifth resistor comprising a first and a second terminal, and a first transistor having a base, and a first and a second terminal, wherein an input of the wave shaping, filter and residual voltage removing circuit is connected to the first terminal of the second voltage divider, the first terminal of the capacitor, and the first terminal of the fifth resistor, and configured to receive a full rectified sine wave signal, wherein the second terminal of the second voltage divider, the second terminal of the capacitor and the second terminal of the first transistor are all connected to ground, wherein the first terminal of the first transistor is connected to the second terminal of the fifth resistor, and wherein the comparator has a first input connected to the third terminal of the voltage divider, which is a node between the third resistor and the fourth resistor, a second input for connection with a reference full rectified sine wave generator, and an output connected to the base of the first transistor, wherein the comparator is configured to compare the full rectified sine wave signal with a reference full rectified sine wave signal, provided by said reference full rectified sine wave generator, and drive the base of the first transistor so that an output of the wave shaping, filter and residual voltage removing circuit follows the reference full rectified sine wave signal, hence removing a residual charge from the capacitor. a comparator, a second voltage divider consisting of a series connection of a third resistor and a fourth resistor and comprising a first, a second and a third terminal, a capacitor comprising a first and a second terminal, a fifth resistor comprising a first and a second terminal, and a first transistor having a base, and a first and a second terminal, wherein an input of the wave shaping, filter and residual voltage removing circuit is connected to the first terminal of the second voltage divider, the first terminal of the capacitor, and the first terminal of the fifth resistor, and configured to receive a full rectified sine wave signal, wherein the second terminal of the second voltage divider, the second terminal of the capacitor and the second terminal of the first transistor are all connected to ground, wherein the first terminal of the first transistor is connected to the second terminal of the fifth resistor, and wherein the comparator has a first input connected to the third terminal of the voltage divider, which is a node between the third resistor and the fourth resistor, a second input for connection with a reference full rectified sine wave generator, and an output connected to the base of the first transistor, wherein the comparator is configured to compare the full rectified sine wave signal with a reference full rectified sine wave signal, provided by said reference full rectified sine wave generator, and drive the base of the first transistor so that an output of the wave shaping, filter and residual voltage removing circuit follows the reference full rectified sine wave signal, hence removing a residual charge from the capacitor.