# Sensing current upto 2A w/ high resolution

I'm trying to sense a current that will flow in a motor (current shouldn't exceed 2Amps), and I'd like to have a high resolution on this measurement. I was hoping on using the ACS712, but it says the precision is 185mV/A. Since the current in my applicaiton won't exceed 2A, it means 185*2 = 370mV (right?)

I'm using a STM32F4 with 12bit ADC which means with a Vref of 3.3V it's an increment each 0.8mV. So in the end I'll get a resolution of 463 steps.

Is there a way to get a higher resolution ? I don't really like the idea of a shunt resistor, maybe an amplificator could do the trick but will I be able to get a precise measurement ? (iA is the measurement)

Btw, I'm trying to replace it with an ACS711 which operates on 3.3V but it'll give me only 110mV/A resolution

Here's the Vref+/- connection

• If you want good quality measurements, use the MCU's internal bandgap voltage reference instead of 3.3v as the reference; the 3.3v rail may have 5-10% error as well as noise, swamping any gains from a high quality shunt monitor. Commented Jun 3, 2015 at 8:15
• So you're saying having an op-amp + shunt resistor is the way to go ? Commented Jun 3, 2015 at 8:36
• He's saying that you shouldn't use any rail directly for the reference voltage. If you want to use a 3,3V reference you can use the 3,3V rail but you should low pass filter it (a capacitor from the ref pin to ground, and a resistor from the cap to 3,3V). In your case you do not want 3,3V but something closer to 400mV as a reference for the ADC. You can use a resistive divider to get a lower voltage from 3,3, or use the more precise bandgap reference integrated in the microcontroller.
– jms
Commented Jun 3, 2015 at 8:59
• You can still use that 3.3V to power the MCU, but you should use a reference voltage to define the upper limit for the ADC. Your ADC already has a built-in reference you can use. Its voltage is much more precise, giving more accurate measurements. And due to the 2.5V, the resolution is better in your case. May be, your MCU allows an external voltage reference for its ADC, then you could use something like an AD680 with a 5:1 voltage divider to set the upper voltage for the ADC to 500mV. Commented Jun 3, 2015 at 9:09
• The MCU you're using has an embedded bandgap reference voltage which you can use - no need for an opamp. Commented Jun 3, 2015 at 9:40

## 3 Answers

Most micro-controllers with ADC's have an internal bandgap reference with a voltage of ~1V (see datasheet for more precise values and tolerances; ex.: the STM32F415xx series has a bandgap reference of 1.21V). This effectively increases your resolution to 1253 steps full scale by flipping a software switch.

If you want to do even better, you have a few options:

1. Use an op-amp to amplify the output of your current sensor
2. Use a higher resolution external ADC
3. Use a lower voltage external reference (for example, something like this). Note that a simple voltage divider directly into the vref pin is almost never a good idea.

In none of these cases do you need to change the voltage supply to your microcontroller.

As a side note, I don't understand your aversion to using a shunt resistor. For moderately low currents (few amps) it is the most accurate way to measure currents. For example, the ACS712 chip you've listed has an accuracy of 1%. That means you get an accuracy of 6.64 bits (~100 steps). It is very easy to get shunt resistors with 0.5% accuracy, giving an accuracy of 7.64 bits (~200 steps). Using a 0.1% accurate shunt gives you 9.97 bits of accuracy (~1000 steps).

If you use a very small shunt resistor with an instrumentation amplifier the burden voltage will be negligible. For example, say you have an in-amp with a gain of 100x (very do-able). An appropriate shunt resistor to get 0-1.21V full scale needs a shunt resistor of 6.05mOhms, and will have a burden voltage of 12.1mV. For all intensive purposes this is negligible. You can reduce this even more by using a 1000x in-amp circuit (also very do-able).

• I don't wan't to use a shunt because it looked easier to use the ACS71X. By the way, the reference voltage is internally fixed to supply voltage on this chip. What is the in-amp called on a datasheet ? couldn't find it Commented Jun 3, 2015 at 11:34
• An "op-amp", short for "operational amplifier", "in-amp" was a typo. Commented Jun 3, 2015 at 13:14
• in-amp is short for "instrumentation amplifier". It is like an op-amp, but there are key design differences. Notably, it is designed to provide a very high gain to amplify slight voltage differences between the two inputs while having high impedance inputs. In-amps can be built using op-amps, though in practice you need really good matching if you want good accuracy at high gain, so get a pre-built chip. I've never seen a hall sensor described as "easier to use" than a shunt. Fewer components, maybe but board geometry is extremely important for hall sensors. Commented Jun 3, 2015 at 17:38

You say you want to do "high resolution" current measurement. When you say "high resolution" and then say you're using a 12-bit ADC in a microcontroller, in the same sentence, you're redefining "high resolution. Downward. Anyway, you'll be lucky to get 10-10.5 effective bits, so you're already down to ~1000 codes over full scale (assuming you do what's necessary and amplify your sense measurement so that 2A = "full scale". Is that high enough resolution for you?

If so, then you'll need to follow the advice given in other answers, about choosing an appropriate reference (internal band-gap, or a decent <0.05% external reference, NOT a supply rail no matter how well filtered one might claim to make it), AND use an op-amp to amplify your current measurement with a shunt resistor so that 2A = your reference votlage, and use decent PCB design practises to keep your analog circuitry relatively clean. My interent is bog slow tonight so I can't download a STM32F4xxx datasheet at the moment, but 99.9% it'll support the option to have an external voltage reference.

I would add an op-amp with a gain of 8 to the output of the ACS712, to take advantage of the full range of the ADC in your microcontroller. So 2A would be represented by 8*463 steps = 3704, almost the full range (4096) of the 12-bit ADC with a full-scale voltage of 3.3v.

The LMV321 is a rail-to-rail version of the LM321.

The gain of a non-inverting amplifier is $1 + \frac{R2}{R1}$, or in this case $1 + \frac{93.1}{13.3} = 8$.

Or use an op-amp with a gain of 12 for the ACS711. In that case, 2A would be represented by 12*275 steps = 3300.

• thanks, that's exactly what I did, altough I used a 1K and a 167 resistor ( I prefered to stick with a gain of 7). Is there any reason I should multiply the values of those resistors by 10 or 100 ? I mean I know the gain is 1+R2/R1 but does low resistor values affect anything ? Commented Jun 4, 2015 at 12:54
• I like to use resistors in the range of 10K to 100K or so if possible. Just like Goldilocks, you don't want too small, or too high. Something in the middle is just right. This thread discusses the topic in more detail. In your case, I would now choose R1 = 19.1K and 115K. Commented Jun 4, 2015 at 17:33