ACS712 current reading on 20kHz PWM

Hi there!
I’m using a nano and a ACS712 (20A) to read the “instant current” of a PWM driven motor and I get very unstable readings… After trying different ACS chips and comparing to a series installed multimeter and a amp-clamp (showing both the same value) I came to the conclusion that the problem was the PWM. The ACS showed the same value as the amp-clamp and the multimeter “from time-o-time”

Some specifications:

  • I’m using the PWM frequency library from runnerup to set 20kHz PWM
  • The usual values I read are between 0 and 5 amps
  • In my code I have apply a moving average to my readings and at an specific duty cycle I get a factor of 3 less current reported by the ACS than the “real” values… —> This factor changes at a different duty cycle.
  • (In case you ask) I’m using 20kHz because under that value I get wining noise and yes, I got a MOSFET with a huge heatsink
  • the main purpose of the current reading is to stop the motor if consumption goes higher than the safety limit.

So my questions would be:

  1. How the amp-clamp and the multimeter do to read he current value in such conditions? I mean, do they take systematically the highest value?
  2. Who is actually showing the “real” value? because if amp-clamp and multimeter are showing max values and with ACS I’m averaging a bunch of samples, I’d believe the ACS is closer to reality and that the real calculation would be MaxAmp*DutyCycle[%]
  3. Any advise in how to read this?

The amp clamp uses a multimeter circuit with an integrating ADC, which low-pass filters the signal to a very low bandwidth (1Hz or so) - this will filter out all the PWM transients completely.

The ACS sensor has about 100kHz frequency response or so (unless low pass filtered externally), and will see the PWM interference. Normally the current in a PWM motor winding is a triangular wave so the instanteous readings will fluctuate over a range.

What value of filter capacitor do you have on pin 6 ? Try 100nF or larger, this may improve things.

I'm using the same current sensor for an undergraduate research robot here at VT, except I'm using a servos instead of plain DC motors. How I did it was to use a difference opamp circuit to take away most of the 2.5V bias, buffered the output, fed the buffered output to a LPF with a 25Hz cutoff frequency and then sampled the waveform at 100Hz using a 16bit external ADC. Works like a charm.

Thank you both for your answers! I really appreciate it.

I’m not home now, I’m on a business trip, but I’ll try to answer.

I’m not using the chip, I’m using it in a module (chinese)
I’ll try to read the reference (if any) when I go back home

<Power_Broker> do you have some kind os scheme? I’m not at that level on electronics :frowning:

I was thinking more in a software solution… kind of averaging maximum from a number of samples or something like that…

<Power_Broker> do you have some kind os scheme? I’m not at that level on electronics :frowning:

What is an “os scheme”? Never heard of it.

I was thinking more in a software solution… kind of averaging maximum from a number of samples or something like that…

You can still do that with my type of circuit implementation, BUT you need an analog low pass filter before reading from the ADC either way. This is for two reasons:

1.) it rejects electromagnetic/thermal noise from the environment.

2.) it prevents signal aliasing when sampling with the ADC. Aliasing is a rather difficult concept to understand if you don’t know the basics of signal processing in the frequency domain, but take my word for it; you will need to have a low pass filter with a cutoff frequency no greater than half your sampling frequency. Do that and you won’t need to worry about aliasing.

There are plenty of tutorials and online calculators to figure out how to make such a filter. They aren’t hard to make.

After filtering and sampling via the ADC, you can store the data on an SD card or send it to a PC for logging and then do averaging (unless you really need to do averaging real-time).

sorry, it was a typo. I ment “some kind oF scheme”

Still I have the question about who is showing the “real” value of current, like if I would like to calculate power consumption.
Because I got the feeling that the amp clamp and multimeter are showing the max current value. But the real current consumption would be something like current max value times duty cycle. Please correct me if I’m wrong (and chances are that I am).

It's all good.

The only real way to measure "true" instantaneous current of a non-DC signal is to use a high precision current sensor and monitor it with a high bandwidth oscilliscope (not an amp clamp, not a multimeter, an o-scope). So, basically what I'm saying is that neither is giving an accurate measurement.

If you use the circuit I described in my first reply, you should be able to get your output good enough. Attached is a schematic I used for my research as a reference. (EDIT: My RC filter has a cutoff around 50Hz, not 25Hz as previously mentioned. You can change the cutoff frequency easily and perhaps change it from an RC to a Butterworth Filter for better results)

Current-Measurement-Circuit.pdf (48.9 KB)