I'd think that this is a common question however I didn't find any posts describing my difficulties.
I've got a stepper motor:
https://www.sparkfun.com/products/10847An Arduino Uno and the ArduinoMotorShield.
I can get the stepper to move with accuracy at a "speed" of 30. However changing that speed will lead to the stepper not going to the correct position. And it seems to be directly related to the difference from 30. i.e. a speed of 60 makes the motor only go half it's expected distance.
I've got it power from the onboard power, also tried a 12v 1a power supply. I'm connecting the motor directly to the shield, no resistors in line (as I don't think the power supply is strong enough to overpower the board or the motor).
Another issue I'm seeing is that the LEDs on the motor shield appear to be getting feedback. i.e. when the motor isn't connected, the leds light up in a clear order. However when connected all the lights will flash making me think power is feeding back in off every coil...is that normal?
Questions:
1: Why when I change the speed does the accuracy of the stepper falter?
2: Why do all LED's on the MotorShield light up at the same time?
Here's the code I've been using:
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 13,12);
// 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(dirA, HIGH);
digitalWrite(dirB, 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 );
myStepper.step(200);
}
void loop() {
}
Thanks for any thoughts!