Go Down

Topic: Problems with Pololu vnh5019 - please help!  (Read 306 times) previous topic - next topic

Karim_S

May 03, 2018, 01:15 am Last Edit: May 03, 2018, 01:41 am by Karim_S
So, I've been working with this motor shield for a fairly large robot, though the code I've written only seems to work on arduino Megas, not Unos. The problem here is that I want to use an Uno, but for some reason I cant (btw pulsein is for my controller). Here's the code I've written :


Code: [Select]
#include "DualVNH5019MotorShield.h"
 
DualVNH5019MotorShield md;

int power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400;                     //Gives us a value that is within the range of the motors. (-400 -> +400)
float direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100;       //Gives us a percentage ( 0 -> 1 value )


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

void setup()
{
  Serial.begin(9600);
  md.init();
  pinMode(3, INPUT);
  pinMode(5, INPUT);
}


void loop()
{
 
  Serial.print("     1:");
  Serial.print(direct);
  Serial.print("     2:");
  Serial.println(power);
 
  if(direct > -50 && direct < 50)
  {
    power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400;             
    direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100;
    md.setM1Speed(power);
    md.setM2Speed(power);
    stopIfFault();
  }
  if(direct < -50 || direct > 50)
  {
    power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400;             
    direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100;
    md.setM1Speed(power * direct);
    md.setM2Speed(power * (1 - direct));
    stopIfFault();
  }
 

  delay(10);
 
}


For some reason , when I use the uno, no LEDs light up indicating that power is going through, but when using an arduino mega it seems to work fine. I'm at a loss for answers. Can someone help me out?

bos1714

Hi there!

That does seem very strange. My only guess is that the board uses PWM signals from pins that are not PWM capable, but I don't think so because why would the shield be designed for an Uno.

Try plugging the Uno in without the shield and see if a sketch can be uploaded to the board successfully. If that doesn't work, then you know something could be fried on the board. If it does work. Then perhaps try to manually route connections from the arduino to the necessary pins on the board using wires instead of plugging the shield into the Uno and see if it works that way. Make sure that all power connections go to the correct location.
Time line? Time isn't made out of lines. It is made out of circles. That is why clocks are round.

MorganS

Don't use pulseIn() in the initial declaration of the two variables. Do that in setup().
"The problem is in the code you didn't post."

Go Up