VNH5019 sample program not working with Arduino Nano ESP32

Hello, I have used this motor controller with Arduino Mega 2560 many years ago. I am now trying to use it with an Arduino Nano ESP32. I tried the Demo program in DualVNH5019MotorShield but it does not work. Motor does not turn at all and I can turn it by hand. Perhaps due to compatibility issue with the Nano ESP32? Could you pleae have a look?
All the components are working and the LED on the VNH5019 is on. I could use another program to turn it but the official demo program about 10 years old does not work.

For your convenience, here is the program:


#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.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = 400; i >= -400; i--)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = -400; i <= 0; i++)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = 0; i <= 400; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = 400; i >= -400; i--)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = -400; i <= 0; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
}

Thank you

Hello.

We have two different products that use the VNH5019; can you clarify which you are using:

Can you also post more details about your system, like the motor and power supply you are using, as well as some pictures of your setup that show all of your connections?

- Patrick

Dual channel. The demo program was made about 10 years ago and the EPS32 was out about 2 years ago. I think there is a compatibility issue that your company needs to check. Using other program, the motor could move so it is not the problem with the connections nor power supply.

We have not heard any reports from others having trouble using the VNH5019 shield with the Arduino Nano ESP32, and on a quick inspection I do not see anything about the our Dual VNH5019 Motor Driver Shield library and the Nano ESP32 that would make them obviously incompatible.

However, the default pin assignments in the demo program from our library do not match the pin assignments you used in the code from your second post (not sure why you deleted that), so double checking your connections still seems like the best starting point. Along with pictures, can you post what the demo program reports through the Arduino Serial Monitor when you run it?

- Patrick