Motor shield

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Motor shield

Post by wzchang »

I purchased two Arduino motor shields from you back in November 2012. I would appreciate it if you could provide me some guidance to troubleshoot the problem I am facing now.
I am trying to set up a demo for high school students to show how Arduino board with Adafruit motor controller can control with feedback loop, PID. I am using a setup that can demonstrate the PID concepts with your motor shield. The setup can be seen from the attached motorshield_setup screenshot, and the motor test code is from your example, Motor test.pde, which is also attached as Motorshield_questions_codeonly.docx.

The problem is that I don't see the motor turning backward, eventhough the print out showing the "backward" from Serial.print. Is there something fundamentally wrong here?
When I am trying to run my own script, the motor turns, and gives out encoder signals, but also tuning only in one direction and always stops at some preset turns. Therefore I never be able to see the PID adjustment effect.

Motor Test.pde code

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

#include <AFMotor.h>

AF_DCMotor motor(2);

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

// turn on motor
motor.setSpeed(20);

motor.run(RELEASE);
}

void loop() {
uint8_t i;

Serial.print(i);

motor.run(FORWARD);
for (i=0; i<25; i++) {
motor.setSpeed(i);
delay(10);
Serial.print(i);
Serial.print("forward");
}
//
for (i=25; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}

Serial.print("tock");

motor.run(BACKWARD);
for (i=0; i<25; i++) {
motor.setSpeed(i);
Serial.print("backward");
Serial.print(i);
delay(10);
}

for (i=25; i!=0; i--) {
motor.setSpeed(i);
delay(10);
}
//
//
// Serial.print("tech");
// motor.run(RELEASE);
// delay(1000);
}
Attachments
motorshield_setup.JPG
motorshield_setup.JPG (99.06 KiB) Viewed 1626 times

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

Re: Motor shield

Post by adafruit_support_bill »

You have one of the motor leads connected to ground. The H-bridge circuit cannot reverse the motor if one of the leads is connected to ground.

Connect the motor leads to the two terminals of M2 and it should work for you.

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

Thank you. I connected two leads to M2's two terminals, then no motion at all. I uploaded the same code, and push the reset button, no motor motion observed.

adafruit_support wrote:You have one of the motor leads connected to ground. The H-bridge circuit cannot reverse the motor if one of the leads is connected to ground.

Connect the motor leads to the two terminals of M2 and it should work for you.

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

Re: Motor shield

Post by adafruit_support_bill »

Can you post a photo showing the solder side of the board?
It could be a bad solder joint somewhere. It could also be a blown or partially blown H-bridge. Have you tried any of the other motor ports? What motor are you using?

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

I have used other ports and have the same results with no motion. When I use 1 ground and 1 Motor 1 the motor rotates constantly in one direction, and 1 ground and 1 Motor 2, it rotates intermittently, only in 1 direction. The motor is Maxon 2140.937-58 236-050 DC motor using 12V. I also attached the image of the other side of motor shield. Thank you.
Attachments
motorshield_side2.JPG
motorshield_side2.JPG (76.81 KiB) Viewed 1586 times

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

Re: Motor shield

Post by adafruit_support_bill »

Do you have a spec sheet on that motor? I couldn't find anything on-line that listed a current rating. If not, measure the resistance across the motor terminals, that should give us a very rough idea.

Can you post a close-up photo of the motor? I am most interested in the end with the terminal connections.

Looks like a few suspicious solder joints on the shield itself, you may want to read through our soldering tutorial and touch up a few of them: http://learn.adafruit.com/adafruit-guid ... n-problems
When I use 1 ground and 1 Motor 1 the motor rotates constantly in one direction,
What happens when you keep the ground connection and move the other lead to the other M1 terminal?

With no motor connected. What voltages do you see on each of the M1 terminals when running your sketch?

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

I uploaded both maxon motor spec sheet and motor's end view, note that the white ribbon cable is for the encoder.
When I keep the ground connection and move the other lead to the other M1 terminal, the motor keeps rotate constantly same as the previous connection, no change.
With no motor connected, the voltage across both M1 leads is 0, but across 1 M1 and ground is 12 V which is what I applied. There is no voltage at all in M2, M3 and M4 leads, except for the case of 1 lead to ground and the other to M2, you see a bit voltage fluctuating around 2-3 volts. Thank you for troubleshooting with me.
Attachments
maxon_motor_end_view.JPG
maxon_motor_end_view.JPG (78.42 KiB) Viewed 1566 times
maxon_motor_spec.jpg
maxon_motor_spec.jpg (93.1 KiB) Viewed 1566 times

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

Re: Motor shield

Post by adafruit_support_bill »

the voltage across both M1 leads is 0, but across 1 M1 and ground is 12 V which is what I applied.
There are two terminals on M1, do they both measure the same with respect to GND?
What sketch are you running when you do this test?

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

Yes. Voltage across both M1 terminals with respect to the ground are the same. The sketch I am running is posted at the beginning of the thread.

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

Re: Motor shield

Post by adafruit_support_bill »

The sketch I am running is posted at the beginning of the thread.

Code: Select all

#include <AFMotor.h>

AF_DCMotor motor(2);
Altered to use M1 instead of M2?

It appears that both halves of your H-bridge are open to the 12v rail. I'd suspect a burnt L293D, but you are reporting the same on all 4 channels. When you tested on the other channels, did you modify the sketch to drive those channels?

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

I always used M2, and just for the testing purpose, I used M1. It seems M1 at least rotates when the motor is connected to GND and 1 M1 terminal.
I didn't change channels in the sketch when I tested M3 and M4. Maybe I should. I won't be able to do this change at this moment. It has to be tonight.

I am not sure whether the voltage rating matters at this point, the Maxon motor is rated 24V, but I only used 12V. My DC supplies the maximum of 20V.

Thank you.

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

Re: Motor shield

Post by adafruit_support_bill »

Stick with the 12v for now until we get a handle on what the controller is doing.

Tests on ports that have no associated motor code will be inconclusive. The outputs will be undefined.

Try this sketch. It should drive all 4 ports in unison. If you measure between the two terminals on each of the motor channels, you should (if everything is working properly) see the voltage ramping up and down (and going negative for reverse).

Code: Select all

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

#include <AFMotor.h>

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

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

  // turn on motor
  motor1.setSpeed(200);
  motor2.setSpeed(200);
  motor3.setSpeed(200);
  motor4.setSpeed(200);
 
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
}

void loop() 
{
  uint8_t i;
  
  Serial.print("tick");
  
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
  for (i=0; i<255; i++) 
  {
    motor1.setSpeed(i);  
    motor2.setSpeed(i);  
    motor3.setSpeed(i);  
    motor4.setSpeed(i);  
    delay(10);
  }
 
  for (i=255; i!=0; i--) 
  {
    motor1.setSpeed(i);  
    motor2.setSpeed(i);  
    motor3.setSpeed(i);  
    motor4.setSpeed(i);  
    delay(10);
  }
  
  Serial.print("tock");

  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  for (i=0; i<255; i++) 
  {
    motor1.setSpeed(i);  
    motor2.setSpeed(i);  
    motor3.setSpeed(i);  
    motor4.setSpeed(i);  
    delay(10);
  }
 
  for (i=255; i!=0; i--) 
  {
    motor1.setSpeed(i);  
    motor2.setSpeed(i);  
    motor3.setSpeed(i);  
    motor4.setSpeed(i);  
    delay(10);
  }
}

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

Should the motor be connected for the measurement? How do you get reverse, since I don't see the reverse command in the sketch? I will do this in 10 hours from now. Thank you very much!

wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 8:16 pm

Re: Motor shield

Post by wzchang »

Sorry. I didn't scroll down the code. Ignore the 2nd question.

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

Re: Motor shield

Post by adafruit_support_bill »

For now, there is no need to connect the motor. Let's see if we get the voltages we expect.

Measuring between the two terminals, you should see the voltage ramp up to 12v, then down to -12v and back up again.

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

Return to “Other Arduino products from Adafruit”