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:
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:
Now, things I already tried:
- Soldering ceramic 0.1 µF capacitors between motor legs, and also to the chassis, as well as twisting the wires;
- Soldering a fat 2200 uF electrolytic capacitor right to the TB6612FNG VM/GND pins;
- Replacing motor - I have 6 motors of different kinds (different brand, size, power, etc.);
- Replacing TB6612FNG;
- Increasing and decreasing the time that motor spends at rest;
- Swapping the DC motor polarity;
- 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.