Let's Make Robots!

Confused by Arduino's new R3 motor shield.

I'm new to Arduino and microcontrollers in general. I've had an Uno for about a half of a year. Using the diagram posted by Tom Igoe (link below), I made an H-bridge to allow me to control a stepper motor with my Arduino. I made the mistake of buying an Arduino's R3 motor shield, not realizing that the design was so new. Come to find out there is little to no documentation to be found on it. My problem is that I have no clue (other than mounting the shield) on how to wire in the stepper motor and what changes to make to the sketch which works with my H-bridge. This my first shield, so I am confused as to which pins are inputs, which are outputs and which are definable. Any help would be appreciated. 

http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors

Thanks

Guy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

For working directly with a stepper motor, try this link.

http://krisarnold.com/2012/02/03/arduino-and-the-official-motor-shield-r3/

Here's a example using one DC motor on channel A controlling speed and direction.

int dirA = 12;
int dirB = 13;  // not used in this example
int speedA = 3;
int speedB = 11; // not used in this example

void setup()
{
  pinMode (dirA, OUTPUT);
  pinMode (dirB, OUTPUT);
  pinMode (speedA, OUTPUT);
  pinMode (speedB, OUTPUT);
}

void loop()
{
  // move the motor A to one direction increasing speed
  digitalWrite (dirA, HIGH);
  for (int j = 0; j < 255; j += 10) {
     analogWrite (speedA, j);
     delay (100);
  }

// stop the motor
digitalWrite(speedA, LOW);

delay(1000); // keep the motor rolling for one second

// move the motor A to one direction decreasing speed
  digitalWrite (dirA, LOW);
  for (int j = 255; j >= 0; j -= 10) {
     analogWrite (speedA, j);
     delay (100);
  }

// stop the motor
  digitalWrite(speedA, LOW);

delay(1000); // keep the motor stopped for one second

}

To be honest, this was an impulse buy. I wanted to get rid of a RS card that's been in my wallet for some time. I also wanted try out a shield (any shield) for the Arduino. I didn't read up on it before hand. I'll take the advice given and do a little more research.  Maybe I'll find a use (if not for robots) so I can justify the purchase.

Ok. The L298 was designed for low current / high voltage (up to 46V) stepper motors. It can also drive 2 DC motors. The Arduino motor sheild includes some additional logic making it easier to drive DC motors. This does not mean it cannot drive stepper motors, only that the code will be different.

From my personal experience the L298 is a poor choice for robots unless you need high voltage and low current. Although it can handle 2A per channel it needs a huge heatsink to do so for any length of time. This is because it has a relatively high voltage drop. Every robot I made using this chip (Pictomatix, Mr. Tidy are 2) suffered from poor torque due to the high internal resistance of the chip and overheating. You are better off stacking some L293D's in parallel.

Even the page he linked to says different. You will however have to do some homework. Because as he said, you will require four pins to drive a stepper. Look up the datasheet for the 298 and find the pinout. Find out where all for IN x pins go on the board. From there, as long as they are directly connected. You are in business. Otherwise, you will need to question arduino directly on how to drive a stepper with the board.

I could be wrong.

Sorry, this motor shield is not intended to drive a stepper motor, it's only useful for DC motors using one PWM and direction (optional break) pin per motor. For a stepper you would need for individual pins.

I have a version 1.1 of this shield and it probably works the same way as the version 3 shield.

http://arduino.cc/en/Main/ArduinoMotorShield

At the bottom of the page, you can find a couple of links to additional information including a sample program.

In the sample for V3, I see the pinouts, which are different than the V1 pins of 9 & 10 instead of 10 & 11:

int dirA = 12;
int dirB = 13;  // not used in this example
int speedA = 10;
int speedB = 11; // not used in this example


The other pins should be available if you can get to them somehow. I'm not quite sure how to hook up your stepper since I don't have one here to test with. Maus