Reply To: Zero all axis automatically

New Home Forum Mostly Printed CNC – MPCNC Troubleshooting – MPCNC Zero all axis automatically Reply To: Zero all axis automatically

#12765

Jason
Participant

I added it to my LCD menu a week ago 🙂

You just need to edit the ultralcd.cpp file of the sketch. I’m on Marlin RC6 so the menu code is slightly different but here’s what I modified:

/**
 *
 * "Main" menu
 *
 */

static void lcd_main_menu() {
  START_MENU();
  MENU_ITEM(back, MSG_WATCH);
  if (movesplanned() || IS_SD_PRINTING) {
    MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
  }
  else {
    MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
    #if ENABLED(DELTA_CALIBRATION_MENU)
      MENU_ITEM(submenu, MSG_DELTA_CALIBRATE, lcd_delta_calibrate_menu);
    #endif
  }
  MENU_ITEM(gcode, MSG_SETHOME, PSTR("G92 X0 Y0 Z0"));
  MENU_ITEM(gcode, "Needle Off", PSTR("M280 P0 S0"));
  MENU_ITEM(gcode, "Needle Low", PSTR("M280 P0 S90"));
  MENU_ITEM(gcode, "Needle Med", PSTR("M280 P0 S135"));
  MENU_ITEM(gcode, "Needle Full", PSTR("M280 P0 S180"));

  MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);

  #if ENABLED(SDSUPPORT)
    if (card.cardOK) {
      if (card.isFileOpen()) {
        if (card.sdprinting)
          MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
        else
          MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
        MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
      }
      else {
        MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
        #if !PIN_EXISTS(SD_DETECT)
          MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));  // SD-card changed by user
        #endif
      }
    }
    else {
      MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
      #if !PIN_EXISTS(SD_DETECT)
        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
      #endif
    }
  #endif //SDSUPPORT

  END_MENU();
}

The following lines are what I added:

 
MENU_ITEM(gcode, MSG_SETHOME, PSTR("G92 X0 Y0 Z0"));
MENU_ITEM(gcode, "Needle Off", PSTR("M280 P0 S0"));
MENU_ITEM(gcode, "Needle Low", PSTR("M280 P0 S90"));
MENU_ITEM(gcode, "Needle Med", PSTR("M280 P0 S135"));
MENU_ITEM(gcode, "Needle Full", PSTR("M280 P0 S180"));

The first line adds the new “set zero” command, the next 4 lines send servo commands to control the speed of the needle cutter I’m working on. This all shows up in my LCD on the main menu.

Oh yeah…you also have to edit language_en.h and add this at the end:
#define MSG_SETHOME "Set XYZ to 000"

I’ve actually since updated my code to use configurable strings for all of those commands…
I also ended up moving this all into a sub-menu and am working on adding other commands like “Raise Z by 15” and “Lower Z to 0” that are helpful. You can see my work in progress on my github, here’s the changes I’ve made to the menu’s so far: https://github.com/jhitesma/Marlin-Folger/commit/6988f456ec8eaf8ae629d0c41d873119e491e353