Read current with ACS712 using PWM

Try a low-pass filter before feeding it to the MOSFET. The cutoff frequency should be about an octave less than the PWM frequency.