Stepper Motor Accuracy

Doing some testing using a Pololu stepper controller:

and SparkFun stepper motor:

Connected to a 12V, 12 amp power supply.

I calibrated the amps going into the motor. (basically 70% of the motors rated amps)

There is no weight load on the motor.

But when I feed it this code about every 20 seconds:

int j;
digitalWrite(3, HIGH); //direction

for(j=0; j<=200; j++) { 
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
}

After a very few rotations the stop point is always shifting farther and farther. Like it's adding steps each rotation.

200 steps should end in the same place every time I call this code. But it never does.

Am I doing something wrong?

Thanks for any help : )

Side questions. Is there any documentation on how the combination of delay times between the HIGH/LOWs affect the speed/torque/motion?

Are there example sketches for using this controller board? Or do I have to substitute? For example dir/step code for the EasyDriver should work on the Pololu?

SparksAlot:
Am I doing something wrong?

Yes - you are assuming that a stepper motor a) has no mass, and therefore no inertia, and b) has no need for any kind of encoder to ensure repeatability in positioning.

Both of these assumptions are false; the rotor of a stepper has mass, and inertia once you have it moving. It takes time to stop such a moving mass, possibly enough time to overshoot the stopping point. A way around this would be to ramp up and down the speed as you approach end-points. With that said, a better way of determining shaft position is with an encoder of some sort.

Finally - even with all the encoders and careful stepping in the world, you're still possibly going to end up with some form of error in positioning. Welcome to the world of mechatronics.

XD

j=0; j<=200
that is 201 steps!!

Quite right. If it was not advancing one step per execution of that code, then there would be something wrong.