I am using the motor shield attached to an Arduino Leonardo to run a 4 motor robot platform.When I turn on the power the right rear motor immediately starts. When I run a motor test program the other 3 motors run correctly but the right rear motor shuts down and runs when the other 3 motors shut down.Any ideas why this is occurring??
Thanks
motor shield issue
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: motor shield issue
The Leonardo is not completely compatible with Atmega 328-based Arduinos and we haven't tested compatibility with all shields. As the product description states:
It is probably not going to work with nearly any shields other than the proto shield. We haven't gone through and tested it with all the Adafruit shields and don't guarantee it will work until we've sat down and done a lot of testing and coding, so keep that in mind!
-
- Posts: 2
- Joined: Wed Nov 14, 2012 8:24 pm
Re: motor shield issue
Thanks-I will try it with an uno.
- adeering
- Posts: 13
- Joined: Wed Nov 14, 2012 3:29 am
Re: motor shield issue
Is there any word about making the shields work with the leonardo, working on a project that would benefit from the leonardo, but need the motor shield.
-
- Posts: 2
- Joined: Tue Dec 04, 2012 3:21 pm
Re: motor shield issue
Today I encountered the same issue. Too bad it's my first encounter with Arduino
I have got a Leonardo board and the motor shield, that have to work together. I don't have neither the time, nor the money to buy a Uno (and waste the Leonardo).
After extensive research and some AVR crash-course it looks like pins 3 and 11 are easy, insted of Timer2 they are on Timer0, which on the Leo is 8 bit too. Then when comparing datasheets I noticed that the Leo sets OC0A sets on match, clears on TOP, while the Uno setst OC2A on match and clears it on BOTTOM. Is this difference going to cause trouble?
Pins 5 and 6 seem a bit more tricky, as it's Timer4 that sets them and it's a 10 bit high speed timer with the option to work in 8 bit mode. Again, if I understand the datasheet correctly, unless the extra 2 bits (accessed in a 2-step way, due to the 8bit bus) are set, it works in 8-bit mode.
Then the configuration registers are set a bit differently (4 8-bit registers). There is a wave-form generation mode, but it differs again. "Update of OCR4x at TOP" "TOV4 Flag Set on TOP", while for the timer on the Uno its BOTTOM/MAX. Again I am not sure if this will be a problem.
I am modifing the AFMotor.cpp and will try. The trouble is the only motors I have now are 4V bipolar steppers and the shield is rated for 4.5V+ so maybe the modifications would be enaugh to get the shield working, but it won't be able to power the motor, or it is able to power it, but the modifications won't work. Either way if it doesn't work I won't have a way to know why
The changed code is here: http://BANNED.com/W8PzChgJ
It's only the inline functions defined after
/******************************************
MOTORS
******************************************/
If this actually works I will make it into a patch and make a pull request.
I have got a Leonardo board and the motor shield, that have to work together. I don't have neither the time, nor the money to buy a Uno (and waste the Leonardo).
After extensive research and some AVR crash-course it looks like pins 3 and 11 are easy, insted of Timer2 they are on Timer0, which on the Leo is 8 bit too. Then when comparing datasheets I noticed that the Leo sets OC0A sets on match, clears on TOP, while the Uno setst OC2A on match and clears it on BOTTOM. Is this difference going to cause trouble?
Pins 5 and 6 seem a bit more tricky, as it's Timer4 that sets them and it's a 10 bit high speed timer with the option to work in 8 bit mode. Again, if I understand the datasheet correctly, unless the extra 2 bits (accessed in a 2-step way, due to the 8bit bus) are set, it works in 8-bit mode.
Then the configuration registers are set a bit differently (4 8-bit registers). There is a wave-form generation mode, but it differs again. "Update of OCR4x at TOP" "TOV4 Flag Set on TOP", while for the timer on the Uno its BOTTOM/MAX. Again I am not sure if this will be a problem.
I am modifing the AFMotor.cpp and will try. The trouble is the only motors I have now are 4V bipolar steppers and the shield is rated for 4.5V+ so maybe the modifications would be enaugh to get the shield working, but it won't be able to power the motor, or it is able to power it, but the modifications won't work. Either way if it doesn't work I won't have a way to know why
The changed code is here: http://BANNED.com/W8PzChgJ
It's only the inline functions defined after
/******************************************
MOTORS
******************************************/
If this actually works I will make it into a patch and make a pull request.
-
- Posts: 2
- Joined: Tue Dec 04, 2012 3:21 pm
Re: motor shield issue
Not surprisingly Timer2 was successfuly replaced with Timer0 and I am driving one stepper up to 300RPM.
For the future generations:
The documentation states that the complimentary pin to OC4A - pin 5 is connected when COM4A1..0 is set to 01. This way the shield doesn't turn the steppers. If it's 10 it works.
Timer4 works like e regular 8bit timer and the only thing required to put in in Fast-PWM mode is to set the relevant COM4x1..0 and PWM4x.
This way both stepper output works on the Arduino Leonardo board with no hardware modifications and a few additions to the library code.
The tested by me code: http://BANNED.com/LwaHubCZ
For the future generations:
The documentation states that the complimentary pin to OC4A - pin 5 is connected when COM4A1..0 is set to 01. This way the shield doesn't turn the steppers. If it's 10 it works.
Timer4 works like e regular 8bit timer and the only thing required to put in in Fast-PWM mode is to set the relevant COM4x1..0 and PWM4x.
This way both stepper output works on the Arduino Leonardo board with no hardware modifications and a few additions to the library code.
The tested by me code: http://BANNED.com/LwaHubCZ
- xchg.ca
- Posts: 6
- Joined: Sun Mar 31, 2013 5:40 pm
Re: motor shield issue
I've tried your code and MOTOR1-2 works well, but MOTOR4 doesn't show sign of life. MOTOR3 values are very strange, but the code motor should spin with speed 200, but motor 3 stop, starts, stop with different time intervals....moridinbg wrote:Not surprisingly Timer2 was successful replaced with Timer0 and I am driving one stepper up to 300RPM.
The tested by me code: http://BANNED.com/LwaHubCZ
Do you know what might be a problem?
Here is my test code
Code: Select all
#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.setSpeed(200);
motor.run(FORWARD);
delay(10000);
}
- xchg.ca
- Posts: 6
- Joined: Sun Mar 31, 2013 5:40 pm
Re: motor shield issue
Here are my changes:
https://github.com/riahut-dot-com/Adafr ... 812a03c21b
https://github.com/riahut-dot-com/Adafr ... 812a03c21b
Please be positive and constructive with your questions and comments.