Skip to content

Momentary Switch Homing and Dome Rotation Calibration - #48

Open
CTetford wants to merge 1 commit into
hjd1964:masterfrom
CTetford:Momentary-Home-Switch
Open

Momentary Switch Homing and Dome Rotation Calibration#48
CTetford wants to merge 1 commit into
hjd1964:masterfrom
CTetford:Momentary-Home-Switch

Conversation

@CTetford

Copy link
Copy Markdown

Adds homing support for momentary (magnetic/limit) home switches, which are only ON for a short time. The stock fast/slow/fine refinement has no region to converge on with these. All opt-in; default behaviour is unchanged.

Momentary homing

  • (HOME_SEQUENCE_MOMENTARY): seek past the switch until it releases, approach from the far side, record the coordinate at the sensor trip, then goto back to it.
  • Moves are separated by a settle delay (HOME_SETTLE_TIME), edges are debounced by travel distance (HOME_SENSE_DEBOUNCE), and seek direction is selectable (HOME_SEEK_REVERSE).
  • The dome now sets home from the recorded trip point, and only when the sensor was actually reached - a timeout or motor fault won't write its stopping point to NV as home.

:DM# rotation calibration

  • Rotates continuously, records each home switch pass, and reports averaged steps/revolution for calibrating AXIS1_STEPS_PER_DEGREE. Requires AXIS1_WRAP ON; writes nothing to NV; :DH# stops it.

Servo safety - oscillation detection update

  • Old: shut down if drive output went below -33% and above +33% within the same 2-second window. This approach caused nuisance trips on normal behaviour: a commanded direction reversal, or the settling transient after a stop.
  • New: Hägglund's method (https://doi.org/10.1016/0967-0661(95)00164-P) applied to the following error: integrate |error| between zero crossings, count a half cycle as significant only if its mean magnitude and duration are both in range, and act only on consecutive significant half cycles. A one-off transient scores once and resets. Warns at half the shutdown count and reports the measured period and amplitude. Tunable via SERVO_SAFETY_OSCILLATION_*.

Servo safety - runaway detection update

  • Old: shut down if the distance travelled in a 2-second window exceeded the previous window's target distance while at ≥90% power. Comparing distances means a following error that just grows (heavy load, speed change) can look like a runaway, and a real runaway can hide.
  • New: shut down only if the encoder moved in the opposite direction to the target at ≥90% power, on two consecutive checks. Direction is unambiguous where distance is not, and the two-check requirement keeps a window containing a commanded reversal from qualifying. Still catches a reversed encoder.

Fix - backlash takeup deadlock

  • When a slew reversed direction with backlash compensation set, the axis stopped dead partway through the move and never recovered. No error, no timeout.
  • Cause: while the motor is taking up backlash, Axis::poll() commanded a frequency of zero. The motor backends read travel direction from the sign of the commanded frequency, and zero has no sign - so the motor stepped nowhere, the takeup counter never advanced, and inBacklash never cleared. The fix keeps the normal frequency ramp running during takeup; the backends already clamp it to the backlash rate, so takeup completes and the slew continues. Dome homing also zeroes backlash for the run (as park/unpark already do) and restores it on every exit path.

New options (HOME_SEQUENCE_MOMENTARY, HOME_SEEK_REVERSE, HOME_SENSE_DEBOUNCE, HOME_SETTLE_TIME, DOME_CALIBRATE_REVOLUTIONS, SERVO_SAFETY_OSCILLATION_*) all default to current behaviour and are checked in Validate.h.

Tested on a modified Technical Innovations HD6 dome, Teensy 4.1 / OCS4: SERVO_EE DC drive, AB encoder, magnetic home switch.

- HOME_SEQUENCE_MOMENTARY: homing for lever/roller switches. Seeks past the switch until it releases, approaches from the far side, records the coordinate where the sensor trips, and gotos back to it. The dome sets home from that recorded edge, and only if the sensor was reached.
- :DM# measures steps per revolution via repeated home switch passes, for calibrating AXIS1_STEPS_PER_DEGREE.
- Servo oscillation detection replaced with Hägglund's integral absolute error (IAE) method; the old check tripped on a single polarity change (normal reversals and settling transients).
- Servo runaway detection is now direction-based: encoder moving opposite the target at >=90% power on two consecutive checks. The old distance-based check could mistake a growing following error for a runaway.
- Fix: Axis::poll() zeroed the frequency during backlash takeup, giving the backends a zero step size - takeup never completed and the axis stopped dead mid-slew. Dome homing also runs with backlash off.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant