Commit 7e74f0c
committed
fix(rs274ngc): MAX_UNWIND_TURNS rebase aligns angular position via shortest path
The original rebase pinned the motor at AA_current when triggered, which
gave correct results only when AA_current happened to coincide with the
target's mod-360 angular position (e.g. an exactly N-turn accumulation).
For any off-mod-360 starting state, the motor would not move and the
physical angular position would no longer match the user-frame target.
Updated rebase computes the shortest-path delta into (-180, 180] and
moves the motor by that sub-turn delta while absorbing the full-turn
remainder in the offset. After rebase, machine angular position == target
mod 360 and user_pos == target.
Trace from AA=28850 (80 turns + 50 deg) with G0 A0:
delta = -28850, |80.14 turns| > 10, rebase fires
delta_short = -50 (shortest path to align mod 360)
target_machine = 28800, motor delta = -50
new_offset = 28800, user_pos = 0
Physical angular position = 0 deg, matches programmed A0.1 parent 7fd961b commit 7e74f0c
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5345 | 5345 | | |
5346 | 5346 | | |
5347 | 5347 | | |
5348 | | - | |
5349 | | - | |
| 5348 | + | |
| 5349 | + | |
| 5350 | + | |
| 5351 | + | |
| 5352 | + | |
5350 | 5353 | | |
5351 | 5354 | | |
5352 | 5355 | | |
| |||
5358 | 5361 | | |
5359 | 5362 | | |
5360 | 5363 | | |
5361 | | - | |
| 5364 | + | |
| 5365 | + | |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
5362 | 5369 | | |
5363 | 5370 | | |
5364 | 5371 | | |
| |||
0 commit comments