Machsupport Forum
G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: John Lovaasen on May 16, 2012, 10:47:58 AM
-
Hi,
I have rectangular raster pattern that I would like to program a subroutine for, but have a couple questions regarding the best way to go about it. The first question is, will Mach3 understand conditional loops (WHILE, FOR, IF, etc.)? I read on CNC Cookbook that Mach3 doesn't support macros, and I got an error when I tried programming a WHILE loop.
Anyways, what I want to do is setup variables for the X length, Y length, Z gap between tool and substrate, feed rate, and spacing between raster scans. For example, a 86mm by 36mm (X length, #1=86 and Y length, #2=36) substrate, a 2mm gap between tool and substrate (Z gap, #3=-12, in my case), a feed rate of 2500mm/min (#4=2500), and a 1mm spacing between scans (#5=1).
I have attached the g code that goes through the raster pattern I would like for reference. If Mach3 does not support conditional loops, how would I go about doing? Any help is greatly appreciated!
-
Hi John
You're quite right Mach doesn't support selection but does support iteration. It does support macros but in a different context i.e. you can create your own M codes with CB (cypress basic). That said you don't need either for your task because Mach does support gcode subroutines.
a short example and I'll leave you to do the rest - hint - subs can be nested.
N10 #1000 = 10 (user gcode vars start at 1000)
N20 M98 P123 L#1000 (do sub called 123 L times)
N30 M30 (end of main)
o123 (start of sub - note that's an o not a zero and no line numbers allowed on sub labels)
N40 (do whatever)
N50 M99 (return from subroutine)
Ian
-
That's what I figured, but just wanted to clarify. I am more familiar with C programming but have enjoyed learning g code programming. Thanks for the help.