Simulator

A stepper motor simulator that follows a knob

Mokxi is a free online stepper motor simulator that runs in your browser, with nothing to install and no account needed. An Arduino Uno turns a 28BYJ-48 stepper to wherever a knob points, half a step at a time, with a logic analyzer on the four coil lines so you can see the sequence walk.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno: stepper diallive0.000 s 0.00x
Click to open it in the editor
Turn the knob and the shaft goes there and stays. Click anything else to open it in the editor.

What you can do here

In the circuit above, or in the editor it opens.

  • Turn the knob and watch the shaft follow, step by step
  • See the half-step sequence on four coil lines in the logic analyzer
  • Step too fast and watch the motor miss steps like a real one
  • Try a NEMA 17 on an A4988 or a DRV8825 with STEP and DIR
  • Read every move in the serial monitor, in half-steps and degrees
  • Export the logic analyzer capture as CSV

What the running circuit shows

A stepper goes to a position, not a speed.

IN1 to IN4 on the motor’s driver board are on pins 8 to 11, and the knob’s wiper is on A0. The rotor turns 5.625 degrees a half-step and the gearbox divides by 64, so a whole turn of the output shaft is 4096 half-steps; the sketch maps the knob onto half a turn, 2048 half-steps.

In the engine the knob starts in the middle and the sketch moves the shaft to 1025 half-steps, 90.0 degrees. Turn the knob all the way and it goes to 2048 half-steps, 180.0 degrees, and the serial monitor prints both lines.

How the stepper is simulated

Coils and a magnetic field, so every drive mode works.

The part works out where the field of its four coils points and moves the rotor there, so half-step, wave drive and two-phase-on all come out of one model rather than being special cases. It has a top step rate, from the datasheet: steps closer together than about a millisecond are steps the rotor cannot follow, and it misses them as a real motor does. Nothing reads the shaft, so the sketch only believes it got there, which is why real machines home against a limit switch.

For bigger motors, the parts bin has a NEMA 17 with A4988 and DRV8825 drivers that take STEP and DIR, plus the TB6612, DRV8833 and L298N bridges for driving a bipolar motor yourself.

Questions

Is it free?

Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.

Do I need an account?

No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.

Does the Arduino Stepper library work?

The circuit on this page uses Mokxi’s stepper helper, which steps the coils the same way. Sketches using the standard Stepper library or AccelStepper compile in the editor where the board supports them.

Why is a whole turn 4096 steps?

The 28BYJ-48’s rotor moves 5.625 degrees a half-step, which is 64 half-steps a turn, and its gearbox divides by 64. 64 times 64 is 4096.

Can I simulate a NEMA 17 with an A4988?

Yes. The NEMA 17, the A4988 and the DRV8825 are all in the parts bin, and a built-in project drives one of each from the same STEP pulses.

Make a stepper turn

Open the circuit, turn the knob and press Run. Nothing to install, and no account needed.