I currently have four motors connected up to a motor shield. When I load a demo sketch (below), the motors just twitch and move randomly. I currently have a .1uF capacitor across each of the motor leads, and my power source is 5xAA (7.5V) with fresh batteries. As far as I know, my Motor Shield is soldered correctly and carefully, but I will double check that once more. One side of the motors occasionally moves at the pace that I am looking for, but other than that, they move fairly randomly. I have the 4WD Robot Chassis, as built here: http://www.rugcommunity.org/page/dfrobot-4wd-arduino-mobile
The motors have the following specs:
Gear Ratio 1:120
No-load speed(3V):100RPM
No-load speed(6V):200RPM
No-load current(3V):60mA
No-load current(6V):71mA
Stall current(3V):260mA
Stall current(6V):470mA
Torgue (3V): 1.2Kgcm
Torque (6V): 1.92Kgcm
Size: 55mm x 48.3mm x 23mm
Weight:45g
and the demo sketch that I am using is as follows:
#include <AFMotor.h>
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR12_1KHZ);
AF_DCMotor motor4(4, MOTOR12_1KHZ);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
motor1.setSpeed(200); // set the speed to 200/255
motor2.setSpeed(200);
motor3.setSpeed(200);
motor4.setSpeed(200);
}
void loop() {
Serial.print("tick");
motor1.run(FORWARD); // turn it on going forward
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
delay(1000);
Serial.print("tock");
motor1.run(BACKWARD); // the other way
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
delay(1000);
Serial.print("tack");
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE); // stopped
delay(1000);
}
I would first try adding more time in between each action as one second is not enough. I would make that at least delay(7000); or higher. I have built the 2 wheeled and 4 wheeled version of that platform. http://www.robotliving.com/building-robots/two-wheeled-robot-2/
I am using Adafruit's motor shield. What motor shield are you using?
I am using Adafruit's Motor Shield as well. I wonder if my motor wires are not inserted into the correct terminals. I have each motor to the outer two terminals. So M1 has two wires going into it. Then I skip where it says GND, and then I connect the next two. I do the same for the other side.
I changed the delay to be 8000, and just my M3 and M4 were really going. There was less twitching (because the delay was greater), but still not moving according to the sketch. The sketch should have the motors run forward, pause, run backward, pause, release, and then restart the loop over again, correct?
As I look at the Serial Monitor, it shows the correct "tick", "tock", and "tack" for the respective FORWARD, BACKWARD, and RELEASE. I hear it make a ticking noise when it is trying to move, but other than that I get nothing. Could I have made an error in the build of the Motor Shield? Did you solder any capacitor to your motors? Is it the # of KHz that I set to each motor? I read that M3 and M4 can only get 1KHz.
From Adafruit's wiki on DC Motors and the Motor Shield: Create the AF_DCMotor object with AF_DCMotor(motor#, frequency), to setup the motor H-bridge and latches. The constructor takes two arguments. The first is which port the motor is connected to, 1, 2, 3 or 4. frequency is how fast the speed controlling signal is.
I think my Arduino is shorting with the Metal surface of the chassis that it is sitting on. When I hold the Arduino, the motors work perfectly. I will comment here if I run into any more problems.
EDIT: This is weird. I placed a non-conductive surface underneath the Arduino board. But even when that is there, it still twitches. But when I pick it up, it runs flawlessly. Any ideas? Possibly when the wires are more compressed (when it is sitting on the chassis) some wires are touching inside, but when I pick it up, they untouch?
How would I be able to determine that this exists, or if I can get rid of it? I do have another attachment to the chassis, which adds another level to the robot. Should I add this?
Brennn10:
How would I be able to determine that this exists, or if I can get rid of it?
By trial and error and looking for spurious resets, unconnected inputs, ground loops, etc.
I would start with ground loops and move on to capacitive coupling causing one of the chips to reset.
Are your chassis and circuit grounds connected? are they connected in a star topology (good) or connected in series (grounds at different potentials) or in more than one place (classic ground loop)? How about RFI? is there an ungrounded portion of the chassis broadcasting the rise and fall times of power FETs like an antenna? Is your ground plane capacitively coupled to that antenna?