Motor shield compatability???

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
larley
 
Posts: 1
Joined: Thu Feb 10, 2011 6:34 pm

Motor shield compatability???

Post by larley »

The Motor Shield works great on the UNO board, however it will not work on the Mego 2560. Is there a compatability issue? If not, what am I doing wrong?

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield compatability???

Post by adafruit_support_bill »

Do you have the latest library? There were recent (early January) changes to add support for the Mega 2560.

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

I just had an issue that I can squarely blame on the Mega 2560. I adapted the demo code to go through all four motors (Front left, front right, back left, back right) and it does not work as expected on the Mega. My library was just re-downloaded and installed 20 minutes ago and the program has been recompiled since. Symptoms: On the Uno, the four wheels run properly. On the Mega, only motor 1 runs properly. The other three wait out their delays without movement. Serial output is as expected and identical on both boards.

Power is coming from an external power source. The Arduino and the Motor Shield have independent power sources (5x AA for the motors, USB to the computer for the Arduino.) There is no excessive heat on the motor drivers.

Quite literally, the ONLY difference is which board use. Attached is the code:

Code: Select all

#include <AFMotor.h>

AF_DCMotor motorBL(1, MOTOR12_1KHZ);
AF_DCMotor motorBR(2, MOTOR12_1KHZ);
AF_DCMotor motorFL(3, MOTOR12_1KHZ);
AF_DCMotor motorFR(4, MOTOR12_1KHZ);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");
  
  motorBL.setSpeed(200);     // set the speed to 200/255
  motorBR.setSpeed(200);     // set the speed to 200/255
  motorFL.setSpeed(200);     // set the speed to 200/255
  motorFR.setSpeed(200);     // set the speed to 200/255
}

void loop() {
  Serial.println("BACK LEFT forward ");
  
  motorBL.run(FORWARD);      // turn it on going forward
  delay(1000);

  Serial.println("BACK LEFT backward ");
  motorBL.run(BACKWARD);     // the other way
  delay(1000);
  
  Serial.println("tack");
  motorBL.run(RELEASE);      // stopped
  delay(1000);
    Serial.println("FRONT LEFT forward ");
  
  motorFL.run(FORWARD);      // turn it on going forward
  delay(1000);

  Serial.println("FRONT LEFT backward ");
  motorFL.run(BACKWARD);     // the other way
  delay(1000);
  
  Serial.println("tack");
  motorFL.run(RELEASE);      // stopped
  delay(1000);
    Serial.println("BACK RIGHT forward ");
  
  motorBR.run(FORWARD);      // turn it on going forward
  delay(1000);

  Serial.println("BACK RIGHT backward ");
  motorBR.run(BACKWARD);     // the other way
  delay(1000);
  
  Serial.println("tack");
  motorBR.run(RELEASE);      // stopped
  delay(1000);
    Serial.println("FRONT RIGHT forward ");
  
  motorFR.run(FORWARD);      // turn it on going forward
  delay(1000);

  Serial.println("FRONT RIGHT backward ");
  motorFR.run(BACKWARD);     // the other way
  delay(1000);
  
  Serial.println("tack");
  motorFR.run(RELEASE);      // stopped
  delay(1000);
}

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

... or am I alone on this one?

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield compatability???

Post by adafruit_support_bill »

I'm trying to track down a spare Mega to verify this with. The support is there in the code and others have reported using it with success. Can you post the code you are using?

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

The simplest code I could make that replicates the problem is attached to the OP. I hope I don't have a defective Mega. It's brand new - my birthday gift to myself.

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

Also - if there's anything else I can do to help, let me know. I have a long weekend ahead and another couple hundred bucks of parts coming from Adafruit for it, so I'm in "hacking mode!"

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield compatability???

Post by adafruit_support_bill »

I don't have a 2650 handy, but I confirmed the same problem exists on a Mega 1280. The AFMotor library has code to map the pins for both Megas. We'll have to take a closer look at it to see what the problem is.

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

Thanks for the confirmation. You're welcome to ping me (thoughtfix on anything) when any libraries are updated and I'll run the same code test on my 2650 and report results. If I have to #define something in my code to identify it as a 2650 before compiling, that's not a big deal either.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Motor shield compatability???

Post by adafruit »

we cant reproduce this error. we have an atmega1280 mega with a scope on the motor out pins and all of them are working :/
please try arduino v21 and the motortest.pde with the latest library from
https://github.com/adafruit/Adafruit-Mo ... ld-library

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

Okay! I'll test it tonight.

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor shield compatability???

Post by adafruit_support_bill »

I experimented with it some more this afternoon. The problem is with specifying the PWM frequency for motors 3 & 4. In the code example you posted, you specified frequency parameters for all the motors. When I do that, I see the Motor-1 only symptom you reported.

Code: Select all

AF_DCMotor motorBL(1, MOTOR12_1KHZ);
AF_DCMotor motorBR(2, MOTOR12_1KHZ);
AF_DCMotor motorFL(3, MOTOR12_1KHZ);
AF_DCMotor motorFR(4, MOTOR12_1KHZ);
But, if you eliminate the frequency parameter for motors 3 & 4, it works fine. :D

Code: Select all

AF_DCMotor motorBL(1, MOTOR12_1KHZ);
AF_DCMotor motorBR(2, MOTOR12_1KHZ);
AF_DCMotor motorFL(3); //, MOTOR12_1KHZ);
AF_DCMotor motorFR(4); //, MOTOR12_1KHZ);

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

That never would have occurred to me.
Excellent support work :D

User avatar
thoughtfix
 
Posts: 70
Joined: Mon May 23, 2011 3:44 pm

Re: Motor shield compatability???

Post by thoughtfix »

All four motors now work. I have to tweak some of the backup/turn code because the 3/4 motors go forward at the right speed but not backward. Odd. I'll figure it out and post my results.
angry robot.jpg
angry robot.jpg (64.28 KiB) Viewed 2667 times
Thanks again!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”