Pololu Motor driver speed controlnot working

HI,

I’m finishing up my Fan motor controller and I have the current parameters set.

I’m using a Pololu Motor driver VNH5019
Fan unit is Brushed 12vdc max 6amps
Only running M1 as the motor output.

  1. Arduino turns on the VNH5019 shield via LDR at >400 ( ie sunny day)
  2. The Motor shield runs for 1 hour on and 1 hour off to allow fan to stand down ( I have this set at 1 min to test for now so I don’t wait round for 1 hour)
  3. Speed to run fan at 50% of rated fan output.

However,

I cant get the motor to run via the PWM to less than 100% forward speed, I’m keen to run it in all cases at 50% that of full speed if makes sense.

All the code works well and functions all work except that of the md.setM1Speed(200) function.

I can see why this is not working, Have I missed some code to call md.setM1Speed(200) function??

My current code looks like this:

#include “DualVNH5019MotorShield.h”

const long oneSecond = 1000; // a second is a thousand milliseconds
const long oneMinute = oneSecond * 60;
const long oneHour = oneMinute * 60;
const long oneDay = oneHour * 24;

DualVNH5019MotorShield md;

int sensorPin = A0; // select the input pin for LDR//
int sensorValue = 0; // variable to store the value coming from the sensor
/*int analogPin = 6;
int val = 0; */

void setup()
{
Serial.begin(115200);
Serial.println(“Dual VNH5019 Motor Shield”);
md.init();
pinMode(6, OUTPUT); //pin connected to the VNH5019 M1EN//
}

void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print("LDR light reading of ");
Serial.println(sensorValue); //prints the values coming from the sensor on the screen

if(sensorValue < 400) //setting LDR threshold value//
digitalWrite(6,LOW); //turn VNH5019 off//

else digitalWrite(6,HIGH); //turn VNH5019 ON//
delay(2);

//motor startup//
Serial.println(“M1 Speed 50% Forward”);// 400 is 100%//
md.setM1Speed(200);
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());

Serial.print("Delay: ");
Serial.println(“delay for 1 min”);
delay(oneMinute);

// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print("LDR light reading of ");
Serial.println(sensorValue); //prints the values coming from the sensor on the screen

if(sensorValue < 400) //setting LDR threshold value
digitalWrite(6,LOW); //turn VNH5019 OFF//

else digitalWrite(6,HIGH); //turn VNH5019 ON//
delay(2);

//motor shutdown//
Serial.println(“M1 Speed 0% stopped”);
md.setM1Speed(0);
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());

Serial.print("Delay: ");
Serial.println(“delay for 1 min”);
delay(oneMinute);

}

Do the examples with the library work as expected ?

NO, Ive tested with the demo code from Pololu but does nor work either.

cheers
jas

Ive tested with the demo code from Pololu but does nor work either.

Time to carefully check the wiring.

How is the motor powered ?

HI Bob,

The arduino is powered from the VNH5019 shield jumper and the Pololu shield has 12vdc input.

Currently I have the shield running positive out of M1 and Negative back into shield neg.

Image attached.

The thing I didnt try with the demo code is Positive on M1 and neg on M2 for motor 1.

I’ll try this and come back to forum.

12vdc brushed fan

HI,

Well simple fix and thanks for you help, I didnt think to look at connections and I have the:

Positive into M1A
Negative into Ground from shield

Now have the:

Positive into M1A
Neg into M1B

Now the code fully works and speed control.

Thanks to everyone for the support.

jason