Pages: [1] 2   Go Down
Author Topic: Arduino Motor Shield R3 Help  (Read 22140 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was completely lost at first, then I found a code of someone that had the same Motor Shield, and it works.   smiley-mr-green smiley-mr-green smiley-mr-green smiley-mr-green

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);

 }
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
// 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);
 
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yup !!!

Thanks again, I would never have figured it out.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Cotati California
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


...
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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; 
 }
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote from: 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))?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have this stepper motor:

http://cjoint.com/?BLqiIz9oQvk

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
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check this video out:


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

Offline Offline
Jr. Member
**
Karma: 11
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1] 2   Go Up
Jump to: