Source: https://mokxi.com/stepper-motor-simulator

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.

Start building free or see the stepper part

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

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.

28BYJ-48 stepper with Arduino NEMA 17 on an A4988 The AccelStepper library A stepper that vibrates but does not turn Stepper motor wiring The A4988 pinout A DRV8825 on an Arduino The motor driver simulator The servo simulator

## 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.

## More simulators

Each one opens on a circuit that is already running.

Online circuit simulator Breadboard simulator ESP32 simulator Op-amp simulator Logic gate simulator LED circuit simulator Servo simulator LCD simulator OLED simulator NeoPixel simulator 7 segment display simulator LED matrix simulator Motor driver simulator Ultrasonic sensor simulator Rectifier simulator Digital circuit simulator Potentiometer simulator PWM simulator Relay simulator Shift register simulator DHT11 simulator RFID simulator Accelerometer simulator RGB LED simulator Buzzer simulator MOSFET simulator Circuit simulator for kids Flip-flop simulator Multiplexer simulator Full adder simulator I2C simulator UART simulator Thermistor simulator PIR sensor simulator Oscilloscope simulator Multimeter simulator DC motor simulator Traffic light simulator Diode simulator Capacitor simulator Series and parallel circuit simulator Wheatstone bridge simulator Voltage regulator simulator Soil moisture sensor simulator Zener diode simulator Solar panel simulator AC circuit simulator Thevenin simulator Decoder simulator Encoder simulator PID simulator Robot arm simulator Load cell simulator IR sensor simulator LM35 simulator HC-05 Bluetooth simulator nRF24L01 simulator

## Make a stepper turn

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

Start building free Open the editor
