code wiki / _hdl_build / nx_motion_plan.nx
nx_motion_plan.nx
buildroot/runtime/_hdl_build/nx_motion_plan.nx
about
nx_motion_plan.nx -- SOVEREIGN PRINTER ARC rung 1a: trapezoidal motion planning (operator is
building our OWN printer; the QIDI is inferior). Every motion controller (Klipper/Marlin/GRBL
class) reduces a G-code move to an accel/cruise/decel velocity profile and then step pulses.
This is that math, integer-exact: distances um, velocities um/s, accel um/s^2, times ms.
d_acc = v^2 / (2a). If 2*d_acc <= dist -> TRAPEZOID (accel, cruise, decel).
Else -> TRIANGLE: v_peak = isqrt(a * dist) (from v^2 = 2a*(dist/2)).
Steps: steps = dist_um * steps_per_mm / 1000 (integer; fractional step carry = next rung).
HONEST SCOPE: single-move planning. Junction velocity (lookahead between moves), jerk limits,
and the step-pulse interval table for the MCU ISR are the flagged next rungs.
LAWS: struct-free, integer-only. license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_litho_stepper.nxnx_printer_ctl_test.nx
structs
| none |
consts
| 13 | const MP_TRAPEZOID: i64 = 0 |
| 14 | const MP_TRIANGLE: i64 = 1 |
| 15 | const MP_BAD_INPUT: i64 = 2 // defensive boundary: zero/negative dist, vmax, or accel |
functions
| 18 | func mp_isqrt(x: i64) -> i64 called by 1: mp_plan |
| 34 | func mp_plan(dist_um: i64, vmax: i64, acc: i64, out: *i64) -> i64 |
| 63 | func mp_steps(dist_um: i64, steps_per_mm: i64) -> i64 called by 1: main |
| 69 | func mp_cruise_interval_us(v_um_s: i64, steps_per_mm: i64) -> i64 called by 1: main |