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.

  • 505parts on the bench
  • 45boards 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.

How it works

Three steps from a blank tab to a running circuit.

  1. Open the editor

    It runs in your browser tab. Nothing to install, and you need no account to start.

    Your first project
  2. Wire it and write the code

    Drag parts onto a breadboard, run each wire from pin to pin, and write the sketch beside it.

    Wiring
  3. Press Run

    Your sketch compiles in the tab and runs on a model of the chip, with the Serial Monitor beside it.

    Run and serial
Reviews

What makers say about Mokxi.

“The AI checker helps check and correct my circuits, and it has way more components than Tinkercad. As a student I really appreciate the tool.”

ChloeEngineering student

“I’d been looking for a real online electronic simulator that was intuitive and complete when I found Mokxi. I was able to quickly import a Fritzing file and my Arduino sketch and start testing. Mokxi has all of the makings for the best online Arduino simulator I have been able to find!”

JayModel builderFeatured in his DioramaOS post

“I’m using Mokxi to develop and simulate an STM32-based four-wheel-drive robot car before building the actual hardware. It allows me to experiment with DC motor control, PWM, RPM measurement using photointerrupters, and different acceleration, braking, and reversing strategies, helping me understand and refine the system before implementing it in real life.”

NusretRobot car builder, Hamburg

Share your story

FAQ

Questions, answered.

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.

More simulators

Each one opens on a circuit that is already running.

Make a stepper turn

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