gcode Loop/Repeat script for testing.

User-Generated tips and tricks for the Rostock Max, Orion, H1.1, or H1 Printers
Post Reply
User avatar
KAS
ULTIMATE 3D JEDI
Posts: 1157
Joined: Thu Dec 04, 2014 6:06 pm

gcode Loop/Repeat script for testing.

Post by KAS »

Anyone know of a way to repeat or loop a set of gcode instructions?
It appears M41 command is the Loop function, although not implemented in smoothie or just about any 3D print controller.

http://reprap.org/wiki/G-code/es#M41:_Loop
bot
Printmaster!
Posts: 988
Joined: Thu Sep 25, 2014 12:18 am
Location: Vancouver
Contact:

Re: gcode Loop/Repeat script for testing.

Post by bot »

Copy and paste in a text editor is what I do. On a duet you could make two macros that are the same and then call each other at the end, creating an endless loop that you'd have to interrupt to stop.
*not actually a robot
Xenocrates
ULTIMATE 3D JEDI
Posts: 1561
Joined: Wed Sep 23, 2015 2:55 pm

Re: gcode Loop/Repeat script for testing.

Post by Xenocrates »

Unfortunately, from the looks of it, Repetier and Marlin do not support it. And Rep-Rap, which is the only one which does, not not support recursive or looping macros. So, well, bugger. I had a hope spot that you could use M98, but unfortunately that bit of niceness from industrial G did not make the transition. It would likely be easier to just set a large number of repetitions in the G code, with nice dwells and homes between it so that you have time to make adjustments, and it can take those into account. M41 is also apparently a dead letter when it comes to that.

I also found out that a number of the features I've come to love in industrial G did not make it to printers. G13 for example. I also dislike that they changed a few other things, and think their way of explaining the parameters is kinda terrible. I'm sorry I can't be more helpful to you.


That being said, there is very much a way to loop G code on industrial controllers. M97 on haas controllers pulls a line number (N####), named in the P####, and runs that, so long as at some point there is a M99 after the called line. You can potentially set it to loop like this. You can also use M98 to call a sub-program, which can be used to have a stub program which only serves to call the main portion of it, which then calls the stub again. of course, with the sanity checking most do, you'd have to terminate both with M99, and some controllers would either eventually run out of memory, or refuse to run this abortion at all. Seeing as how this has no abort method (G has no major logical constructs such as while or for loops in common implementations) I would argue refusing to run it, unless a setting is toggled is probably the best method to deal with it.
Machines:
Rostock Max V2, Duet .8.5, PT100 enabled E3D V6 and volcano, Raymond style enclosure
Automation Technology 60W laser cutter/engraver
1m X-carve router

Sic Transit Gloria Mundi
01-10011-11111100001
Post Reply

Return to “General Tips 'N Tricks”