Hello Guest it is October 14, 2019, 04:56:30 AM

Author Topic: Subroutines and passing parameters  (Read 2622 times)

0 Members and 1 Guest are viewing this topic.

Subroutines and passing parameters
« on: January 06, 2015, 08:53:07 PM »
I just started playing around with Mach 3 and have have been trying to write a small G-Code program that uses a subroutine to generate a pocket.. Simple in concept.. Set the Z-Depth of the cut..call the routine to do the pocket "slice"..Set the next slice depth..call the subroutine.

Using Wizard I have a program that seems to work fine but If I load it into Mach 3 it chokes!...I am using the trial version right now. So I have two questions:

1. Are subroutines supported in Mach 3

2. I can't seem to set a local or global (volatile or non volatile) variable prior to each subroutine call and use it in the subroutine.. Any insight.. My code looks something like:
O1
       #100=-4.0
        M98 P02

       #100=-6.0
        M98 P02
        end -main

O02
        G0 Z10 (Safe Zone)
        G0 Xn Yn (move to pocket origin)
        G1 Z[#100] (drop down to the set level).
       ...
        Return


The G-Code language is quite archaic lying somewhere between BASIC and Assembly language.. Im quite surprised it hasn't evolved into a much more structured form.

Thanks in advance for any suggestions & guidance!

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Subroutines and passing parameters
« Reply #1 on: January 06, 2015, 09:29:26 PM »
Gcode is a motion control language in it basci form it doe NOT have logic. It is simple instructural code design to move a machine. It has evolve in some respects as to conditional Gcode . That has a basic logic incorporated.  It has not "EVOLVED" because it does not need to.

Yes Mach3 does subs to a limit. It does have some flaws to it.

IF you will post the working code we can review it and see what you have working.

(;-) TP