Ardumoto wont reverse

My Ardumoto arrived yesterday, wired it up. All seemed fine until I tried to reverse MotorB. Both Motors work fine forward, MotorA works fine in both directions.

Both motors work aswell as the Arduino Uno and I am using Vin on the Arduino to power it (9v).

I am using the SparkFun demo code (below)

/*
  6-29-10
  Pete Dokter
  SparkFun Electronics
  
  This is an example sketch for Arduino that shows very basically how to control an Ardumoto
  motor driver shield with a 5V Arduino controller board (3.3V may work, but it's out of spec
  for the L298 H-bridge logic, so no promises). If you're plugging the Ardumoto into an
  Arduino Duemilanove or similar, all the connections are done for you and you can just rewrite
  the examples in this code to your liking.
*/


int pwm_a = 10;  //PWM control for motor outputs 1 and 2 is on digital pin 10
int pwm_b = 11;  //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12;  //direction control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13;  //direction control for motor outputs 3 and 4 is on digital pin 13

void setup()
{
  pinMode(pwm_a, OUTPUT);  //Set control pins to be outputs
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);
  
  analogWrite(pwm_a, 100);  //set both motors to run at (100/255 = 39)% duty cycle (slow)
  analogWrite(pwm_b, 100);
  
}

void loop()
{
  digitalWrite(dir_a, LOW);  //Set motor direction, 1 low, 2 high
  digitalWrite(dir_b, LOW);  //Set motor direction, 3 high, 4 low
  
  delay(1000);
  
  analogWrite(pwm_a, 255);  //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_b, 255);
  
  delay(1000);
  
  digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
  digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high
  
  delay(1000);
  
  analogWrite(pwm_a, 100);  //set both motors to run at (100/255 = 39)% duty cycle
  analogWrite(pwm_b, 100);
  
  delay(1000);
}

Sxuid,

You’re probably going to need to provide more information for us to be of much help. As a start:

  • - What motors are these? (In general, if you provide links to datasheets for things, folks here are more likely to help you.)
  • - Are the two motors the same?
  • - What, if any, mechanical load do you have on the motors?
  • - If you have a mechanical load, what happens if you remove it?
  • - What happens if you switch the motor connected to A with the one connected to B?
  • - What happens if you command B to reverse, but don't command A to move at all?
  • - What happens if you command B to reverse, but disconnect A from the driver board?
  • - What happens if you reverse the connections to the B motor?
  • - What happens if you connect the B motor directly to an appropriate power source?
  • - What happens if you connect the B motor directly to an appropriate power source with the polarity reversed?
  • - What voltage is each motor seeing in each of the intended operating conditions? (9 V batteries are intended to provide very low current, so you may be having a substantial voltage sag.)
  • - What happens if you try a different power source, such as 4 alkaline AA cells in series?
  • When you’ve tried that stuff and reported your findings here, there’s a good chance one of us will be able to help you.

    Happy Hunting,

    Eric

    Extra info:

    The motors are those bundled with the 2WD Arduino Robotics Platform

    http://australianrobotics.com.au/produc … atform-kit

    Switching the motors (at the Ardumoto screw terminal) doesn’t change anything. The new MotorB won’t reverse.

    Switching the connections to MotorB doesn’t work either. It works in forward but not in reverse.

    Even with motorA disconnected or commanded not to move it still won’t reverse.

    I haven’t tried using different power sources other than over USB and the 9v.

    This makes me think it’s either the code or a faulty Ardumoto.

    Sxuid:
    Extra info: The motors are those bundled with the 2WD Arduino Robotics Platform

    http://australianrobotics.com.au/produc … atform-kit

    Unfortunately, that link doesn’t appear to lead to much in the way of specs for the motors. All I found was that they’re rated 3-6 V. (You might want to reconsider running them at 9 V, as that’s likely to shorten their lifespans.) I didn’t find anything on current requirements.

    Sxuid:
    Switching the motors (at the Ardumoto screw terminal) doesn’t change anything. The new MotorB won’t reverse.

    Switching the connections to MotorB doesn’t work either. It works in forward but not in reverse.

    Even with motor A disconnected or commanded not to move it still won’t reverse.

    What do you mean by “forward” and “reverse”? Are you referring to what you command the motor to do or which way the shaft actually spins? On a related note, what do the LEDs (on the Ardumoto) that indicate which way the Ardumoto is trying to turn the motors do when you try each motor in each direction?

    Sxuid:
    I haven’t tried using different power sources other than over USB and the 9v.

    This makes me think it’s either the code or a faulty Ardumoto.

    I certainly can’t rule those out. If you can swap motors and the problem is specific to the B terminals, but not the motor, the motor is not likely to be the problem.

    However, have you checked the connections between the Arduino and the Ardumoto? Specifically, if you command B to reverse, does the voltage on the B direction pin on the Ardumoto (pin 13, it appears from the code) change?

    More generally, I suggest putting a voltmeter on each motor terminal (referenced to ground, not the opposite terminal) of the Ardumoto and trying each motor in each direction. I’d do this with the motors connected and with the motors disconnected.

    Odd thought, while looking at the [Ardumoto schematic: There’s a voltage setting jumper. It is set to the correct position for your logic voltage?

    Here’s another odd thought: As shown in [the Uno schematic, pin 13 is “special”, in that it has an LED built into the Arduino board. If you have a bunch of jumpers handy, you could try connecting the Arduino and the Ardumoto to each other with jumpers, check to make sure the problem still occurs, then cross-connect pins 12 and 13. {EDIT: That is, connect pin 12 of the Arduino to pin 13 of the Ardumoto, and vice versa} If the problem moves from B to A, then it’s specific to the Arduino output pin. If the problem stays on B, then the problem is in the Ardumoto. If the problem is specific to that pin of the Uno, the workaround is to use some other pin for DirB, but that’ll make the “shield” fit a bit of a nuisance.

    Good Luck,

    Eric](http://arduino.cc/en/uploads/Main/arduino-uno-rev2-schematic.pdf)](http://www.sparkfun.com/datasheets/DevTools/Arduino/Ardumoto_v13.pdf)

    Hi. I’m having the exact same problem with 2 separate Ardumoto shields and an Arduino Uno, using the same sample code provided(after changing pwm a to pin 3 to accomodate the newer revision. I tried reversing pins 12 and 13 as suggested, and the problem remained on motor b with both shields. This must be a known issue… anyone?

    Looks like I solved the problem. I isolated the Vin of the Ardumoto from the Uno, and gave the motors their own power supply. Strange that it didn’t work properly before. I assumed that small motors could be run off the 5V from the Uno. I guess there wasn’t enough juice to power both the LED which came on when reversed, and the motors at the same time. I’m sure there is a more technical and elaborate explanation… I’m still puzzled about why this affected only motor b, however.

    Hi, I have two of theese in my vehicle project.I have made them work in a minute but after some time(2 days) they stopped responding to any direction change.What can be the problem?I am using them with arduino uno and 4 12V/2A motors.I even added some heatsinks on the bridges.

    So, according to your post,

    you attached 2 motors to each board, correct?

    and each motor could pull 2A, correct?

    and 2*2=4, correct?

    and the 298 datasheet says 2A chip max, correct?

    Now, you probably aren’t familiar with the concept of thermal resistance, Rth. The datasheet doesn’t show the Rth for the package you are using when it’s on a PCB (it does show for when it’s mounted on aluminum) so there’s really no way to know but it’s got to be higher than the multiwatt 15 package (which has a sorta heatsink) and that is rated at 35 degress C per watt. You can calculate the watts being dissipated in your situation by looking at the voltage drop on the datasheet - at 2A, it’s 4.9V. So, 2 Amps times 4.9V is, gulp, 9.8W. and 35 deg/W makes that a bit shy of 350 C above ambient temp. And you were doubling the current? I think the multiwatt package can handle about 2 watts in free air with out a sink. The surface mount package isn’t really well characterized by the datasheet so it’s a bit of a guess but I’d be surprised if it’s better than the multiwatt when it comes to heat.

    Now, most people that use this chip PWM it so you have to reduce the total watts by the PWM duty cycle but even 50% DC at 4Amps is going cook that puppy good.

    Seems pushing it to me.

    Ehm…I feel like an idiot right now…Thanks for quick response.But why it still works(changing speed) but doesnt change the direction?Is here some chance that the bridge is ok?Sorry for stupid questions :slight_smile:

    edit: but Sprakfun says: “Based on the L298 H-bridge, the Ardumoto can drive up to 2 amps per channel.” so it should be ok to drive two 2A motors right?

    see my edits on heat. It’s all about heat. Don’t feel like an idiot. We’ve all been there. You used it exactly as they told you to. 4A is generates a huge amount of heat. The datasheet misrepresents power handling. It says 25W but if you do the math, even the multiwatt case in free air melts down well before then. I believe the 25W spec is with a perfect heatsink. And the powerso numbers are pretty much useless.

    As for why it doesn’t reverse, one channel could have blown. Though, it’s possible there is something else going on. Assuming you changed nothing before the problem occurred, I’d say a blown channel is likely. The L298 is notorious for blowing channels.

    It would be great to see a driver shield based on some of the newer DMOS technology that doesn’t generate nearly as much heat as the old school bipolar technology.

    Thanks for explanation

    If you want to check whether the H-Bridge for motor B is still working, the best way if you have a couple of LEDs and a resistor lying around, would be to connect the resistor to one screw terminal, connect the other end of the resistor to the + (anode) of one LED, and - (cathode) of the other. The the remaining two LED legs go to the second screw terminal.

    If it is working, then in Forward, one LED should be one, in Reverse, the other LED should be on.

    Actually there are two LEDs per channel included already and in one directon is one of them on and in the opposite direction are on both:D But I have already ordered another motor driver specified up to 12A per chanel in continuous use and up to 25A in peak so this one should be enough to drive two 2A motors on channel A and two on channel B.I will do some testing if Ardumoto is dead or just part of it and think if I could use it somewhere else.

    Wow. Well they both can’t be on at once - the circuit couldn’t do that, but it could be rapidly alternating between forward and backward, in which case it would appear as if they were both on.

    As to why that would be happening, I haven’t got an answer :S

    My idea is thatit can be the logic for changing directions which si dead and that is the problem.But the Sabertooth 2x12 has just arrived and I am spending my time to get my robot moving so now I do not really care about the ardumoto.Maybe in long winter nights I will take a look at it :slight_smile: