Go Down

Topic: Measuring noisy dc motor currents (Read 692 times) previous topic - next topic


Hey all, I am working on a project and one part involves measuring the current draw of a small dc motor.  These motors run on 12-20v and draw up to 200ma.  500ma stall current.

TLDR: need to measure 0-300ma accurately from a small cheap dc motor.  My code and circuit are double confirmed to be working fine with calibrated currents, the dc motors are giving me issues. Even with filter caps installed.
Looking for general small current measuring scheme tips.

I have tried an ACS712 Hall effect current measure IC, but at low currents it is just too noisy and the magnets of these dc motors affect the readings.
  I'm trying to move away from this and have been trying an INA169 + shunt resistor to measure voltage drop and calculate current.



I made a spreadsheet and have confirmed that my hookup and code are working fine by sending calibrated currents through the circuit and the serial monitor is confirming that everything is working fine. I've double confirmed this with my clamp on ammeter. 

Problem is, that when I set up the dc motor and get it going, I am getting 200 readings of zero (which I discard) for every 30 good readings, and the good readings average out to a low value.  None of the readings are in the range of actual current, they're all too low.  I'm drawing around 70ma no load and the serial monitor is giving me an average of around 25.  I am using a delay of 5ms between analogReads.

I've tried a few schemes to filter out brush noise, to no avail. Perhaps I need to low pass filter the output of the INA169?

Thanks for any general low current measuring advise.


Feb 26, 2020, 12:11 am Last Edit: Feb 26, 2020, 12:12 am by jremington
Post a complete schematic diagram, with pins and parts clearly labeled.

If you are using PWM and a motor controller, post the code, using code tags.


Your motor draws up to 500 mA, but your current measurement is limited to 300 mA. Why?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Feb 26, 2020, 01:29 am Last Edit: Feb 26, 2020, 01:43 am by Srmaietta
JRemington, motor is fed from straight DC, separate circuit.  I'll post those things tomorrow. (Project is at work)

WvMarle - 500ma is stall current, the motors will be under a constant mild load, and will never stall.  I figure designing for the actual range of predicted currents makes more sense rather than trying to extend the range to the total limit.
  With my 2ohm shunt resistor and a 0-5v adc input the INA169's range is 5 - 250ma which if it was working correctly would be perfect.



Feb 26, 2020, 01:57 am Last Edit: Feb 26, 2020, 01:59 am by jremington
will never stall
A brushed DC motor briefly draws the stall current every time it starts moving. If it is rapidly reversed, it draws TWICE the stall current.

Don't forget to post the details of the motor power supply.


I would double that range - giving it a 1Ω resistor. That also allows you to actually measure (and confirm) the stall current. Of course the resolution is cut in half, but that shouldn't be a major issue, and if it is, time for a higher resolution sensor.

You can also shield your hall effect sensor against any stray magnetic fields, though I doubt that to be an issue. Brushed DC motors are notoriously noisy (due to the brushes switching on and off the coils all the time), to filter I usually add three 100 nF caps to the terminals: one in between, and the others from either terminal to the motor's housing. That should take care of most of the noise.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Feb 26, 2020, 02:08 pm Last Edit: Feb 26, 2020, 02:12 pm by Srmaietta
My setup and the motor I'm trying to measure (small racing car)


Feb 26, 2020, 02:15 pm Last Edit: Feb 26, 2020, 02:16 pm by Srmaietta
My code

Code: [Select]
void setup()

int a,Av;
float currAv;
float curr=0;
float current;

void loop()


curr = analogRead(0);

curr = (curr*5) / 1023; //turn analog reading into actual voltage
 if (curr<.06)  //reject the lowball readings (Dont want to do this!..but have to for now)

 Serial.println(curr);  //print of voltage

 // Is = (Vout x 1k) / (RS x RL)  //INA169 current formula from datasheet
 //current = (curr * 1000) / (2 * 10000);
 current = curr / 20;

 Serial.print(current,3);  //print of calculated current
 Serial.println(" A");

 currAv = currAv+current;
     if (Av==30)   //averaging every 30..
       Serial.print("\tAverage: "); //printing average of 30 readings
       Serial.println(" A");
       Serial.print("Lowballs: ");  //printing # of rejected lowball readings




Feb 26, 2020, 03:25 pm Last Edit: Feb 26, 2020, 03:26 pm by Srmaietta
I'm really trying to figure out why the majority of my readings are zero. I do understand that there will be spikes and noise from the motor but still, wouldn't most of the readings be in a positive direction? And why are none of the readings at the level they should be?

I need to bring in my oscilloscope...


Feb 26, 2020, 05:22 pm Last Edit: Feb 26, 2020, 05:22 pm by Paul_KD7HB
How long has it been since you last cleaned the copper commutator on the motor. From the picture it looks pretty black.


PS: Have you checked the brushes and springs?


Hey Paul, it has been never that I have cleaned the cars brushes etc..  The issues of my setup here are present whether I am using this old car, another even worse older car, or a brand new dc hobby motor.

So today I joined the ground on the Arduino and the -side of the power supply and that cleaned up the vast majority of zero readings.  --YAY--   I tried this yesterday and it didn't seem to make any difference.  Fresh eyes and a fresh mind are always a good thing...

Was running into the rails of the IC so I switched the 169's VCC from the Arduinos 5V to the V+ on the shunt resistor (18-20v), and this now allows the 169's output to reach all the way up to 5v. and higher actual current readings!!!!! --YAY YAY--

Then decided to try a lowpass on the output (.1uf between Vout and ground) and that cleaned up 90% of the rest of the bad readings.  --SUPER YAY--

I still get a stray 0v or 5v ping every now and then, maybe one for every 30 good readings, but it is now a useable signal.

Now onto finding the best RS and RL to get precision within my desired range.


Go Up