I need to drive a DC motor @ 24V, 6A with a MOSFET. How can I sense the current that the motor is drawing with a microcontroller? I have to know when the motor is stalled.


4 Answers 4


You place a small sense resistor (typically < 100m\$\Omega\$ for the voltage and current involved) in series with the motor and measure the voltage drop. There are two methods: high-side and low-side, depending on the position of the sense resistor.

Low side is easiest, as the voltage drop you want to measure is directly related to ground, but it lifts the low side of the motor's voltage a few tens of millivolts above ground too, and not everybody likes that. If it's no more than these few tens of mV it shouldn't be a problem though, and you can use an opamp to amplify the voltage in a simple non-inverting amplifier configuration. A 10m\$\Omega\$ resistance will give you a 60mV drop, which is acceptable, and at the same time high enough to measure properly. You don't necessarily need a physical component for this; a 1cm PCB trace 0.5mm wide has a 10m\$\Omega\$ resistance.
Make sure to select an RRIO (Rail-to-Rail I/O) opamp.

For high-side measurement you have to use a difference amplifier to measure the voltage drop. There are special ICs for that, some of which have the shunt resistor integrated, for maximum accuracy.

enter image description here

But you can also construct your own difference amplifier with an opamp. If you just want to detect a stall you probably don't need the A/D converter but can use a simple comparator. Be sure to filter the measured voltage with a capacitor.

A (not very thorough) search turned up the SiLabs Si8540 high-side sensor, available from Mouser from USD 0.65 quantity one.

The Zetex/Diodes ZXCT1009 is comparable, but only needs 3 pins of its SOT23 package.

Further reading:
Linear Technology Current Sense Circuit Collection (warning: heavy product plugging!)
Collection of documents on current-sense amplifiers by Maxim

  • 1
    \$\begingroup\$ I am very happy to see that you often take the time to show an example part that will get the job done but your lesson that comes first teaches more then enough to allow you to bypass the shopping advice. \$\endgroup\$
    – Kortuk
    Commented Jul 22, 2011 at 19:01
  • \$\begingroup\$ @Kortuk - Got it. Removed shopping advice. (but left reference to example part) \$\endgroup\$
    – stevenvh
    Commented Jul 23, 2011 at 7:20
  • \$\begingroup\$ It was a "good job" message. I thought the link was a nice touch. You give some basic, here is a part that would work, but by the point you read this you will have learned how to select your own. People always assume a mod is unhappy! \$\endgroup\$
    – Kortuk
    Commented Jul 23, 2011 at 12:15
  • \$\begingroup\$ @Kortuk - well you can't blame them! ;-) \$\endgroup\$
    – stevenvh
    Commented Jul 23, 2011 at 12:17

People who think the only way to measure DC current is to use a shunt resistor may be surprised to learn that a variety of current sense techniques exist.

Hall effect sensors are nice for measuring large high-side DC currents. Some have analog out, eating up one of the analog inputs on your microcontroller. Others have an integrated internal ADC, with digital pins that directly connect to your microcontroller. A few also have an integrated power FET driver, and are smart enough to unconditionally turn off the FET when it measures over-current.

In many cases, I don't really need to know exactly what the current is, I just want to keep things from getting permanently damaged when the motor stalls out. It makes the rest of the system much simpler to use a "smart switch" that automatically turns itself off when the motor stalls.

The Allegro Hall effect sensor chips look nice. The IR intelligent power switches look nice.

Related: Best shunt resistor for power meter application? and High-bandwidth current measurement

  • \$\begingroup\$ Honestly I was curious, but that "variety of techniques" appears to be for 80% shunt resistor based: high side, low side, voltage drop over MOSFET, ... \$\endgroup\$
    – stevenvh
    Commented Jul 24, 2011 at 18:47
  • \$\begingroup\$ @stevenh - he did say "large" in addition to high side at the start of that paragraph. It's easy to imagine how a shunt could get unpleasant in such circumstances. But in more common situations it tends to work pretty well. \$\endgroup\$ Commented Jul 28, 2011 at 8:04
  • 1
    \$\begingroup\$ Another reason to go with the hall effect sensors are that they are isolated and can have very microcontroller friendly outputs. \$\endgroup\$
    – W5VO
    Commented May 31, 2012 at 12:16

As current, voltage, and resistance are all related (Ohms law), you can measure current by measuring the voltage drop across a known resistance and calculating it:


Put a small (\$<0.1\Omega\$) resistor in series with the motor. The microcontroller can measure the voltage drop across it (you may want to amplify it through an op-amp) using ADC.

This is something I have wanted to do myself for a while, and I understand the theory - just haven't worked out how to measure the voltage difference yet

  • 3
    \$\begingroup\$ 1\$\Omega\$ for 6A @ 24V is way too high! It will cause a 6V drop, that's 25% of the power supply! \$\endgroup\$
    – stevenvh
    Commented Jul 22, 2011 at 9:04
  • \$\begingroup\$ Also, it will feed me 6V into the A/D of the microcontroller.. \$\endgroup\$
    – m.Alin
    Commented Jul 22, 2011 at 9:19
  • \$\begingroup\$ That's why I say less than 1 Ω \$\endgroup\$
    – Majenko
    Commented Jul 22, 2011 at 9:23
  • 2
    \$\begingroup\$ @Matt Jenkins: Yes, but 0.9\$\Omega\$ is also less than 1\$\Omega\$. I think you should reconsider your resistor's limit, given the voltage and current for the motor. \$\endgroup\$ Commented Jul 22, 2011 at 9:34
  • 2
    \$\begingroup\$ @Matt - That's why it's a "sense" resistor, haha! :-) OK, that was a bad one. Well, it can't always be caviar... ;-) \$\endgroup\$
    – stevenvh
    Commented Jul 22, 2011 at 10:13

As Andrew Kohlsmith corrected me here's the edit:

For DC, the only way to sense current is by a Shunt Resistor. This method is derived by the Ohm Law:


Where 'I' stands for current and will be the only variable solved by the µC. In the same way, 'V' stands for Voltage, which will be measured by an ADC (Analog-Digital Converter) inside the µC. Finally, 'R' stands for the resistor you must know for calculating the ecuation.

There are two ways of designing the shunt resistor:

  1. Using a resistor conected in series with the motor. Which value has to be known and you'll have to consider the power dissipated. For example: if you use a resistor of \$1\Omega\$ and you want to sense a current around 6A, the power dissipated by that resistor would be 36W. So I sugest you to use values around \$10m\Omega\$.

  2. Using the board trace in a PCB to fabricate a Shunt Resistor. As [1] says, depending on the following parameters in the formula, you'll get a resistance value:

\$R=\rho \times \dfrac{L}{t \times w}\times(1+Tc \times (T-25))\$

  • Length (L)
  • Thickness (t)
  • Width (w)
  • Resistivity (ρ). For Cu, \$\rho=1.7*10^{-6}\Omega\$-cm
  • Temperature (T)
  • Tc = 3.9 \$10^-3\Omega/\Omega/C\$ (I don't know what does it stands for, ideas?).

Some, ommit the temperature product part [2]. There are plenty of webs you can use for generating the aproximate resistor of the PCB trace, for example in [3] and [4]. Anyway, I would measure the value with a multimeter with a \$m\Omega\$ capability. If you want more information, check [5].

On the other hand, the only way to measure the voltage of that Resistor is using an Instrumental Amplifier, just as Stevenvh suggests.

[1] AN894 - Motor Control Sensor Feedback Circuits by Microchip.

[2] AP144 - Calculating PCB Track Resistance by Polar Instruments.

[3] Trace Resistance Calculator by EEWeb.

[4] PCB Thermal Copper Area by The CircuitCalculator.com Blog.

[5] Contructing your Power Supply - Layout Considerations by Robert Kollman [TI].

  • 1
    \$\begingroup\$ Current Transformers won't work with DC motors anyway. I've used them extensively with (large) AC motors for current limited soft-starting, but the only benefit they have (price) is offset by all of the problems that come with them (linearity, range, harmonic sensing, inability to sense DC, etc., etc.) \$\endgroup\$
    – akohlsmith
    Commented Jul 22, 2011 at 12:39
  • \$\begingroup\$ Yes, you're absolutely right. I forgot the motor was a DC one. Having trouble controlling a Brushless DC motor, so I have it stuck in mind. Thanks for the comment! \$\endgroup\$
    – Diego
    Commented Jul 22, 2011 at 15:38
  • \$\begingroup\$ @Diego - You only mention the relevant factors for the resistance, a formula would be nice. \$\endgroup\$
    – stevenvh
    Commented Jul 22, 2011 at 18:45
  • \$\begingroup\$ @stevenh - Eddited! For the PCB trace: some people use shapes, so in the end they just do tests with PCB's and measure the traces with a multimeter.... \$\endgroup\$
    – Diego
    Commented Jul 23, 2011 at 7:19
  • 1
    \$\begingroup\$ @Diego - "Ω/Ω/C" is just an odd way to say that \$T_C\$ is 0.39% per °C. It's more often expressed as 3900 ppm/°C. \$\endgroup\$
    – stevenvh
    Commented Jul 23, 2011 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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