0

I use INA219 module to read DC motor current for control propose. I connect INA219 in series with motor as shown in schematic.

schematic

simulate this circuit – Schematic created using CircuitLab

The control signal is 31.25kHz PWM. when motor turn CW (A = 0,B = 1) it work normally but in reverse (A = 1, B = 0) the current reading look very spiky and INA219 not respoding after I stop motor shaft by hand. After some investigation. I found negative voltage on osciloscope. Setup A = 1, B = 0 probe on pin A reference to Gnd. enter image description here Then zoom into falling edge. enter image description here My assumption is the negative voltage that below maximum rating of INA219 did something cause its to reset. My questions are

  1. What happen here why negative voltage is too high?
  2. How to solve this problem?
  3. (Optional) Any tips to measure DC Motor current?.

Additional Data This is my setup. enter image description here

M lab
  • 1,191
  • 6
  • 21
  • 1
    What is the shunt value is used for current measurement. With this block diagram it's hard to understand the setup. The scope plot shows which signal voltage across ??? – user19579 Aug 08 '20 at 07:39
  • 1
    In module use 0.1 Ohm motor draw about 100 mA when I try to stop it. – M lab Aug 08 '20 at 07:41
  • 1
    How are you powering the INA219? Please show the complete schematic, and if possible a photo of the setup including all wiring. – Bruce Abbott Aug 08 '20 at 07:47
  • 1
    @BruceAbbott I use lab bench power supply. all circuit build on arduino UNO shield. I will upload photo soon. – M lab Aug 08 '20 at 08:07
  • But I thought most H-bridge motor drivers have a current sense pin, which you connect a 0.5R to ground and measure the voltage across the resistance to calculate the voltage. Many modules, eg L298N, extract the current sense pin(s) for such purpose. – tlfong01 Aug 08 '20 at 08:09
  • 1
    @tlfong01 Most of motor driver on market don't have these feature included mine. sobad. – M lab Aug 08 '20 at 08:34
  • @M lab, I am playing with BTN8971B, with current sense pins extracted to the breakout board. But it is a bit expensive. https://electronics.stackexchange.com/questions/510755/help-with-choice-of-dc-motor-speed-control-pwm-vs-regulator. Good luck and cheers. – tlfong01 Aug 08 '20 at 08:42
  • Your measuring the (flowing) current passing the motor is a bit tricky. Have you considered measuring the current at high/low side of the 12V source powering the motor driver? – tlfong01 Aug 08 '20 at 09:49
  • 1
    @tlfong01 Yes it just capture inductive current which I ignored. I just move to high-side to I it's work pretty fine like supper normal like it's should be. – M lab Aug 08 '20 at 10:24
  • Yes, (1) INA219 is designed to work in one direction only. So if you series it with the motor, then it is unexpectedly sensing two directions (CW and CCW). (2) When current in either direction is switched off, there is a huge back EMF voltage and current spike, absorbed by the motor driver's flash back diode, only IF INA219 is outside (high or low side) of the power circuit. (3) But if series INA219 with the motor, then the back EMF current spike will pass through INA219, which will be driven crazy! :) – tlfong01 Aug 08 '20 at 13:32
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/111564/discussion-between-tlfong01-and-m-lab). – tlfong01 Aug 08 '20 at 13:33

1 Answers1

1

I had the same problem, it helps to change the sample amount configuration. At 1 sample (which is the Adafruit default) the current value keeps jumping around. When the configuration is changed to 128 samples I get a very stable reading (that varies as expected, when the motor load is increased, the current increases). The following needs to be changed:

INA219_CONFIG_SADCRES_12BIT_1S_532US to INA219_CONFIG_SADCRES_12BIT_128S_69MS

You can also change the following (for the bus voltage), but this seems stable also with the original setting:

INA219_CONFIG_BADCRES_12BIT to INA219_CONFIG_BADCRES_12BIT_128S_69MS

(changes to be made in Adafruit_INA219.cpp)

  • Welcome to EE.SE. You can format the code in your answer using the `{}` code formatting button on the editor toolbar or by separating the code with a blank line and adding four spaces at the start of each line. For `inline code` use back-ticks on each side. – Transistor Dec 28 '20 at 20:49