2
\$\begingroup\$

I have an Arduino project that provides 12v power to run motors, etc...

I want to be able to measure the current (amps) that the motors are using (0 to 500ma). 12v comes from a battery, but that shouldn't matter. I just have a 12v circuit and I want to measure the current the motors are using (or 0 if they aren't using any).

I don't need a really accurate reading (+/- 30ma would be enough).

I can't use a premade sensor or shield.

I have read about using a shunt resistor and an op comparator (LM311), but I don't understand how I would do that, or if its even the current way to measure.

\$\endgroup\$
  • \$\begingroup\$ to clarify, I want my arduino to be able to measure the current \$\endgroup\$ – Matt Feb 13 '14 at 8:16
  • 2
    \$\begingroup\$ What type of motors are you using? What resolution do you wish? How are the motors driven, what is the circuitry and how can you modify that circuitry? \$\endgroup\$ – abdullah kahraman Feb 13 '14 at 9:04
7
\$\begingroup\$

I have read about using a shunt resistor and an op comparator (LM311), but I don't understand how I would do that, or if its even the current way to measure.

The shunt resistor part is correct, it will crate a voltage drop that is proportional to the current that goes through it (and consequently the motor).
In order to influence the motor current as little as possible you want the shunt resistor the be of a fairly low value. Obviously the same shunt resistor value will introduce a much higher voltage drop in a high current circuit compared to a low current one, so using 0.1 Ohm for 10A will drop 1v while it will only drop 50mV for 500mA

Feeding that voltage to a comparator can only give two states, one when the current is below a specific threshold and another one when the current is above the threshold, like an alert flag.
That is a useful configuration to implement a current limit but not to measure the current level.

On the other hand feeding the voltage to an opamp can amplify it and maintain a linear relation between the input current and output voltage.
A low side circuit using an opamp would look like

enter image description here

The gain of the opamp is set by the values of R1 and R2, calculated as \$Gain= 1+ \frac {R2}{R1} \$

As an example lets suppose that you use a shunt resistor of 0.1 Ohm. That will give a voltage output of 0-50mV (for 0-500mA). In order to get a better resolution in your ADC (assuming Vref=5v) you can apply a gain, lets say 80x (to leave some headroom) so that the output becomes 0-4v. Another option is of course to apply a lower gain and use a lower Vref for the ADC, this is up to you.


Note that the above method describes low side current sensing (ground side), there is also the high side current sensing (positive supply side of the load) which is more complicated and usually an IC solution is better suited. Refer to the following answers:

Hall-Effect-Based Linear Current Sensor ACS712
IMA138 shunt monitor, ZDS1009 current mirror

You can also read this related article Understand low-side vs. high-side current sensing

\$\endgroup\$
  • \$\begingroup\$ Actually I only need to know if the current is above or at/below a threshold (should have said that), so the comparator would be ok. Though I can't find a shunt resistor in stores except large ones meant for 100 amps, etc... so I like your schematic solution instead, but what is Rsense? (to confirm uC is the measured current from the opamp?) \$\endgroup\$ – Matt Feb 14 '14 at 19:19
  • \$\begingroup\$ @Matt Rsense is the shunt resistor. The resistor rating doesn't have to be high for 500mA. The calculation of the consumption on the resistor is P=IIR so for 0.5A and 0.1 Ohm it's just 0.025W. The current through the shunt resistor creates a voltage drop that is amplified using the opamp and then the output feeds the MCU ADC input. \$\endgroup\$ – alexan_e Feb 14 '14 at 19:41
  • \$\begingroup\$ in this case(only 1amp max), can the shunt resistor be a normal resistor? I can't find something called a shunt resistor in local stores except large ones meant for 100amps (too big, too expensive) \$\endgroup\$ – Matt Feb 14 '14 at 21:10
  • \$\begingroup\$ @Matt There is nothing special about the shunt resistor, it's just a normal resistor that is called like that based on its usage in the circuit. You can use any normal resistor with sufficient power rating, you may also want it to have a low tolerance in case you are interested in a better accuracy (doesn't seem to be the case). \$\endgroup\$ – alexan_e Feb 14 '14 at 22:27
  • \$\begingroup\$ I'm trying a 0.1ohm 10 watt resistor with an LM311 and R2=100ohm and R1=10ohm. Pins 5 and 6 are connected. Pin 4 is connected to GND. But while I get a few MV to Pin 2 when using ~50ma, the output (pin 7) is only 0.0mv! (I have a free comparator on an LM339 I'm already using that I would like to use in place of the LM311). \$\endgroup\$ – Matt Feb 20 '14 at 3:33
2
\$\begingroup\$

I'm using an LT6107 and current sense resistor pretty much like this: -

enter image description here

Connect your 12V to where it says "3V to 36V". Connect your motor between "load" and ground.

The chip self-powers and produces an output of 200mV per amp taken by the motor.

If you made the current sense resistor 0.1 ohms then the output would 1V per amp.

\$\endgroup\$
0
\$\begingroup\$

Probably a bit late for Matt, since he hopefully has learned a lot since his last post. But;

10Watt resistor is HUGE! other post pointed out

"P=IIR so for 0.5A and 0.1 Ohm it's just 0.025W" 25 milli Watts. In this case you could have got away with 1.0 Ohm 0.25 Watt [Just].

Also the 100 Ohm and 10 Ohm resistors while theoreically giving a gain of 11 are way too small in value. This is an OP-AMP with very low output capability, you are effectively shorting the output to 0volts. 10k and 1k0 would have been better and 100k with 10k better still. If you wanted a gain of 10 instead of 11 you could use 100k in parallel with 1M0 giving 90k for R2. Still using 10k for R1 gives G= 1+(R2/R1) =10

AND as already pointed out the output is OPEN COLLECTOR. It isn't connected to any voltage source so needs a PULLUP which might well be in the MegOhm range or at least 10's of kilo Ohms Also the LM311 is OPEN EMITTER, so it too must be connected to something e.g 0volts if you want the output to actually DO Something.

I would urge every person trying to make something "Electronic" to read the datasheets of the devices they plan too use. Do it by Design not by Default.

One more thing, the comment about hysteresis is not correct. He is showing the inverting input connected to R1&R2 so it will set gain. If the NON-Inverting input is connected in this manner it will provide hysteresis.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.