Motor Shield and Mega rev3?

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
rwandering
 
Posts: 3
Joined: Fri Jul 12, 2013 4:01 pm

Motor Shield and Mega rev3?

Post by rwandering »

My son and I built a simple 4WD robot using a rev3 Uno and the motor shield kit. It worked great, but we decided we wanted to expand it with more capabilities so we are trying to move it over to an Arduino Mega.

We know this is supposed to work, but with the Mega, we can only get one of the wheels turning. I have actually tried two different rev3 boards (an Arduino and a Sainsmart Mega), but they both behave the same way. When we switch back to the Uno, it continues to work fine.

I know the motor shield is supposed to work with the Mega, and clearly the libraries identify it with conditional compilation.

Has the motor shield been tested with the rev3?

I assume I'll have to dig deeper into the details of how the motor shield gets its instructions . . . but any ideas how we can diagnose this problem?

Thanks,

Robert

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

Re: Motor Shield and Mega rev3?

Post by adafruit_support_bill »

Other than the added R3 pins, the Mega-R3 processor and pinouts are the same as the pre-R3 Mega. That said, I have not run the shield specifically on an R3 Mega. I'll hook one up later today to be sure.

If you post photos of the front & back of the board we'll check the assembly.

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

Re: Motor Shield and Mega rev3?

Post by adafruit_support_bill »

** Update **
I tested the motor shield on an R3 Mega 2560 and all 4 motor channels do work.

However, on further experimentation, I found that some of the PWM frequency specifications do not work on the Mega. For example, if you specify "MOTOR12_1KHZ" for all 4 channels, only M1 will run. This is likely due to the different timers used on the Mega. Using the default PWM frequency (no frequency specified in the constructor) works for all channels on the Mega.

Code: Select all

AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR12_1KHZ);
AF_DCMotor motor4(4, MOTOR12_1KHZ);

rwandering
 
Posts: 3
Joined: Fri Jul 12, 2013 4:01 pm

Re: Motor Shield and Mega rev3?

Post by rwandering »

Thanks for the info; that sounds like the issue.

I have this setup -- which I think came from the original project plans.

Code: Select all

AF_DCMotor motor1(1, MOTOR12_8KHZ); 
AF_DCMotor motor2(2, MOTOR12_8KHZ); 
AF_DCMotor motor3(3, MOTOR12_1KHZ); 
AF_DCMotor motor4(4, MOTOR12_1KHZ); 
I will try some other values for these to see what works -- I hope tonight or tomorrow.

Thanks!

rwandering
 
Posts: 3
Joined: Fri Jul 12, 2013 4:01 pm

Re: Motor Shield and Mega rev3?

Post by rwandering »

Just a follow up, I did change the code to use no frequency as you suggested and it does work. In other words:

Code: Select all

AF_DCMotor motor1(1); 
AF_DCMotor motor2(2); 
AF_DCMotor motor3(3); 
AF_DCMotor motor4(4); 
I believe that defaults to MOTOR34_8KHZ.

Thanks for your help!

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

Return to “Arduino Shields from Adafruit”