Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loop and condition by g-code command

Tags:

loops

g-code

How I can make and stop loop at selected condition using G-code?
For example, I have the following G-code commands:

G10  L2 P1 X-10. Y-10.  Z-10
G10  L2 P2 X-10. Y-11.  Z-10
G10  L2 P3 X-10. Y-12.  Z-10

I would like to create loop, which repeats my code 5 times. I can not use m-code . I need build loop by G92

like image 630
mark Avatar asked Jun 10 '26 13:06

mark


1 Answers

If you are using LinuxCNC, then the code below would be the code used to loop or iterate some lines of gcode.

FYI, LinuxCNC and gcode can be more difficult to own than most of the other common programming languages … python, R, etc...

And LinuxCNC does not accept just any old gcode. The AXIS in my LinuxCNC rejected the code in the other answer that is shown below. LinuxCNC wants the formatting to be exact - including brackets, starting / ending file characters, etc....

This code works in the AXIS GUI in LinuxCNC.

%
/ Tool is set at starting position.  Enter the conditional loop

#100 = 1

o101 while [#100 le 5] 

G1 X -0.02 F10
G54 Z -.25 F10
G0 X0.0
G54 Z0.0

#100 = [#100 + 1]

o101 endwhile

M2
%
like image 178
Gray Avatar answered Jun 12 '26 12:06

Gray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!