Bipolar Motor - First Step Wrong Direction

Dear Forum Arduino members,

I have a bipolar stepper motor,
which makes forward steps by powering up
the wires in the order Wire 1, Wire 3, Wire 2, Wire 4.
And as you may guess the backward steps can be obtained by
reversing the sequence above, i.e., Wire 4, Wire 2, Wire 3, Wire 1.
My problem is the following: When I send my first HIGH to Wire 1
for stepping forward, it sometimes steps backward, which I think is
because my final position was obtained by sending HIGH to Wire 3.

Therefore, I need to determine in which position my BP motor is located
before sending my pulses...
What can be the way for determining the position of my BP motor?
Do you think I should save to a memory the number of wire which is fired up
at the end of my routine?
Or can I determine it by some other way?
I am using L293D Motor Shield without its library supplied by Adafruit.

Thank you.
bkarpuz

There may not be much you can do about it. When powered up the motor will naturally move to the nearest full step position. That's why it is usual to keep stepper motors powered all the time if accurate positioning is required.

The usual way to set the starting position for a stepper motor is to move the motor step by step until it triggers a limit switch. When the switch is triggered the Arduino should be programmed to treat that as ZERO.

The printer from which you took the motor will have had limit switches in it - probably slotted optical detectors.

...R

PS ... it is much easier to help if you keep all the questions about your project in one Thread so we have all the info in one place. You can click Report to Moderator and ask to have your two Threads merged.