Stepper Library not working but stepper motor working with basic code

Hello,

I connected an old 12V stepper motor salvaged from a printer. It has 5 wires - 1 common (to 12V supply) and 4 winding ends. I confirmed this as resistance between common and any other wire is 74 to 75 ohms.

I connected digital pins 2,3,4,5 to ULN2803 drivers input pins 1,2,3,4. The output of ULN2803 is taken from pins 18,17,16,15 and connected to 4 remaining pins of stepper motor. ULN pin 9 is connected to Arduino GND and pin 10 is connected to +12V.

I used example-> stepper -> motorknob and declared pins as 2,3,4,5 in stepper(STEPS, 8, 9, 10, 11); i selected steps as 200 and stepper.setSpeed(30); The loop contained only following statement

stepper.step(1);
delay(10);

My objective was to rotate the stepper motor continuously on no load. I was surprised that the motor was jerking and not rotating. I reduced delay time to 1 ms and eventually removed it but the motor was not rotating. I increased the delay up to 10 ms but no help.

At setspeed(100), the motor started moving sometimes. It was jerky. When I picked it in hand, it would rotate a bit and then stop but when I kept it down on table, it would stall. I thought that particular motor is not in working order so I tried two more motors but they too would rotate intermittently. What irked me most was that they would also change their directions arbitrarily any time. I have used stepper motors with other micros and never had such funny issues.

I decided to go back to basics and wrote a new sketch in which I defined 4 pins 2,3,4,5 in OUTPUT mode and outputted a sequence 0011, 0110, 1100 and 1001 on 4 lines. I inserted a delay of 10 ms between two sequences. All motors ran smoothly from a delay of 4 ms and higher. No jerks, no back and forth rotation.

My question to you all is, it seems that the hardware is properly connected and simple code is running the motors smoothly. Why is the library not working for me.

The second question is the library functions are blocking type. Is there a non-blocking type library available?

In other project using Sebastian Wallin's excellent sketch,

I am generating 1 ms interupt. I can convert it into a 4 ms interrupt and output a new sequence to a given stepper motor, if needed, and make it work in a non-blocking fashion. Any comments please?

Sorry for a very long query and thanks in advance.

It is probably that the stepping motor library required the motor coils to be connected up in a different order to that which they were. Try swapping them over. Mind you when that works then your original code won't.

We had the same problem, even though I was able to manually control the stepper motor, the library wasn’t working for us. I had LED’s attached to the outputs of the Arduino and could see that it seemed to be outputting the sequence out of order. Saw the following post, which solved our problem:
“To work with Arduino Stepper Examples you need change the sequence to (8,10,11,9), (9,11,8,10), (10,8,9,11), or (11,9,10,8).”
We went from (8,9,10,11) to (8,10,11,9) which worked.