Welcome! Log In Create A New Profile

Advanced

M218 Z-Offset without DualCarriage or SwitchingExtruder

Posted by Leo Lautsprecher 
M218 Z-Offset without DualCarriage or SwitchingExtruder
August 29, 2017 03:09AM
Hello!
My multi-extruder printer can switch complete toolheads automaticly. They are clipped on with magnets and can be interchanged by moving to a certain position.
That way, the height of the hotends is not autimaticly equal, therefore I need offsets between the tools.
If I got it right, there are two functions that can do this in theory.
1. M206 sets global offsets, which I could change on every tool change with simplify3d. Thats the solution I had for the last 2 months, but now I want to be able to use M206 in post processing, so it doesn't work out anymore.
2. M218 sets individual toolhead offsets, but i can only get x and y working.

Now, that I already invested a full day into troubleshooting, I decided to ask here.
How do i get z-Offset in M218 to work without activating "Dual_x_Carriage" or "Switching_Extruder"?

This is the original code from the current release concerning M218 (found in marlin_main.cpp)
#if EXTRUDERS > 1
    case 218: // M218 - set hotend offset (in mm), T X Y
    {
      if(setTargetedHotend(218)){
        break;
      }
      if(code_seen('X'))
      {
        extruder_offset[X_AXIS][tmp_extruder] = code_value();
      }
      if(code_seen('Y'))
      {
        extruder_offset[Y_AXIS][tmp_extruder] = code_value();
      }
      #ifdef DUAL_X_CARRIAGE
      if(code_seen('Z'))
      {
        extruder_offset[Z_AXIS][tmp_extruder] = code_value();
      }
      #endif       
      SERIAL_ECHO_START;
      SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
      for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
      {
         SERIAL_ECHO(" ");
         SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
         SERIAL_ECHO(",");
         SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
      #ifdef DUAL_X_CARRIAGE
         SERIAL_ECHO(",");
         SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
      #endif
      }
      SERIAL_ECHOLN("");
    }break;
#endif

My first instinct was to delete two occurrences of " #ifdef DUAL_X_CARRIAGE" and the following "#endif".
But it doesn't change the behaviour.

I validate if it worked by sending "M218 X10 Y10 Z10" followed by "T0" or "T1". Only X and Y move that way (with the carriage beeing in a positinon where movement in every direction is possible).
I also searched for the offset variables and looked for differences between X, Y and Z, but I just can't figure out the solution.

Maybe someone of you has already encountered this or a similar problem.
Thanks in advance!
Leo
Re: M218 Z-Offset without DualCarriage or SwitchingExtruder
August 29, 2017 05:10AM
I finally got it to work. The trick was to activate the movement of the z-axis when toolchanging. The change in the post above has to be done as well (in order to accept the offset).
You have to make a change in the function "void tool_change(", which is located in marlin_main.cpp as well. Since this function is quite long, I can't post it in its entirety, but you are looking for the line:
current_position[Z_AXIS] -= hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
This is located in a "#if ENABLED(DUAL_X_CARRIAGE)" section by default. You can post the line right before this section. A z-offset now makes the z_axis move when sending T1/T0.

Best regards,
Leo
Sorry, only registered users may post in this forum.

Click here to login