feat(turret): per-slot calibration, backlash compensation, software homing, factory parameter set - #601
feat(turret): per-slot calibration, backlash compensation, software homing, factory parameter set#601veerwang wants to merge 4 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>
…t in CI All tests pass but the pytest process intermittently dies with exit code 139: pyqtgraph's atexit cleanup sweeps every gc-tracked object while the Qt C++ side is already tearing down (seen on master too, e.g. runs for 52c6f58 and f8fe36d). The sweep only matters for long-lived interactive sessions, so turn it off for the test process. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ne-search accel, max speed 150 Port SingleMotor f366df9..4119c32 (manager-specified values): - Homing: fine step 5->2 (repeatability +/-2), backoff 150->60, sweep 50->60 Step/s with 20ms poll (52ms window crossing >= 2.6 polls), fine travel limit 400->200 - Fine search now temporarily lowers acceleration (0x005F) to 50 to soften the microstep approach to the trigger edge; restored after - Max speed 200->150: the 0.95A current cap loses steps under load at 200 - Idle current 60->21 (displayed 0.69A); drop the decel-current (0x15) calibration and its volatile mechanism — the SDM42 drive has no such parameter (writes silently dropped, reads back 0) SingleMotor's reconnect-polling fix (8ab21dc) is Qt-panel-specific and does not apply to this synchronous controller. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Pushed fd6ee50, syncing the tuning work done on the SingleMotor bench project over 07-27/07-28 (all manager-specified values): Homing parameter revisions
New: temporarily lowered acceleration during fine search Max speed 200 → 150 Step/s Current parameters
Not ported: SingleMotor's reconnect-polling fix is specific to its Qt status panel; this controller polls synchronously per move and doesn't have that failure mode. These values are written on connect and persisted to EEPROM by the existing calibration path. Bench-verified on SingleMotor; re-verification on the turret hardware is still pending. |
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