code wiki / _hdl_build / nx_motion_plan.nx

nx_motion_plan.nx

buildroot/runtime/_hdl_build/nx_motion_plan.nx

2837 B62 linesdepth 2pulls 4 transitivereach 3 importersview sourcekind librarytopic motion
docsdependenciesstructsconstsfunctions

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 2 imports · 2 importers

nx_syscalls.nx nx_vecmath.nx nx_motion_plan.nx nx_litho_stepper.nx nx_printer_ctl_test.nx

imports: nx_syscalls.nxnx_vecmath.nx

imported by: nx_litho_stepper.nxnx_printer_ctl_test.nx

structs

none

consts

14const MP_TRAPEZOID: i64 = 0
15const MP_TRIANGLE: i64 = 1
16const MP_BAD_INPUT: i64 = 2 // defensive boundary: zero/negative dist, vmax, or accel

functions

19func mp_isqrt(x: i64) -> i64 { return vm_isqrt(x) }
called by 1: mp_plan calls 1: vm_isqrt
23func mp_plan(dist_um: i64, vmax: i64, acc: i64, out: *i64) -> i64
called by 1: main calls 1: mp_isqrt
52func mp_steps(dist_um: i64, steps_per_mm: i64) -> i64
called by 1: main
58func mp_cruise_interval_us(v_um_s: i64, steps_per_mm: i64) -> i64
called by 1: main