Smoothing PWM for electromagnet

Paul__B:
Sorry, this is total rubbish.

You cannot use a capacitor to filter PWM in this application. :astonished:

In fact, the whole thread is rubbish. The premise appears to be that by using a very slow PWM, you can make the timing increments small in proportion to the whole cycle. Averaged over a second or so, this is quite true, but now you want it to be averaged and controllable over a smaller period which you cannot have. The two are mutually exclusive. Look up "Nyquist".

There is a distinct XY problem here.

Sir thank you very much you hit the bullseye i was expacting an answer like this scentific clearity.
My pwm is at 30 Hz now.My limit for making it faster 250Hz pwm so will be an interrupt in every 4000 microseconds.Is it enough?