Pages: [1]   Go Down
Author Topic: Adafruit Motorshield doesn't work properly  (Read 1177 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello and thank you in advance for your help. I have a Arduino Duemilanove and an Adafruit motor shield. I am using a 4.5V to 9 V DC motor. My arduino is powered by USB or a 9V battery. The shield and motors are powered by 12 V (8 new AAA batteries in series or one large lead acid battery) in the external power jack on the shield. The shield was built according to the instructions. The LED lights. Servos work fine. When I upload and run this following code, which is an example in the AFmotor library I downloaded to use the shield, the motor barely spins or doesn't spin at all. It does not accelerate or decelerate over the entire acceleration and deceleration periods. I confirmed on an oscilloscope that the PWM on that motor channel was working. However, with the test code pasted below, it only provided 1V of power according to the oscilloscope, which is insufficient to run the motor. I added four lines to the code and the shield worked fine. I marked these lines below. Why is this necessary? Has anyone else experienced this problem? And when must extra motor.run() commands be used?

Code:// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>

AF_DCMotor motor(4);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");

  // turn on motor
  motor.setSpeed(200);
 
  motor.run(RELEASE);
}

void loop() {
  uint8_t i;
  
  Serial.print("tick");
  
  motor.run(FORWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
    motor.run(FORWARD);                                   //was added here
    delay(10);
 }
 
  for (i=255; i!=0; i--) {
    motor.setSpeed(i);  
    motor.run(FORWARD);                                     //was added here
    delay(10);
 }
  
  Serial.print("tock");

  motor.run(BACKWARD);
  for (i=0; i<255; i++) {
    motor.setSpeed(i);
     motor.run(BACKWARD);                                        //was added here  
    delay(10);
 }
 
  for (i=255; i!=0; i--) {
    motor.setSpeed(i);  
     motor.run(BACKWARD);                                                   //was added here
    delay(10);
 }
  

  Serial.print("tech");
  motor.run(RELEASE);
  delay(1000);
}
« Last Edit: January 01, 2013, 12:10:16 pm by rifleman213 » Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That doesn't make sense. Perhaps your delay is too short. Try 50 ms.

I wrote a simple version, partly based on the Adafruit code : http://playground.arduino.cc/Main/AdafruitMotorShield
You could give it a try.

The Adafruit Motor shield will not work with 5V.
Some motors and servos require a lot of current to start. So check your power supply during operation.
Some DC motors even shortcut the power, if the speed is too low. DC motors come in all sizes and qualities and can have strange unexpected behaviour.

The servo doesn't use much of the Adafruit motor shield. It only uses the +5V and an output from the Arduino.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you. I tried 50 ms. I had the same result - the motor briefly spun over part of the acceleration/deceleration period. Once again, my oscilloscope showed that the motor was only receiving 1V of power, even though I powered the motorshield with a 12V power supply. In operation my batteries supplied 12.2 V to the motor shield, so I don't think that is the cause. I ran your code, and nothing happened. Do you know of any hardware malfunctions, either Arduino or motor shield, that could cause these issues?
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use my code to switch the outputs high and low.
If you do that, and measure the output on the connector, you can test the outputs one by one.
You could even use the shiftWrite() function to test the output pins of the shift register one by one.

But something is wrong for sure.
Can you make a photo of it and upload it ?
Are the power supply and motor strong enough to blow the L293D ?
Logged

Pages: [1]   Go Up
Jump to: