4WD Motor stutter problem
Yesterday I was building a Arduino-based robot (with the DFRobot 4WD kit). I put it all together and used the Adafruit motor shield to control it with my Arduino. I tested all 4 of the motors, and luckily I had soldered all the wires the same way (so that when red is + and black GND the vehicle drives forward).
I then programmed the Arduino using the MotorTest example which follows with the AFmotor library. I added all 4 motors like this:
AF_DCMotor motor(4);
Replaced with:
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
And then replace all mention of motor
with motor1
and motor
2,3,4. Like this:
motor.run(FORWARD);
becomes:
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
After I had done that I tested the robot. All went well, but as the robot approaches max velocity it simply stopped. I figured that it was probably due to the Arduino and motors using the same power source (i used the black hopper on the motor shield). So I removed the hopper and added a separate power source for the Arduino. It finally worked, but soon more problems arose.
The motors started to stutter when the velocity was high. After some research I found out that the problem was that the motors created electrical charge when moved, which caused them to stutter. I found a simple solution for this: add a 100nF capacitor to each motor.
Solder them on to the motor (so that one pin goes to the positive-side of the motor and one to the negative-side of the motor). This will reduce the stuttering. This worked like a charm for me! Now I can finally start working on my Arduino-based room cleaner.