Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: MechanoMan on April 28, 2009, 05:13:01 AM
-
Is there a way to implement an "if" conditional in G-code?
I found there are conditionals for other engines' versions of G-code, but I didn't see one in the manual. At one point it does say that "conditional branching is not permitted".
At best I kinda thought of:
"if integer #5>0 then O100"
#10=[FIX[#5+0.1]/#5] (gives 1 for any positive nonzero integer)
M98 P100 L#10
Which should work, but it does kinda end up high in the running for Most Obfuscated Solution.
-
Sorry , there is NO conditional branching in MACH Gcode (;-(
(;-) TP
-
You can do conditional IF/THEN/ELSE and WHILE in a macro.
-
You can do conditional IF/THEN/ELSE and WHILE in a macro.
Could you give an example of this?
I saw this on some random examples on the Net, but it's not in the core G-code specification. I tried to create it but couldn't get Mach3 to parse it. I assumed Mach3 did not implement IF/THEN/ELSE and WHILE.
I may have failed to grasp the "macro" aspect. Is it a preprocessor thing? And thus unable to control the flow at runtime?
-
Ok, just off the top of my head here is a simple one. Set a variable and run a piece of code that many times.
#500 = 5
O20
routine 1 here
#500 = #500-1
M500
M98 P#502
O30
G code routine 2
M500.m1s file goes in macros/your profile and contains
Sub main ()
a = GetVar (500)
If a > 0 Then GoTo set20
SetVar(502,30)
GoTo set30
set20:
SetVar(502,20)
set30:
End
End Sub
-
Hi everyone, I need some help.
I want to have an output activated in certain x,y coordinate and deactivate in another point without interrupt movement. how can I do that, is there a possibility to have the output activated and timed while the movement keep going? I'll appreciate any help.
thanks
Darli