Motorshield V2.3 Motors not running
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Dave74
- Posts: 5
- Joined: Sun Jan 17, 2021 12:43 pm
Motorshield V2.3 Motors not running
I cannot get the DC Motor to run using the Motorshield V2.3 with Arduino Mega 2560. The DC Motor runs fine when connected directly to 9V and/or 6V source. I am running the DC Motor Test code from the Adafruit library. I've connected the wall adapter to the DC jack and am using the jumper. I have a solid green light on the shield. The Serial Monitor Shows ticktocktech repeatedly. I got this to run yesterday and then wired all 4 motors up and tried different code and now nothing works.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motorshield V2.3 Motors not running
Please post a photo showing your soldering on the shield. And also please post the code you are using.
- Dave74
- Posts: 5
- Joined: Sun Jan 17, 2021 12:43 pm
Re: Motorshield V2.3 Motors not running
Thank you for the quick response. Soldering is definitely not our strong suit. Actually, this is the first thing my son and I have ever soldered. But, we did try to be sure no solder was connecting 2 pins together. In case it helps to diagnose the situation, I can also tell you that even when the DC Motor Test code worked for us yesterday, if I picked up the board while it was running and turned it upside down it would stop. Then when I turned it back rightside up it would start again.
Code is the DC Motor Test file unmodified.
Code: Select all
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control
For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
*/
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Adafruit Motorshield v2 - DC Motor test!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
// Set the speed to start, from 0 (off) to 255 (max speed)
myMotor->setSpeed(150);
myMotor->run(FORWARD);
// turn on motor
myMotor->run(RELEASE);
}
void loop() {
uint8_t i;
Serial.print("tick");
myMotor->run(FORWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(10);
}
Serial.print("tock");
myMotor->run(BACKWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(10);
}
Serial.print("tech");
myMotor->run(RELEASE);
delay(1000);
}
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motorshield V2.3 Motors not running
That is a pretty good indication that you have some marginal connection or connections on the board. The soldering looks mostly OK. However, a couple of suspicious looking solder joints also happen to be pins used to control the shield.if I picked up the board while it was running and turned it upside down it would stop. Then when I turned it back rightside up it would start again.
The SDA and SCL pins (leftmost two pins on the header in your first photo) are the i2c bus that is used to control the shield. The SCL looks like a possible 'cold joint' and the SDA looks like it may not have flowed onto the solder pad. (The solder on the 3rd pin (AREF) also looks suspicious, but that one is not important for the shield).
This guide has some tips on identifying and repairing common soldering problems: https://learn.adafruit.com/adafruit-gui ... n-problems
- Dave74
- Posts: 5
- Joined: Sun Jan 17, 2021 12:43 pm
Re: Motorshield V2.3 Motors not running
That seems to have fixed it. The DC Motor test is now working. Our other code where we tried to plug in the membrane keypad to drive the motor caused a problem. Specifically when we plugged the lead into pin 4 it conflicted with the motor. Not sure about 3,2,1,0. So, we moved those pins to the bottom of the board pins 31-53 and it works. We also had some issues with power. When we had the jumper on and had both the USB and the wall DC power jack plugged in it caused issues with the motor. So, we are now powering the board with 4 AA's into the power terminals and the jumper off. That seems to work. this will be the configuration anyway for the final project. Not sure why the DC wall jack was causing issues when combined with the USB. Thanks so much for the help. Any insight into the power issues or conflict with pin 4 would be interesting to know and may help us later.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motorshield V2.3 Motors not running
Analog 4 or digital 4? digital 4 is not used. Analog 4 is a duplicate of the SDA pin.Specifically when we plugged the lead into pin 4 it conflicted with the motor.
The Mega should automatically select between the USB and the DC power jack. What is the rating on the power supply? As long as it has sufficient power for the motors, it should not be a problem to connect both to the Mega.When we had the jumper on and had both the USB and the wall DC power jack plugged in it caused issues with the motor. So, we are now powering the board with 4 AA's into the power terminals and the jumper off.
That said, there are advantages to removing the VIN jumper and using a separate supply for the motors. Motors are very noisy electrically and in some cases they cause enough interference on the power rails to cause the processor to malfunction.
- Dave74
- Posts: 5
- Joined: Sun Jan 17, 2021 12:43 pm
Re: Motorshield V2.3 Motors not running
Digital I/O 4 on the side it says Digital PWM. The power supply is the one that came with the Elegoo kit. It is output 9V 1A.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motorshield V2.3 Motors not running
Digital pin 4 should not affect anything on the shield. As you can see in the schematic, it is not even connected to anything on the shield.:Digital I/O 4 on the side it says Digital PWM
https://cdn-learn.adafruit.com/assets/a ... 1396892649
Most likely it is getting overloaded by the motors, so the output voltage drops and causes your Mega to crash.The power supply is the one that came with the Elegoo kit. It is output 9V 1A.
- Dave74
- Posts: 5
- Joined: Sun Jan 17, 2021 12:43 pm
Re: Motorshield V2.3 Motors not running
Thanks for all the help. Seems to be relatively consistent now. Since I switched to batter power and not using the jumper on the shield it has been better. I also had to remove the shield and resolder the sda and scl pins (for the second time). That was definitely the original issue. Seems to be running consistently now. Thanks so much for the quick response and all the help.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motorshield V2.3 Motors not running
Good to hear things are running now. Thanks for the follow-up.
Please be positive and constructive with your questions and comments.