Read current with ACS712 using PWM

Hello, I have some problems with the sensor that I am using. The sensor that I am using you can find here. I use the 20A version. The problem I'm having is that the output of the sensor very chaotic is. At first, I thought it is because I'm using PWM to control a MOSFET that's connected to a power supply.
The frequency of the PWM did have some influence on it. for example:

pin9 (uno) 3.9k Hrtz and

pin6 (uno) 7.8k Hrtz.
And came here to ask if you would have an Idea to make the output more stable.

This is the part where members ask you to post an accurate drawing / schematic of your circuit, hand drawn is fine. Also a listing of your code using code tags. This makes it much easier to get good help.

Thank You

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