VNH5019: Problem with powering 2 motors simultaneously

Hello guys,

I´ve got a problem with the VNH5019 dual motor driver shield. I´m using it on an Arduino Mega2560 powering two brushed 12V DC gear-motors. The power source I use is a 11.1V LiPo pack.

My setup is as simple as possible: Arduino + VNH5019 shield + 2 motors + LiPo pack

Now here´s the thing: When I use the demo program for the shield, everything works just fine. Both motors run as they should. No problems. But when I try to power both motors at the same time (the code I used can be found below), some weird stuff happens.

You can see the run of the two motors over the time in the picture I attached to this post.

Basically spoken, when both motors should run forward, motor2 does nothing while motor1 is running as it should. When both motors should go backwards, motor2 is running as it should while motor1 is going backwards at full speed without the increasing and decreasing the program tells it to do. Then motor2 does nothing again and so on.

This problem keeps existing when I change the motors and even when I disconnect one of them.

Because the motors work fine when powered separately or one after another and I don´t think the code to be the problem, there has to be something wrong with the shield.

Here is the code I used:

#include "DualVNH5019MotorShield.h"

DualVNH5019MotorShield md;

void stopIfFault()
{
  if (md.getM1Fault())
  {
    Serial.println("M1 fault");
    while(1);
  }
  if (md.getM2Fault())
  {
    Serial.println("M2 fault");
    while(1);
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println("Dual VNH5019 Motor Shield");
  md.init();
}

void loop()
{
  for (int i = 0; i <= 400; i++)
  {
    md.setSpeeds(i,i);
    stopIfFault();
    delay(2);
  }
  
  for (int i = 400; i >= -400; i--)
  {
    md.setSpeeds(i,i);
    stopIfFault();
    delay(2);
  }
  
  for (int i = -400; i <= 0; i++)
  {
    md.setSpeeds(i,i);
    stopIfFault();
    delay(2);
  }
}

I hope anyone can help me. I really don´t know what to do next.
This seems all pretty weird to me. :confused:

Thank you for every answer.

Greetings

Phil


Hello, Phil.

I am sorry you are have a problem getting your motor shield working correctly. You have done a nice job of simplifying your code and I do not see any faults there. However, the behavior is a little perplexing because all the setSpeeds(i,i) function does is to call the same setM1Speed(i) and setM2Speed(i) functions used by the demo code.

Can you provide pictures that shows the connections for the battery and motor to the shield? It would be helpful if you could also show any solder joints there.

Nathan

Hello Nathan,

thank you for your answer, but I think I fixed it (kind of).
I don´t know why I did´t come up with this earlier, but I just put the shield on an Arduino Uno and now it works perfectly.
It seems to be the Arduino Mega that is the problem. The shield does work.

So thanks again for your answer and I will buy a new Mega.

Greetings

Phil

Hello, Phil.

I’m glad you were able to do some more troubleshooting. It sounds like one of the pins on the Arduino Mega could be damaged. Thanks for letting us know.

-Nathan