feat(turret): per-slot calibration, backlash compensation, software homing, factory parameter set - #601
Open
veerwang wants to merge 2 commits into
Open
feat(turret): per-slot calibration, backlash compensation, software homing, factory parameter set#601veerwang wants to merge 2 commits into
veerwang wants to merge 2 commits into
Conversation
Port two positioning features from the SingleMotor source project: - OBJECTIVE_TURRET_CALIBRATED_PULSES: per-slot calibrated absolute pulse targets (slot 1..4 -> pulses from homing zero). A calibrated slot is used verbatim; uncalibrated slots fall back to the theoretical (slot-1)*pulses_per_position + OBJECTIVE_TURRET_OFFSET_PULSES. - OBJECTIVE_TURRET_BACKLASH_DEG: gear backlash compensation (0..1 turret degrees). When > 0 every slot change overshoots below the target and approaches it from below, so the final approach direction is always the same and gear backlash cancels out. Both are validated at init (slot range, integer pulses, deviation bound of one slot vs theoretical, degree range) so a bad machine .ini fails fast. Defaults keep behavior identical to before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… switch, factory params Re-merge from the SingleMotor source project (2026-07-23..27 changes): - Homing rewritten as software homing (sweep in velocity mode polling the DI level -> backoff -> fine-search -> SET_ZERO at the trigger edge), replacing the driver's built-in homing modes. Repeatability +/-5 pulses; ends clamped at home with holding torque. Default home timeout raised to 120s. - DI1 is now permanently "origin switch" (3). The old scheme (DI1 temporarily mapped to negative limit + homing method 17) faults FF0E on the current firmware whenever a move passes the sensor; all homing-register calibration is removed. - Factory parameter set ported and auto-calibrated on connect: accel/decel 1000, max speed 200, min speed 16 (written before max — fixes the min/max write-order bug), currents overload 1.3A / idle 0.6A / accel+run+decel 0.95A, microstep forced to 16 (write + save + fail fast asking for a power cycle when it differs). Decel current is marked volatile (firmware drops the write) so it cannot trigger an EEPROM save every connect. Direction register written to RAM after the EEPROM save. - modbus_rtu: add read_input_registers() batch read so the homing sweep gets DI + position + alarm in one frame per poll (the ~50-pulse sensor window must not be crossable between two polls). - _def.py: fix the calibrated-pulses doc example (6640 deviates more than one slot and fails validation) and note that slots must be re-measured after upgrading from driver homing (the zero reference moved). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two commits improving the NiMotion 4-position objective turret controller:
1. Per-slot calibration and gear backlash compensation (
6918f4f)OBJECTIVE_TURRET_CALIBRATED_PULSES: per-slot calibrated absolute pulse targets (slot -> pulses from homing zero). Calibrated slots are used verbatim; others fall back to the theoretical(slot-1)*pulses_per_position + OBJECTIVE_TURRET_OFFSET_PULSES.OBJECTIVE_TURRET_BACKLASH_DEG: when > 0, every slot change overshoots below the target and approaches from below, so the final approach direction is constant and gear backlash cancels out.2. Software homing, DI1 origin switch, factory parameters (
fffd0a5)SET_ZEROthere. Repeatability ±5 pulses (hardware-measured 0); ends clamped at home with holding torque. Home timeout raised to 120 s.modbus_rtu: newread_input_registers()batch read so the homing sweep sees DI + position + alarm in one frame per poll (the ~50-pulse sensor window must not be crossable between polls).Deployment notes
Test plan
tests/control/test_objective_turret_controller.py,tests/control/test_modbus_rtu.py): calibration/backlash targeting, software-homing edge/sweep/timeout paths, factory-param write order, microstep-mismatch fail-fast🤖 Generated with Claude Code