tyhenry / CheapStepper

Arduino library for the cheap but decent 28BYJ-48 5v stepper motor with ULN2003 board
GNU General Public License v3.0
122 stars 46 forks source link

CheapStepper v0.2

An Arduino library for the 28BYJ-48 stepper motor using ULN2003 driver board

created by Tyler Henry, 6/2016

You can read some more info on the cheap yet worthy 28BYJ-48 stepper motor here.

Wiring example

Library Info

Half-stepping

CheapStepper uses an 8 mini-step sequence to perform all moves
(a.k.a half-stepping): A-AB-B-BC-C-CD-D-DA

Gear Ratio

Depending on whom you ask, the 28BYJ-48 motor has an internal gear ratio of either:

Total Steps

64:1 gear ratio * 64 steps (1 step = 8 mini-steps) per internal motor revolution =
4096 total mini-steps / revolution
or ~4076 (4075.7728) if the gear ratio is 63.68395:1

CheapStepper library defaults to 4096 mini-steps but you can call:
CheapStepper::set4076StepMode() to use 4076 steps or CheapStepper::setTotalSteps(int numSteps) to use a custom amount

Power

CheapStepper assumes a 5v power source for RPM calculations.
It's best to use an external power supply like this, wired directly to the ULN2003 driver board, rather than draw from the Arduino's onboard power, which may have insufficient amperage (>100mA needed).


Blocking Moves

The Arduino sketch "pauses" during move()


Non-blocking Moves

The Arduino sketch will continue running during the move.
You must call run() on your stepper during loop()

Note


Move a Single Mini-Step
(1/8 of 8 Step Sequence)


All move functions have ...CW() or ...CCW() variants:

e.g.