What the course teaches
Stepper motion planning is seven lessons on the Uno, in three chapters:
- One axis, done right: what one STEP pulse is worth on an A4988 and a TMC2209 and how each reads its mode pins, steps per millimeter, one microstep and the pulse budget; trapezoid, triangle and S-curve ramps worked out and run; AccelStepper's recurrence, where it brakes, what stop() does, and the step rate an Uno tops out at.
- Two axes and a language: the dog leg two free-running motors draw, Bresenham's line algorithm by hand and on the motors, feed along the path and a per-axis rate limit; a G-code parser with words, G92, modal motion, relative mode, line numbers and checksums.
- A real machine: homing that seeks, brakes, backs off, touches slowly and pulls off; soft and hard limits; and the boss, a two-axis G-code plotter you home, drive and tune.
It goes under Motors and motion and Printer and CNC basics, which teach STEP, DIR and a first homing switch. Each chapter ends in a short quiz. Open it from /learn.
The circuits
Every lesson runs a sketch written for the course, on one of two circuits:
- Stepper bench: a NEMA 17 on an A4988 (STEP 3, DIR 4, EN 8, MS1 to
MS3 on 5, 6 and 7) and another on a TMC2209 (STEP 11, DIR 12, EN 10, MS1
and MS2 on A2 and A3). The mode pins are on the Uno so the sketch can
change the microstep setting while it runs. It runs
smpmicro,smprampandsmpaccel. - Two-axis plotter: X on an A4988 and Y on a TMC2209, both at 1/8 step
(40 steps a millimeter on a GT2 belt), a min end switch on each axis (A0
and A1, pressed reads LOW) and a pen servo on pin 9. It runs
smpsyncandsmpplot, the G-code firmware.
The sketches take commands typed into the Serial Monitor, and the checks read what really happened: each driver's microstep setting, each motor's shaft angle, the pen servo's horn and what the sketch prints.
The G-code firmware
smpplot understands G0, G1 (with F in mm a minute), G4, G28, G90, G91,
G92, M3 and M5 (pen down and up), M18 and M114. A line may start with a
line number and end with a checksum, the XOR of every character before the
star, as Marlin checks it: N10 G92 X0 Y0*34. Every good line gets ok
and a bad one gets error: and the reason. Type demo to draw its built-in
square and star.
It is a teaching firmware, about 400 lines, not Grbl or Marlin. It plans a trapezoid for each move on its own and stops at every corner; real firmwares look ahead over many lines.
Troubleshooting
- Homing says waiting for the switch to open. Mokxi has no carriage, so you play it: hold the switch while an axis seeks, let go when it waits, click again on the slow touch, and let go once more after the pull-off.
- A move answers position unknown. Send G28 to home, or G92 X0 Y0 to say where the pen is.
- Every move answers alarm. An end switch was pressed mid-move. Let go of it and send G28.
- Lines get lost. Send one line at a time and wait for its ok, as a real sender does: the Uno's receive buffer is 64 bytes.
- The shaft angle is not a round number. Each motor starts a little off zero (2.7 or 0.9 degrees), where its driver's power-up state puts the field. Count from there.
Related
Servos, solenoids and actuators for things that move to a place, and Robot kinematics for the geometry of arms and wheeled robots.