Monday, 22 April 2013

Calibrating, and a new stepper motor library

Using the info from TriffidHunter and RichRap, I calibrated as follows:

X and Y stages: 1.5mm pitch (M10 threaded rod). 1.8º/step => 200 steps = 1 rotation. Total 200 / 1.5 = 136 steps per millimeter. Measured by running 13600 steps: 1 cm. Why am I off by an order of magnitude?

With a 10ms delay between each step, I get ~13mm. The Arduino stepper motor library appears to ignore all but the sign of the "number of steps" parameter.

It appears that what the library calls a "step" is just 1 of the 4 steps involved in a "real" step, as can be told by the two diodes turning on and off. But that doesn't explain why my 200-steps loop only does ~50 steps.

Odd. When I do 1 step at a time with a 1 second delay, it only changes LEDs every 4 seconds. With 4 steps per 1s delay, they change every second.

There is something I don't get about driving a stepper motor with this library, so I do the programmer thing: Use an abstraction interface. The AccelStepper library is not only much more advanced, it is also (gasp!) documented. Here is a minimal test program:


AccelStepper stepper(AccelStepper::DRIVER, 4, 5);

void setup()

void loop()

This just runs the motor at full speed (the library is currently limited to a max speed of 1000 since anything higher would use microseconds, and the author is concerned that those overflow after a matter of days). I will start with this because I don't need speed for calibration. The library also supports going to specific positions, which is nice. It gives a much better run, fast and even with little effort. I'm not sure that the acceleration part is really necessary here, but the basic example works smoothly, so I'll go with this, reading more documentation at home.

Quick test: Since the stepper motor driver is set to half-step, and the motor has 1.8º steps, 400 steps should be one rotation. And it is! Then 4000 steps should be 15mm... it is! Quite precisely. Y stage does the same. Z stage - I had some problems lifting the entire extruder + holder - but it, too, is precise. Beautiful.

Getting late now, so I'll calibrate the extruder motor and heater later. It seems the temperature "calibration" is just finding out what measurements melts the plastic, accurate measurements are apparently tricky, and there are variations in the thermistor.

Next time: extrusion calibration and tightening the Z stage holder: Just found that I can store the entire thing in its little corner without necessarily tilting the Z stage.

No comments:

Post a Comment