init stepper motor

Im using this cheap stepper 28BYJ-48 Stepper Motor with ULN2003 driver. As as far as I understand there are basically two ways of init the position of the stepper motor

  • Fit an absolute encoder to the motor so that you always know its position, even if it gets moved while the power is off.
  • At power on, perform a referencing procedure. Drive the motors until they hit an end stop or reference switch or sensor, at which point they know exactly where they are. Something like this:
    CNC Grbl Limit Switch Wiring The ultimate solution - YouTube

Anyone know an cheap encoder that would fit to that stepper?

Any other ideas of doing calibration? Im using multiple steppers so need them to be calibrated together

Thanks

Many people use things like magnets with hall effect sensors or reed switches, micro switches, or optical “gap” sensors, but not knowing anything about your particular setup, I can’t advise.
Picture of gap sensor that detects a “flag” moving thru the gap.

acroscene:
Anyone know an cheap encoder that would fit to that stepper?

Three things about this ...

  • An encoder adds a very significant computational load to an Arduino so I would try to avoid it for that reason
  • The common encoders are relative encoders which do not know their own position. Absolute position encoders are available but they are considerably more expensive.
  • Unless the encoder produces the same number of steps per revolution (or a simple multiple) as the stepper motor you will not be able to relate the encoder reading to the number of motor steps.

My recommendation is to home the motor at startup and then work from that ZERO position.

...R