Hello Guest it is October 17, 2019, 02:16:21 AM

Author Topic: Using an M98 sub call as a GOTO  (Read 1932 times)

0 Members and 1 Guest are viewing this topic.

Using an M98 sub call as a GOTO
« on: December 17, 2016, 04:37:39 PM »
G-code does not have a "GOTO" function but I believe that I could use an M98 (Subroutine call) to cause the branch and then just never use the M99 (Return).   That will allow me to branch around sections of code.  I can later "NO-OP" the call and have the original code back.  The program will run until it encounters the M30 (Or manual STOP and REWIND), skipping over some portions, then hit the M30 and stop/rewind.

My concern is that I am leaving the call stack (or whatever implementation Mach3 uses) unbalanced.  There are some number of subroutine CALLs with no RETURNS.  The question is "Does Mach clean up the stack on the M30 or manual STOP/REWIND?"  I would assume that it does because I use subroutines and can manually STOP and REWIND a program in the middle of a sub even if nested several levels deep, but I don't know that it will still work if the program is repeated enough times.

Also, what is the stack depth for CALLS?  That would be useful info for general information.

Any other suggestions on how to implement a GOTO welcome.

Offline Graham Waterworth

*
  • *
  •  1,889 1,889
  • Yorkshire Dales, England
    • View Profile
Re: Using an M98 sub call as a GOTO
« Reply #1 on: December 23, 2016, 06:06:28 PM »
You could write the g-code into a VB M code macro and use the VB side to to the jumps.
Without engineers the world stops
Re: Using an M98 sub call as a GOTO
« Reply #2 on: December 23, 2016, 08:09:36 PM »
I'm not familiar enough with VB macros to know how to do that.  Maybe something I should learn. (Life is a learning experience.)

In the meantime I tried it on a real job and it worked well BUT ...
I still don't know if it's safe from the standpoint of repeatedly executing the same NC program for multiple parts without having Mach come unglued at some point with an unbalanced stack.  When I used it I then exited Mach and re-started it.  That way I know the stack was re-initialized and everything was clean.

I think I'll set up a test case with many of my "GOTOs' and many iterations of running the same program without re-starting Mach.  (If you can't analyze it any other way then set it up and pound on it until you are satisfied or tired.)

Re: Using an M98 sub call as a GOTO
« Reply #3 on: September 05, 2017, 03:23:19 AM »
Hi there i'm using bobcam-cad V28 set to plasma to Mach 3 on a laptop. My drawing is simulated OK, but as soon as I post to mach3, that runs in plasma mode the units jump from mm to inches everytime. Both cad and mach is set to mm .Could it be my post processor (mill plasma) that is set to inches? Or have I missed something.   Thanx Luan

Online Tweakie.CNC

*
  • *
  •  7,949 7,949
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Using an M98 sub call as a GOTO
« Reply #4 on: September 05, 2017, 03:34:11 AM »
Quote
Could it be my post processor (mill plasma) that is set to inches?

Check your generated Gcode - does it contain a G20 or a G21 ?

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
Re: Using an M98 sub call as a GOTO
« Reply #5 on: September 05, 2017, 04:14:09 AM »
I have looked in the G codes could not find G20 or G21

Online Tweakie.CNC

*
  • *
  •  7,949 7,949
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Using an M98 sub call as a GOTO
« Reply #6 on: September 05, 2017, 04:26:56 AM »
If your machine (Mach3 set-up) is set to operate in Metric units and your CAD/CAM working is in Metric units then your Post Processor should add a G21 towards the beginning of the Gcode file it produces.

Check that you do indeed have BobCam set to operate in Metric units.

Try adding a G21 to the beginning of your Gcode file.

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
Re: Using an M98 sub call as a GOTO
« Reply #7 on: September 05, 2017, 04:32:06 AM »
Thanx Tweakie will give it a try