Duet3D / RepRapFirmware

OO C++ RepRap Firmware
GNU General Public License v3.0
942 stars 534 forks source link

[Discussion] Parameter support for G-Code Macros #150

Closed FHeilmann closed 5 years ago

FHeilmann commented 6 years ago

Hi everyone,

I've been using my Duet Wifi for some time, and really enjoyed making use of the M98 macro call function. During my usage I found myself wanting a basic parameter facility for macros, so you can remove some redundancy in e.g. heating macros.

Here is what I came up with:

Allow M98 to have other parameters (lets go with A B C D E F for now as they don't shadow G or M)

e.g. M98 P"/macros/heatup_macro.gcode" A220 B60

Inside this macro called by M98, allow G-Codes to reference these parameters using special syntax, i.e.

G10 P0 R0 S{A}
M116
M190 S{B}

Especially paired with stuff like Slic3rs conditional g-code execution, this would open up a lot of possibilities for generic macros.

I have a basic mockup of the whole thing in an offline repo. In its current state it bootloops the CPU unfortunately, so I thought I'd rather start the discussion before putting more time into it. IF this gains some traction I'll of course share it.

Things this will give us

Things that need to be discussed/standardized

Thanks for your time, I am looking forward to your discussion.

dc42 commented 6 years ago

There are already some other schemes for implementing variables and parameters in GCode, so we should probably adopt one of them instead of inventing our own scheme. Here are some examples:

http://linuxcnc.org/docs/html/gcode/overview.html#_parameters https://www.cnccookbook.com/fanuc-macro-system-variables-cnc-g-code-parameterized-programming/

Stroppel commented 5 years ago

To be honest it doesnt matter to me what type of variables we use but i really like to see this. I just wanted to create a filament change makro and set the extrusion factor for this filament. But the gcode for the extrution factor is global or i have to set the extrude explicitly. Till now the makro is filament specific but not extruder specific. If I now want to have the extrution factor be set in the macro i have to generate makros for all combination of filament in extruder. As I am just trying to build a filament changer functionality for my printer this will explode the amount of macros I need.... And all that just because i have no information inside the macro, in what extruder the filament was loaded...

Greetings

Schleichmichl commented 5 years ago

+1! I have a kraken and need this parameters, too. This opens a new world of possibilities.

FHeilmann commented 5 years ago

closing due to inactivity.

dc42 commented 5 years ago

I plan to implement macro parameters as part of the work on variables and conditional GCode that is scheduled for RRF 2.04.