Welcome! Log In Create A New Profile

Advanced

Is M915 / TMC_Z_CALIBRATION with TMC 2130 useful?

Posted by tbeaulieu 
Is M915 / TMC_Z_CALIBRATION with TMC 2130 useful?
March 19, 2018 01:04PM
I'm running with 2130s on my 2560/Marlin/RAMPs 1.4 home made rig and using sensorless homing for X & Y. I stumbled across this GCODE today and the code for it is listed below. What the heck is this actually accomplishing?

I was super excited at first, thinking it would solve all my manual paper calibrations by automatically probing and detecting the extruder tip touching the bed.

By subtracting the missed steps it could automatically determine the distance between the IR Z sensor and where the tip actually is. I can't see what value this is actually providing, though.

Any thoughts?

    inline void gcode_M915() {
      uint16_t _rms = parser.seenval('S') ? parser.value_int() : CALIBRATION_CURRENT;
      uint16_t _z = parser.seenval('Z') ? parser.value_int() : CALIBRATION_EXTRA_HEIGHT;

      if (!axis_known_position[Z_AXIS]) {
        SERIAL_ECHOLNPGM("\nPlease home Z axis first");
        return;
      }

      uint16_t Z_current_1 = stepperZ.getCurrent();
      uint16_t Z2_current_1 = stepperZ.getCurrent();

      stepperZ.setCurrent(_rms, R_SENSE, HOLD_MULTIPLIER);
      stepperZ2.setCurrent(_rms, R_SENSE, HOLD_MULTIPLIER);
      SERIAL_ECHOPAIR("\nCalibration current: Z", _rms);

      soft_endstops_enabled = false;

      do_blocking_move_to_z(Z_MAX_POS+_z);

      stepperZ.setCurrent(Z_current_1, R_SENSE, HOLD_MULTIPLIER);
      stepperZ2.setCurrent(Z2_current_1, R_SENSE, HOLD_MULTIPLIER);

      do_blocking_move_to_z(Z_MAX_POS);
      soft_endstops_enabled = true;

      SERIAL_ECHOLNPGM("\nHoming Z because we lost steps");
      home_z_safely();
    }
Re: Is M915 / TMC_Z_CALIBRATION with TMC 2130 useful?
March 20, 2018 10:11AM
That is not GCode. That is C code.

That code block sets the current available to both of the Z stepper motors to a lower value. And then it moves the Z Axis up past the end of the axis by _z. It then sets the current back to where it started.
And lastly, it moves the Z Axis back to the max position.

It does not check for a stepper motor losing steps. That would need to be added. And then some more logic to get both sides of the Z Axis back in sync.
Sorry, only registered users may post in this forum.

Click here to login