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.
- Arduino turns on the VNH5019 shield via LDR at >400 ( ie sunny day)
- 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)
- 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 screenif(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 screenif(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);}
