system
February 26, 2012, 10:03pm
1
Hello:
Experimenting with Arduino UNO + Arduino Motor Shield R3.
Notes & Situation:
Arduino powered by 9v battery
Typical 2 Motor configuration ( One for speed and the other for direction) - both run on 3 x AA battery
VIN Disconnected on Motor Shield therefore am powering motors through 3 x AA Battery leveraging the use of the VIN and GND on Motor shield.
Provided the code below that am trying to use.
Problem:
The car is just not moving when placed on the ground. Once I lift the rear wheels off the ground - the wheels spin. When I place them back on the ground, not enough power to move the car.
What am I doing wrong ? Please advice.
int MotorPinDirection = 12;
int MotorPinSpeed = 3;
int ServoPinDirection = 13;
int ServoPinSpeed = 11;
void setup() {
pinMode (MotorPinDirection, OUTPUT);
pinMode (MotorPinSpeed, OUTPUT);
pinMode (ServoPinDirection, OUTPUT);
pinMode (ServoPinSpeed, OUTPUT);
}
void loop(){
//analogWrite(MotorPinDirection,255);
digitalWrite(MotorPinDirection,255);
digitalWrite(MotorPinSpeed, HIGH);
delay(500);
digitalWrite(MotorPinSpeed, LOW);
delay(500);
/*analogWrite(ServoPinDirection,255);
digitalWrite(ServoPinSpeed, HIGH);
delay(500);
analogWrite(ServoPinDirection,128);
digitalWrite(ServoPinSpeed,LOW);
delay(500);
analogWrite(ServoPinDirection,0);
digitalWrite(ServoPinSpeed, HIGH);
delay(500);
analogWrite(ServoPinDirection,128);
digitalWrite(ServoPinSpeed,LOW);
delay(500);
*/
}
Pauly
February 26, 2012, 10:44pm
2
What motors are you using? Datasheet?
Just a guess, but you probably need more power to the motors.
system
February 27, 2012, 6:07pm
3
Hi:
Dont know the motor spec...
model is based on this:
http://www.modelzone.co.uk/radio-control-rc/rc-cars-and-trucks/off-road/xq-toys-1-24-off-road-w-pvc-blister-cover.html
Since this is a trial, didnt want to invest too much ...
I agree with you on your initial diagnostics.. so tried using a sample code with afmotor.h library.
Guess what .. the RC moves faster than what it does with the above code.
The issue with afmotor.h library code is it moves foward however doesnot respond to backward or stop command.
system
February 27, 2012, 11:03pm
4
Ladies & Gents:
FINALLY SOLVED THE PUZZLE ON WHY THE CAR WONT MOVE WITH THE SHIELD.
Here are the steps:
Connect a 9V to Arduino CPU Board.
On the motor shield, disconnect VIN by scraping the Jumper at the back of the motor shield.
Connect another 9V battery to the Motor Shield independent of the Arduino CPU basically to power the two motors ( Turn and Speed).
Try the following code.. Should work like a dream.
int MotorPinDirection = 12;
int MotorPinSpeed = 3;
int MotorPinBrake =9;
int ServoPinDirection = 13;
int ServoPinSpeed = 11;
int ServoPinBrake = 8;
void setup() {
pinMode (MotorPinDirection, OUTPUT);
pinMode (MotorPinSpeed, OUTPUT);
pinMode (MotorPinBrake, OUTPUT);
pinMode (ServoPinDirection, OUTPUT);
pinMode (ServoPinSpeed, OUTPUT);
pinMode (ServoPinBrake, OUTPUT);
}
void loop(){
/* --- Forward, Brake, Reverse, Brake Sequence --- */
//forward
digitalWrite(MotorPinDirection, HIGH);
analogWrite(MotorPinSpeed, 200);
delay(1000);
// brakes
digitalWrite(MotorPinBrake, HIGH);
delay(500);
digitalWrite(MotorPinBrake, LOW);
//reverse
digitalWrite(MotorPinDirection, LOW);
analogWrite(MotorPinSpeed, 200);
delay(1000);
// brakes
digitalWrite(MotorPinBrake, HIGH);
delay(500);
digitalWrite(MotorPinBrake, LOW);
/* --- Turn Right, pause, Turn Left, pause Sequence ---*/
// Turn Right
digitalWrite(ServoPinDirection, HIGH);
analogWrite(ServoPinSpeed, 255);
delay(500);
analogWrite(ServoPinSpeed,0);
delay(500);
// Turn Left
digitalWrite(ServoPinDirection,LOW);
analogWrite(ServoPinSpeed,255);
delay(500);
analogWrite(ServoPinSpeed,0);
delay(500);
}
Am glad i got the car moving now .. truly getting started with something...