Hello,
I am using a single VNH5019 motor driver carrier for controlling a linear actuator.
Motor driver gives OUTA and OUTB values to linear actuator when PWM value is positive, but not when it is negative.
I took the code from motor driver shield. It worked fine and suddenly it does not work anymore.
Please anyone let me know how to save my motor driver or troubleshoot this…
Thanks in advance.
void initMotor3(){
_PWM5 = 5;
_INA3 = 3;
_INB3 = 11;
pinMode(_PWM5, OUTPUT);
pinMode(_INA3, OUTPUT);
pinMode(_INB3, OUTPUT);
}
void setM3Speed(int speed)
{
unsigned char reverse = 0;
if (speed < 0)
{
speed = -speed; // make speed a positive quantity
reverse = 1; // preserve the direction
}
if (speed > 255) // Max
speed = 255;
analogWrite(_PWM5,speed); // default to using analogWrite
if (speed == 0)
{
digitalWrite(_INA3,LOW); // Make the motor coast no
digitalWrite(_INB3,LOW); // matter which direction it is spinning.
}
else if (reverse)
{
digitalWrite(_INA3,LOW);
digitalWrite(_INB3,HIGH);
}
else
{
digitalWrite(_INA3,HIGH);
digitalWrite(_INB3,LOW);
}
}
void loop() ={
for(int i=0; i<=10; i++)
{
setM3Speed(-100);
delay(2);
}
}