Motor shield

by wzchang on Sun Feb 24, 2013 7:30 pm

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 837 times
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Sun Feb 24, 2013 7:34 pm

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: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Sun Feb 24, 2013 9:33 pm

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.
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Mon Feb 25, 2013 6:34 am

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?
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Mon Feb 25, 2013 10:53 am

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 797 times
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Mon Feb 25, 2013 12:03 pm

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?
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Tue Feb 26, 2013 2:02 am

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 777 times
maxon_motor_spec.jpg
maxon_motor_spec.jpg (93.1 KiB) Viewed 777 times
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Tue Feb 26, 2013 7:10 am

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?
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Tue Feb 26, 2013 10:12 am

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.
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Tue Feb 26, 2013 11:25 am

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

Code: Select all | TOGGLE FULL SIZE
#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?
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Tue Feb 26, 2013 11:54 am

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.
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Tue Feb 26, 2013 12:05 pm

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 | TOGGLE FULL SIZE
// 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);
  }
}
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield

by wzchang on Tue Feb 26, 2013 12:27 pm

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 7:16 pm

Re: Motor shield

by wzchang on Tue Feb 26, 2013 12:28 pm

Sorry. I didn't scroll down the code. Ignore the 2nd question.
wzchang
 
Posts: 18
Joined: Sun Feb 24, 2013 7:16 pm

Re: Motor shield

by adafruit_support_bill on Tue Feb 26, 2013 1:40 pm

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.
User avatar
adafruit_support_bill
 
Posts: 28916
Joined: Sat Feb 07, 2009 9:11 am