Motor Shield + Stepper 324 - RPM vs Steps Problem

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
triadjon
 
Posts: 3
Joined: Thu Jul 07, 2011 12:25 pm

Motor Shield + Stepper 324 - RPM vs Steps Problem

Post by triadjon »

Hi,

Please excuse me if this is a stupid question.. or posted in the incorrect forum. I did some searching and wasn't able to find an answer to my question..

I recently purchased an Arduino Uno, Adafruit Motor Shield (81), and stepper motor (324).

I completed the Motor Shield kit and connected the stepper motor using the reference provided in the item description. So far, everything seems okay.

Here's my pin connections. (see attached picture)

M4 --- RED
M4 --- YELLOW
Gnd --- open
M3 --- GREEN
M3 --- BROWN

I loaded the AFmotor.h and ran the test code referenced in the Stepper tutorial (http://www.ladyada.net/make/mshield/use.html). I input the steps in the the AF_Stepper motor (200, 2). However, I notice a peculiar thing happening.

The stepper motor is 200 steps per revolution. So I assume if I code to move 200 steps, it will make one revolution..

motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);

However, the actual degrees of rotation are dependent on the motor.setSpeed().

For example, (truncated code)

motor.setSpeed(10);

motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);

----> This will cause the stepper to move one revolution clockwise, and one revolution counter-clockwise... but!

motor.setSpeed(100);

motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);

----> Setting the setSpeed(100) causes only about 45-degrees of movement, instead of the 360-degrees I was expecting by coding for 200 steps.


So my question is: Why is the actual rotation in steps dependent on the RPM setSpeed? I assumed that 200 steps is 200 steps.. and RPM determines how quickly the 200 steps occurs in time?

Maybe I'm just missing a simple a math element here. haha.. or maybe I wired it incorrectly.

Any advice or suggestions would be appreciated. Thank you in advance! :)

- jon





Full Code (I've tried solving this by using different stepping methods, too. (Single, double, etc).



#include <AFMotor.h>


AF_Stepper motor(200, 2);


void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

motor.setSpeed(100); // 10 rpm

motor.step(100, FORWARD, SINGLE);
motor.release();
delay(1000);
}

void loop() {
motor.step(200, FORWARD, SINGLE);
motor.step(200, BACKWARD, SINGLE);

// motor.step(200, FORWARD, DOUBLE);
// motor.step(200, BACKWARD, DOUBLE);

// motor.step(100, FORWARD, INTERLEAVE);
// motor.step(100, BACKWARD, INTERLEAVE);

// motor.step(100, FORWARD, MICROSTEP);
// motor.step(100, BACKWARD, MICROSTEP);
}
Attachments
IMG_20111121_155745.jpg
IMG_20111121_155745.jpg (104.7 KiB) Viewed 1172 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield + Stepper 324 - RPM vs Steps Problem

Post by adafruit_support_bill »

How are you powering the motors? Looks like you are running them from the Arduino supply. These motors are designed more for resolution than speed. Getting them to go faster requires more voltage & current for torque. If you try to step too fast without sufficient power, they will 'skip' steps and not go as fast as programmed.

For best performance with these motors, you want a good 12v supply connected to the external supply terminals of the shield. Be sure to remove the power jumper when you do that.

triadjon
 
Posts: 3
Joined: Thu Jul 07, 2011 12:25 pm

Re: Motor Shield + Stepper 324 - RPM vs Steps Problem

Post by triadjon »

I was thinking this same thing on my way home from work. Thank you for your response. I'll give this a try first thing tomorrow morning and report back.

- jon

triadjon
 
Posts: 3
Joined: Thu Jul 07, 2011 12:25 pm

Re: Motor Shield + Stepper 324 - RPM vs Steps Problem

Post by triadjon »

yup. that did it. oops for the silly mistake... but thank you for the quick response. :)

jon

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”