Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Dual VNH5019 shield in single-channel mode strange problem


#1

VNH5019 shield with two seperate motors working just fine.
when i try single-channel mode, strange things happening.
i can only move motors with “-” negative numbers. “+” positive doesnt make anything
also, i have to use M1 and M2 speeds for FW and Rev…

here is the code:

#include "DualVNH5019MotorShield.h"

void setup()
{
  md.init();
 }
 
void loop()
{
  
  md.setM1Speed(200);  // this doesnt work
  delay(2000);  // wait for 2 seconds
  md.setM1Speed(0);  // single-channel motor stop (coast)
  delay(500);  // wait for 0.5 s

   
  md.setM1Speed(-200);  // this works clockwise
  delay(2000);  // wait for 2 seconds
  md.setM1Speed(0);  // single-channel motor stop (coast)
  delay(500);  // wait for 0.5 s

md.setM2Speed(-200);  // this works anticlockwise
  delay(2000);  // wait for 2 seconds
  md.setM1Speed(0);  // single-channel motor stop (coast)
  delay(500);  // wait for 0.5 s

}

i also modified ccp files for the connections and jumpred pins

#include "DualVNH5019MotorShield.h"

// Constructors ////////////////////////////////////////////////////////////////

DualVNH5019MotorShield::DualVNH5019MotorShield()
{
  //Pin map
  _INA1 = 2;
  _INB1 = 2;
  _PWM1 = 10;
  _EN1DIAG1 = 6;
  _CS1 = A0;
  _INA2 = 4;
  _INB2 = 4;
  _PWM2 = 10;
  _EN2DIAG2 = 12;
  _CS2 = A1;
}

thanks

EDIT : using arduino Mega : and tried regular code and connections as in manuel, no go!


#2

connected PMW1-2 to pin 11 on Mega
connected M1INA-B to pin 2 on Mega
connected M2INA-B to pin 4 on Mega not to 7 or 8 (which they are short)

its working now, with below .ino and .ccp
but i dont get it how! i am not connecting INA2 and INB2 to pin 7,
but to 4. and 4 is INB1 and its sorted to INA1!
if i connect to pin7, i get the same problem as in my first post…

also,
if i dont short M1A-to-M1B for out A and M2A-to-M2B for out B i still get power.
either output connections work without shorting them.
if i use M1B and M2A only (without any short) i get led indicators working too :slight_smile:
but i guess thats half of power of each side, kind a using one chip.
unlike when sorted outputs are full output of both cips.

motor_test.ino

#include "DualVNH5019MotorShieldMod3.h"

DualVNH5019MotorShieldMod3 md;//Use default pins

void setup()
{

  md.init();
  // remaining setup code goes here

}
 
void loop()
{
  
  md.setM1Speed(100);  // single-channel motor full-speed "forward"
  delay(2000);  // wait for 2 seconds
  md.setM1Speed(0);  // single-channel motor stop (coast)
  delay(500);  // wait for 0.5 s

   md.setM1Speed(-100);  // single-channel motor full-speed "forward"
  delay(2000);  // wait for 2 seconds
  md.setM1Speed(0);  // single-channel motor stop (coast)
  delay(500);  // wait for 0.5 s
  
}

this is .ccp file

include "DualVNH5019MotorShieldMod3.h"

// Constructors ////////////////////////////////////////////////////////////////
// All default pins function (note: motor sheild 2 is "custom")
DualVNH5019MotorShieldMod3::DualVNH5019MotorShieldMod3()
{
  // Default Pin map motor sheild 1
  _INA1 = 2;
  _INB1 = 4;
  _EN1DIAG1 = 6;
  _CS1 = A0; 
  _INA2 = 7;
  _INB2 = 8;
  _EN2DIAG2 = 5;
  _CS2 = A1; 
  _PWM1 = 11;
  _PWM2 = 12;
}

#3

Hello.

I am glad you were able to get things working. As for you understanding how your system is working, it might help you to use the continuity function on a multimeter to check which pins are connected/disconnected on the shield (and it would probably be easiest to probe the pins at the general-purpose headers on the left side of the shield).

While some of us were looking into your setup and connections, we realized that the single-channel code example we gave in the shield’s user’s guide would not completely work. We edited the constructor in that code so that it should work. This should make it so that if you make the hardware modifications we recommend in the Using the Driver in Single-Channel Mode section of the shield’s user’s guide, you should be able to use our DualVNH5019MotorShield library as-is, so long as you specify which pins you are using in the constructor. For example, for an Arduino Mega, I suspect this could work for you:

DualVNH5019MotorShield md(2, 7, 11, 6, A0, 2, 7, 11, 12, A1);

-Jon