Reading @Dgkeith237 comments and your response with script triggered some ideas/information. I’ve used various scripts triggered in various places over my time with my MPCNCs, and I’ve spotted some g-code features that might be helpful. Consider this post my musings on saving positions and the use of g-code scripts/macros.
I’m actually interested if anyone has suggestions on how to simplify that process.
It is my understanding that, in firmwares specifically created for a CNC, the saving and restoring of positions is handled by workspaces. Marlin does have workspaces (see: G54-G59.3 - Workspace Coordinate System). What it doesn’t have is an interface on the host computer software to make using workspaces easy. It means you have to define your own process and scripts to use workspaces. I outlined in this post how I used workspaces to implement bitsetter functionality, but a much simpler setup could be used to just save and restore a position.
One cool thing about workspaces is that they are saved with a M500. This means the offsets that you are currently writing on a piece of paper could be “automatically” recorded for all your jobs just in case you need to return to the job origin (even if the electronics are cycled). If anyone thinks they want to go down this path, I can provide some ideas of the process and the g-code to make it happen.
You might also look at G60 and G61. These two g-code save and restore positions. This is a simpler mechanism than Workspaces, but this feature is not enabled in the V1 versions of Marlin. To enabled it, this area of configuration_adv.h needs to be edited:
// // G60/G61 Position Save and Return // //#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes
I think that G60 positions are saved to the EEPROM with an M500, but it is not something I’ve tested.
G-code scripts can be added to the V1 custom menu. This menu is available with an LCD display or in Marlin mode on the TFT. I’ve put a number of my scripts on this menu to make them easier to execute. Search for “#define CUSTOM_MENU_MAIN” to find the area to edit to add custom menu items.
A number of people on this list have implemented a pendent to provide physical “switches” to implement macros (and movement)…myself included. It is an easy Arduino project to read a 4x4 membrane switch array and execute a g-code script for each of the 16 buttons. And I think more than one membrane switch could be used (32 scripts at the push of a button anyone?). If anyone wants to go down this path, I’ll be glad to help.
I recently bumped into the M810-M819 g-codes. G-code macros can be attached to each of these g-codes. Using them would centralize the g-code scripts to a single file, and it would allow these scripts to be executed from a g-code sender, not just by running them from the SD card. They could also be run from the console on the TFT. Unfortunately, M810-M819 are not saved with an M500, but Marlin’s [Autostart functionality](Autostart | Marlin Firmware Autostart | Marlin Firmware) would allow you to repopulate these macros each time the control board is rebooted. Also unfortunately, the V1 versions of Marlin do not have this macros feature enabled. It is this section in configuration_adv.h that needs to be modified to enable g-code macros.
/** * G-code Macros * * Add G-codes M810-M819 to define and run G-code macros. * Macros are not saved to EEPROM. */ //#define GCODE_MACROS #if ENABLED(GCODE_MACROS) #define GCODE_MACROS_SLOTS 5 // Up to 10 may be used #define GCODE_MACROS_SLOT_SIZE 50 // Maximum length of a single macro #endif