0
\$\begingroup\$

I am building a Li-Po powered robot, with NodeMCU at its core, and two DC motors run through a TB6612FNG DC motor controller. Also some sensors that are not relevant here. Full schematic:

enter image description here

Basically Li-Po is connected to a boost converter going up to 6V, which is then fed into NodeMCU and the TB6612FNG, while the NodeMCU 3V3 line is used for powering logic level. I am switching AIN1, AIN2, BIN1 and BIN2 pins on the TB6612FNG through PNP transistors, so I can control motor directions with 2 pins on NodeMCU instead of 4. Please ignore the sensors and the servo motor in this example, they are disconnected on my test board.

I wrote a dead simple code that turns both motors clockwise for 1 second, stops for 1 second, then runs counter-clockwise for 1 second, and stops for one second again. This is a single loop, which is repeated infinitely. Full duty cycle, PWM frequency set to 512.

Now, something really weird is going on. I noticed that after some time of motor going back and forth, my Li-Po battery disconnects. Safety feature due to over-current. So I hooked it up to my PSU instead, and noticed that with each loop, the current draw on the clockwise rotation remains the same, but the current draw on the counter-clockwise rotation gradually increases. After some 6 or 8 loops it reaches its peak, and then starts decreasing with every loop. Like some sort of a wave.

I hooked up just one motor for demonstration purposes. At rest, current consumption is ~155 mA (that's for NodeMCU). With motor running clockwise/counterclockwise at first loop, the consumption is 214/223 mA. Second loop - 214/300 mA. Third loop - 214/331 mA. Fourth loop - 214/366 mA. And so on. It keeps growing and growing until it reaches almost 800 mA, and then it starts going down again. I caught this on tape:

https://youtu.be/lTup1g7zn-g

Now, things I already tried:

  1. Soldering ceramic 0.1 µF capacitors between motor legs, and also to the chassis, as well as twisting the wires;
  2. Soldering a fat 2200 uF electrolytic capacitor right to the TB6612FNG VM/GND pins;
  3. Replacing motor - I have 6 motors of different kinds (different brand, size, power, etc.);
  4. Replacing TB6612FNG;
  5. Increasing and decreasing the time that motor spends at rest;
  6. Swapping the DC motor polarity;
  7. Switching from A channel to B channel, even tried one wire on A channel, one wire on B channel;

And none of these things made the slightest difference. Nothing changed, at all. The current still grows with each loop in one direction.

Important note: if I run motor continuously in one direction - doesn't matter which direction - the current consumption remains the same, steady at around 214 mA. This strange growth only happens when I start changing directions, as in the video.

I could understand that if I changed the motor direction immediately there could be a power surge, but the motor spends whole 1 second at rest! And yet something remains. It's almost as if the current is "pooling" or something. I can't explain it rationally.

Any ideas? What is going on here?

EDIT: One detail that might relevant. During these current spikes, the voltage does not drop anywhere across the system. Not from PSU, not after the boost, nor the 3V3 line on NodeMCU. All voltages seem to be very stable.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ what happens if you run CW pause CCW pause CCW pause CCW? \$\endgroup\$
    – jsotola
    Mar 29, 2020 at 3:04
  • \$\begingroup\$ @jsotola - if I do that, then current consumption is all over the place. Totally random for CCW, but stable for CW. And yes I did try to swap polarities and changing to another motor... \$\endgroup\$ Mar 29, 2020 at 3:12
  • 1
    \$\begingroup\$ where did you get the schematic? ... the two transistors appear to be incorrectly connected \$\endgroup\$
    – jsotola
    Mar 29, 2020 at 3:15
  • \$\begingroup\$ I made this schematic myself... If you're asking about the transistor datasheets, I got them here: sparkfun.com/datasheets/Components/2N3906.pdf. I am unsure what you meant by incorrectly, because they are working exactly as intended... All voltages are correct in every state. EDIT: oh damn, I wrote NPN in my question. I meant PNP!! \$\endgroup\$ Mar 29, 2020 at 3:18
  • \$\begingroup\$ if it was working as intended, then you would not be here posting your question .... the transistor emitter pin should be more positive than the collector pin .... example here learningaboutelectronics.com/Articles/… \$\endgroup\$
    – jsotola
    Mar 29, 2020 at 3:30

0

Your Answer

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

Browse other questions tagged or ask your own question.