Using trigger timestamp to compensate for overshoot

Hi, let me know if this has already been discussed.

The documentation says that multi MCU homing is prone to overshoot. As far as I can tell this is indeed the case. The overshoot is reasonably consistent however.

Has anyone tried using the trigger tiimestamp to calculate expected steps for each motor and command the motors to backtrack as necessary?

The steps would be:

  • obtain trigger clock for trigger MCU from the trsync_state message
  • for each stepper
    • translate trigger clock to corresponding stepper MCU clock
    • scan generated step times history and determine the expected position for the trigger clock
    • request current stepper position
    • calculate offset from current and desired
    • issue a move command to return to the desired position

This would still rely on the MCU clocks being reasonably in sync, but eliminate the obvious transport latency.

Never mind, of course it’s a thing: homing: Calculate homing position based on trigger time · Klipper3d/klipper@3814a13 · GitHub

Probably worth updating the documentation.

I think I fixed that issue here… Pending Kevin getting around to looking at it.
By “I think” I mean it works perfect for me, but Kevin would need to make sure there are no unintended consequences.

The trigger position and halt position is kept already in the homing code per mcu.
In other words lets say you have 4 mcus controlling 4 steppers (in my case the Z steppers).

You run home Z and it triggers at time X
The code already has a portion that says essentially…
Z1 MCU was at Y position at time X
Z2 MCU was at Y position at time X
etc… etc…

The halt position is where the probing stopped. (I may be getting these backwards, I did this months ago.)

In my pull request above what I did was say “Take the difference of those positions from the ‘trigger position’ and ‘halt position’ and make the minute Z adjustments to get them back into sync”

 if probe_pos:
            halt_steps = {sp.stepper_name: sp.halt_pos - sp.start_pos
                          for sp in self.stepper_positions}
            trig_steps = {sp.stepper_name: sp.trig_pos - sp.start_pos
                          for sp in self.stepper_positions}
            difference = {stepper: trig_steps[stepper] - halt_steps[stepper]
                for stepper in halt_steps}
            #Adjust the steppers back to the trigger position
            for step_diff in difference:
                adjustments = (steppers[step_diff].get_step_dist()
                           * difference[step_diff])
                self.stepper_adjust_move(steppers[step_diff], adjustments)
            haltpos = trigpos = self.calc_toolhead_pos(kin_spos, trig_steps)