Solved Saving and Using Machine Coordinates in a Macro
-
I am trying to put together a tool calibration macro where the user can see a live feed looking up at the tool while they baby step the tool until it is lined up with a specific point on the screen. The calibration itself works, the issue I’m having is I want my macro to automatically update the G10 tool offset in my config.g file.
Right now, the coordinates are displayed, and the user is instructed on where to manually update the config file, which opens room for human error with typing in offsets. I was wondering if anyone knows a way to save current machine X and Y coordinates as separate variables for future use. I’ve experimented with using object model variables, but I haven’t had any luck. If anyone knows how to work with those or has another idea for getting machine coordinates from the macro to the config file, I’d love to hear it. Thank you! -
@kiyer5 you can read the current coordinates from the object model.
-
@dc42 I'm pretty new to G-Code I didn't realize you could do that, thank you. Would I be able to save those coordinates as a variable that I could export from my macro to the G10 call in my config file?
-
@kiyer5 The current (x) position in OM is: move.axes[0].userPosition
But i don't know how to save it in your config.g... -
@cosmowave That's still a big help thank you. I'm assuming that Y and Z coordinates are move.axes[1] and move.axes[2] respectively then? I was hoping to save these coordinates as variables in my macro and then assign them to blank object slots. And then in my config I think there is a way to have parameters in the G10 line that would access the object that I set the coordinates to in the macro. Still not sure if that is possible though.
-
@kiyer5 said in Saving and Using Machine Coordinates in a Macro:
@dc42 I'm pretty new to G-Code I didn't realize you could do that, thank you. Would I be able to save those coordinates as a variable that I could export from my macro to the G10 call in my config file?
The object model and the use of variables in GCode is specific to RepRapFirmware. See https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands.
You could use values from the object model to update the current G10 coordinates, then use M500 P10 to save various parameters including the G10 tool offsets to config-override.g.
-
@kiyer5 yes. the y and z axes are [1] and [2] respectively.
-
@dc42 Ok that makes sense. And then have an M501 in my config file. More curious than anything at this point, is there a command to update or reassign object model instances? Like can I store a value to a specific object?
-
@kiyer5 No, you can only read from the object model.
Eventually in the future it will be possible. -
Hey guys just a quick update I followed your suggestions and my macro is working as intended. Thank you for your input, it's much appreciated!