Arduino Motor Shield R3 Help

Hello,

This is my first time playing with Arduino.

I have an Arduino Uno and Motor Shield R3.
I have not been able to find any information on the Motor Shield R3, except for this: http://arduino.cc/en/Main/ArduinoMotorShieldR3

Can anyone help me connect a bipolar stepper motor and get it running. I have found tutorials with older Arduino Motor Shields but no the R3. Do I connect all 4 of the stepper motor wires to the A+,A-,B+,B- ? And then control the steps with the #12 & #13 pins (Dir A, Dir B)

Thank You

insert:
Can anyone help me connect a bipolar stepper motor and get it running. I have found tutorials with older Arduino Motor Shields but no the R3. Do I connect all 4 of the stepper motor wires to the A+,A-,B+,B- ? And then control the steps with the #12 & #13 pins (Dir A, Dir B)

Yes. Be sure to set pins 3 and 11 (PWM-A and PWM-B) to HIGH to turn on power. You should probably also turn 8 and 9 to LOW to turn off the brakes.

If you want to hold position without heating up the stepper you can use analogWrite() on 3 and 11 to reduce the power. If you want to release the motor so you can turn the shaft by hand, set 3 and 11 to LOW.

I was completely lost at first, then I found a code of someone that had the same Motor Shield, and it works. :grin: :grin: :grin: :grin:

Thanks for your help.

Incase someone else runs into this problem, this is the code that worked:

#include <Stepper.h>

const int stepsPerRevolution = 48; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 12,13);

// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;

int x = 0;
void setup() {
Serial.begin(9600);
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);

// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
myStepper.setSpeed(2);
}

void loop() {

myStepper.step(48);
myStepper.step(-48);

delay(2000);

}
[/table]

Well look at that! Exactly what I told you to do.

 // set the PWM and brake pins so that the direction pins  // can be used to control the motor:
pinMode(pwmA, OUTPUT);
 pinMode(pwmB, OUTPUT);
 pinMode(brakeA, OUTPUT);
 pinMode(brakeB, OUTPUT);
 digitalWrite(pwmA, HIGH);
 digitalWrite(pwmB, HIGH);
 digitalWrite(brakeA, LOW);
 digitalWrite(brakeB, LOW);

Yup !!!

Thanks again, I would never have figured it out.

Thanks for posting the code, that looks like exactly what I need. Could you possibly elaborate on how you connected up the stepper motor? I have 8 wires in total from my stepper motor (a Nema23 model) which are coloured Black, White, Orange, Yellow, Brown, Red, Blue and Green. If I can figure out how to wire it up I will post a diagram.

Kind Regards,
Dan

Tell me again your stepper motor connections? how do I wire the two coils? If I connect them across A+/A- and B+/B-, thats all four wires. What are you connecting pins 12 and 13??

thanks

insert:
...
Can anyone help me connect a bipolar stepper motor and get it running. I have found tutorials with older Arduino Motor Shields but no the R3. Do I connect all 4 of the stepper motor wires to the A+,A-,B+,B- ? And then control the steps with the #12 & #13 pins (Dir A, Dir B)

Thank You

Im in the same exact boat!!! I have an Arduino uno+R3 motor shield with a nemea 23 stepper but it had 6 wires. According to wiring diagram the green and black was one coil and the red and blue was the other, then directions i found stated to have the center taps, in my case white and yellow connected to ground. I then plugged in black to A+ and Green to A- , then Red to B+ and Blue to B- I took the white and yellow twisted together and connected to the GND terminal. which I can't verify that it works cause the code below sort of moves the motor, the shaft sort of vibrates and when it gets to what i think is wave the flag the motor shaft turns a little:

#include <Stepper.h> //include the function library
#define STEPS 200 //1.8 deg motor (200 steps per rev)
Stepper stepper(STEPS, 12, 13); //create the stepper

void setup()
{
int i;
stepper.setSpeed(30); //set speed to 30 rpm
delay(1000); //pause for effect
stepper.step(200); //move 360 deg one direction
delay(1000); //pause for effect
stepper.step(-200); //move 360 deg in the other direction
delay(1000); //pause
stepper.setSpeed(60); //speed up
for (i=0;i<5;i++) {
stepper.step(20); //wave the flag
stepper.step(-20);
}
}

void loop()
{}

If any of you guys see something wrong with the code or the wiring for the motor let me know. the Arduino book I have by Simon Monk arrived and turned out to not have anything about wiring up steppers. Which is frustrating

I also gave the other sketch a try and for a minute the motor was incrementally rotating and you could see the LED for A+ A- B+ B- moving and the shaft rotating but then it started doing other things like ticking back and fourth by 1.8 degrees randomly. I was curious when you up load the sketch does it erase the previous one?

wiring sounds correct, without knowing the specs of your motor.

It does sound like your code though. The r3 board, I think, uses different parameters.

I'm just learning this myself.

I was able to get this code to work though. Its basically the knob stepper example, but for the R3 motor shield. The values on the potentiometer could be played with to get better motion. Potiometer wiper to Analog 0, one end of the element to GND, other end to Vin.

#include <Stepper.h>

const int stepsPerRevolution = 48; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution,12,13);

// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

int previous = 0;

void setup() {
Serial.begin(9600);
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
myStepper.setSpeed(30);
}

void loop() {
// get the sensor value
int val = analogRead(0);

// move a number of steps equal to the change in the
// sensor reading
myStepper.step(val - previous);

// remember the previous value of the sensor
previous = val;
}

johnwasser:
Yes. Be sure to set pins 3 and 11 (PWM-A and PWM-B) to HIGH to turn on power. You should probably also turn 8 and 9 to LOW to turn off the brakes.

Ugh. This was exactly my problem. Wish there was more documentation about the motor shield. Thanks, John.

johnwasser:
If you want to hold position without heating up the stepper you can use analogWrite() on 3 and 11 to reduce the power. If you want to release the motor so you can turn the shaft by hand, set 3 and 11 to LOW.

Can you talk more about this? If most of the time, my stepper's going to be stationary, should I be setting it to LOW manually (and only doing a .step() when I actually want to move it, then analogWrite(3,LOW))?

Hello,

I have this stepper motor:

I think it is compatible with the Arduino Motor Shield R3 that I am considering buying.

Can you tell me how to connect the Arduino Motor Shield R3

I would like a wiring diagram of the power supply and motor

Thank you for your help

Check this video out:

The motor shield uses the exact same IC, I believe, so this should be of some help :slight_smile:

Hello,

one shield with one stepper is nice for one direction.
Is it possible to connect a second Motor Shield R3 at the Arduino?

Thanks for information

insert:
Hello,

This is my first time playing with Arduino.

I have an Arduino Uno and Motor Shield R3.
I have not been able to find any information on the Motor Shield R3, except for this: http://arduino.cc/en/Main/ArduinoMotorShieldR3

Can anyone help me connect a bipolar stepper motor and get it running. I have found tutorials with older Arduino Motor Shields but no the R3. Do I connect all 4 of the stepper motor wires to the A+,A-,B+,B- ? And then control the steps with the #12 & #13 pins (Dir A, Dir B)

Thank You

http://arduino.cc/forum/index.php/topic,140631.0.html

hello, I want to know the voltage that provide two channels for motor DC

phthalo:
Hello,

one shield with one stepper is nice for one direction.
Is it possible to connect a second Motor Shield R3 at the Arduino?

Thanks for information

yes you can use two, but not one on the other, you must put the other one next to your Arduino connect the pins of the "side-car" shield to others pins than the ones used by the first one ex:

==============================================
Arduino pin| shield on the Arduino | side-car shield
=========|===================|================
0 |NC |NC
1 |NC |NC
2 |NC |BRAKE A
3 | PWM A |NC
4 |NC |BRAKE B
5 |NC |PWM A
6 |NC |PWM B
7 |NC |DIR A
8 |BRAKE B |NC
9 |BRAKE A |NC
10 |NC |DIR B
11 |PWM B |NC
12 |DIR A |NC
13 |DIR B |NC
A1 |SNS 0 |NC
A2 |SNS 1 |NC
A3 |NC |SNS 0
A4 |NC |SNS 1
A5 |NC |NC

(you can change the pins connection of the side car shield if you want but make sure that you don't use a used pin by the "on Arduino" shield.
Of course you also need to connect the Vin pin, Gnd pin and 5V pin.

I don't have two shield so I can't show you a photo but it is something easy to do.

i want to use servo in motor shield r3.. how to use it ?

thank you

Bonjour à tous, j'utilise arduino motor shield R3 pour alimenter diffèrents cantons d'un réseau de train miniature HO. Que se passe-t-il si au passage d'un canton à l'autre, les 2 sorties A et B de la carte se retrouvent en // pendant qq secondes ??
merci de votre réponse.
Claude