Stepper motion planning lesson plan
What a printer’s firmware does between a line of G-code and two STEP pins: microsteps, trapezoid and S-curve ramps, AccelStepper, Bresenham, a G-code parser, homing and limits, and a plotter that does it all.
Objectives and materials
By the end, students can
- What a microstep is worth, ramps worked out and run, and the library that does it for you.
- Bresenham keeps two motors on one line, and a parser turns G-code into moves.
- Homing that brakes and backs off, soft and hard limits, and the boss: a G-code plotter.
Materials for the whole unit
- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
One axis, done right
What a microstep is worth, ramps worked out and run, and the library that does it for you.
| Lesson | Time | What students do |
|---|---|---|
| Microsteps: what one pulse is worthAn A4988 and a TMC2209 with their mode pins on the Uno. Send both the same pulses and they turn different amounts: read each chip’s table, set 1/16 and 1/64, move one microstep, and count the pulses a second each mode costs. | 65 min |
|
| Acceleration ramps: trapezoids and S-curvesJump a NEMA 17 past its ceiling and watch it lose steps. Then work out a trapezoid, find when a move becomes a triangle, run a ramp one step at a time, and see what an S-curve costs. | 65 min |
|
| AccelStepper: the ramp, done for youThe library most Arduino machines use: moveTo and run, the recurrence that times each step, where it starts braking, what stop() really does, and the step rate an Uno tops out at. | 55 min |
|
Materials
- Arduino Uno R3
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver
Check for understanding
Each student finishes "AccelStepper: the ramp, done for you" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A gentler machine".
Two axes and a language
Bresenham keeps two motors on one line, and a parser turns G-code into moves.
| Lesson | Time | What students do |
|---|---|---|
| Multi-axis sync: BresenhamTwo motors, one straight line. Step both at one rate and see the dog leg, trace Bresenham by hand, draw the line within half a step, and turn a feed along the path into a step rate per axis, capped at the limit. | 55 min |
|
| G-code parsing: words, modes and checksumsThe plotter’s firmware reads G-code one line at a time. Split a line into words, set the position with G92, see modal motion and relative mode carry from line to line, and catch a corrupted line with a checksum. | 55 min |
|
Materials
- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver
Check for understanding
Each student finishes "G-code parsing: words, modes and checksums" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Say no clearly".
A real machine
Homing that brakes and backs off, soft and hard limits, and the boss: a G-code plotter.
| Lesson | Time | What students do |
|---|---|---|
| Limits and homingHome a two-axis machine the way Grbl does: seek fast, brake past the switch, back off, touch slowly, pull off. Then refuse a target off the bed, and stop dead when a switch trips mid-move. | 55 min |
|
| Boss: a two-axis plotterPut it all together on the G-code plotter: home it, drive the pen, draw a square line by line, read a ramp off every move, run a whole drawing, and make the machine faster by tuning its acceleration. | 55 min |
|
Materials
- Arduino Uno R3
- Hobby servo
- Limit switch, lever microswitch x 2
- Stepper driver, A4988
- Stepper motor, NEMA 17 x 2
- TMC2209 stepper driver
Check for understanding
Each student finishes "Boss: a two-axis plotter" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Tune it faster".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.