Wednesday, April 25, 2012

AdaFruit Motor Shield and the DF Robot 4WD

The last test was a good first test in that the robot moved on command and all the sensors appeared to return output (three ultrasonic sensors and the two encoders). Now it is time to deal with the power issues on the motors. First, the motors do not seem to move at all at speeds less than 200 (as specified to the AFMotor library). This implies there is not enough current going to the motors. In searching the data sheets for the motor (see they are listed at 6V and 1.2A. In looking at the data sheet for the AdaFruit motor shield (see, the shield 0.6A per bridge (and there are two) and up to 25V. Seems that there is just not enough current per bridge. According to their faq (see, they recommend two things. First attach capacitors to the motor to provide better power regulation, and the second is double up on the L293D chips to improve power output. Seems like both are needed as I am seeing both problems.

First, I decided to measure the power draw before doing anything. This means pulling everything apart and attaching the multimeter to one of the motors. I created the simplest sketch I could create. This just runs each of the forward motors at a speed of 100, then turns them off. This repeats indefinitely until powered off.
  1. #include <AFMotor.h>

  2. AF_DCMotor motor1(1);
  3. AF_DCMotor motor2(2);
  4. AF_DCMotor motor3(3);
  5. AF_DCMotor motor4(4);

  6. void setup() 
  7. {
  8.   motor1.setSpeed(100);  
  9.   motor2.setSpeed(100);  
  10.   motor3.setSpeed(100);  
  11.   motor4.setSpeed(100);
  12. }
  13. void loop() 
  18.   ::delay(5000); 
  23.   ::delay(5000);
  24. }
Here is a picture of the connection of the multimeter right to the power terminals on one of the motors.

 Next, I soldered some capacitors over the motor connectors. This will help regulate the voltage. I used .1uf ceramic capacitors as recommended by the ada fruit motor shield faq. Here is a picture of the capacitor and the solder job to mount them on the motors. This took a little bit of work to get the solder iron close to the leads without having to take the motors out. I would recommend soldering these on before you put the motors in the chassis. I then repeated the test with the volt meter and observed the measurements were much more stable (about 1.7 consistently).

The final step was to double up the L293D chips. First I soldered one chip on top (make sure the U shapes are aligned). and then mounted them. I repeated the simple sketch again and now the wheels start moving at about speeds of 60. Definitely better than before.

Next up, put everything back together and try driving around again. I will also output the encoder and wheel information in ros messages so that it will be easier to record data.

No comments:

Post a Comment