How to repeat a g-code sequence from terminal?

What is the problem?

I'm trying to run repetitive tests on my axis movement. For example, I want to repeat the following sequence 100 times. The purpose for this is to see how my belts/axis movement behaves without trying to print.

G0 F1500 Y0
G0 Y250

What did you already try to solve it?

Tried to put in separate commands in Terminal, but can't string them together. I think it would be very stupid to have to manually create a g-code file with those lines repeated - that's now how programming works!

Thanks

You can use a while loop or a if/goto como or just a goto and manually kill it.
https://www.cnccookbook.com/cnc-g-code-macro-conditions-looping/

If your firmware doesn't support the macros like a CNC would, it is possible with the 'Gcode Macros' plugin. You could use a script like this:

{% for i in range(100) %}
G0 F1500 Y0
G0 Y250
{% endfor %}

The syntax documentation is linked from the plugin, it is Jinja2 the same as OctoPrint's gcode scripts.

This is exactly what I was looking for! Many thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.