Macro subroutines in LinuxCNC

More
11 Jun 2016 19:40 #75833 by jwsigler
I looked into ngcgui but it does not seem to do exactly what I want. I want to be able to define a single multipurpose macro which I can easily call from within any Gcode program I would write. Just like I call a G1 command within my Gcode program, I wanted to be able to define a macro where I have the option to define what arguments are needed. If I only need to define X to make my macro work, I want that option. If I need to define more arguments, then I list each argument's name and its value. I find it disappointing that we all use G0, G1, G2, and G3 which allows us to defined only the arguments that need to be defined, but linuxcnc does not allow the same capability when we want to define custom macros with the exact same capability.

I can guarantee you that incorporating such a command into Linuxcnc would be fairly simply for a competent programmer. Most of the code already exists in LinuxCNC's capability to execute a command such as "o<subname> Call". The only thing missing would be to add the capability to analyze any following argument list looking for specific argument names of X,y,z,w,a,b,c,,etc and then assigning the following numerical values to the associated local variable. If you read the article that I previously referenced, you will see how other Gcodes implement this feature. You will also see that some letters of the alphabet, such as o, n, can not be used as argument names because they would conflict with other possible commands. While the macro I envision would have numerous arguments that if defined would allow the macro to machine a wide variety of circular features, this capability would enable lots of users to define multipurpose marcos to share with everyone. By using a macro, which would be compatible with other controllers, people's Gcode could be ported to other machining centers that are not running LinuxCNC. Using something like ngcgui locks one's gcode for use only on a linuxcnc machine.

Please Log in or Create an account to join the conversation.

More
11 Jun 2016 21:52 #75837 by Todd Zuercher
Maybe you can do what you want with g-code remapping. Could probably even write the type of macro handling you want to use, or just the one canned cycle you want to use.
linuxcnc.org/docs/html/remap/remap.html#_the_argspec_parameter
Very powerful stuff, but well beyond my skill level.

Please Log in or Create an account to join the conversation.

Time to create page: 0.140 seconds
Powered by Kunena Forum