Hello Guest it is March 28, 2024, 07:21:13 PM

Author Topic: return from sub  (Read 4112 times)

0 Members and 1 Guest are viewing this topic.

rswolff

*
return from sub
« on: April 17, 2015, 09:46:34 PM »
the following code does not work as described in manual......

G90 G00 X0 Y0 Z0
N0001
G00 X1.0 Y1.0 Z0.0
G01 F10.0 Z-0.2
G00 Z0.0
X0.1 y0.1
M98 P1001
O0100
G00 X2.0 Y2.0
M30
O1001
M99 P0001

I would expect the return in the M99 line to return to N0001 (it doesn't). I got the loop to run but I needed to modify the N0001 to O0001 and the M99 P0001 to M98 P0001. This will work however I am concerned about loop nesting exceeding the maximum and crashing the program.

Any help greatly appreciated.

thanks,
bob  ::)

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: return from sub
« Reply #1 on: April 17, 2015, 10:20:47 PM »
I think that the sub call can only return back to the original sub call.

You called the sub from the M98 P1001 . It will run the sub then the M99 will  return  back to the original sub call.    Then run the code until the required M30.

It would normally look like this.

G90 G00 X0 Y0 Z0
G00 X1.0 Y1.0 Z0.0
G01 F10.0 Z-0.2
G00 Z0.0
X0.1 y0.1
M98 P1001
G00 X2.0 Y2.0
M30
o1001
M99
%

THe M98 can call a LOCAL sub or an OUTSIDE sub.

Just a thought, (;-) TP

rswolff

*
Re: return from sub
« Reply #2 on: April 17, 2015, 10:26:00 PM »
according to the Manual (its for Mach4) M99 Pxx would return to the Nxx line in the main program. I am using Mach3 so I'm guessing this doesn't work. Is there a method to jump to a specific line? I don't see anything as such in the manual.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: return from sub
« Reply #3 on: April 17, 2015, 10:32:09 PM »
Mach4 YES, Mach3 NO. they are 2 different DAWGS.


Mach3 does not have conditional Gcode so there is little need to return to anything other than the original sub call.

 WELL it can be done BUT (;-) WHY ?


(;-) TP

rswolff

*
Re: return from sub
« Reply #4 on: April 17, 2015, 10:54:30 PM »
because I'm incrementing a counter and deciding where to return....no...I didn't want to run the sub x times...guess I'll need to do it in some other way....bizarre program at best.....other than being cheap.....really cheap...its hard to imagine someone actually WANTING to use this program as a substitute for a real application. Does a lot...not a lot particularly well however.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: return from sub
« Reply #5 on: April 18, 2015, 12:34:19 AM »
There is no difference of counting to a stop point or preplanning the number of moves to get to the stop point (;-) But instead of counting up you count down to zero.   Been there done that.

Just a thought(;-) TP

rswolff

*
Re: return from sub
« Reply #6 on: April 18, 2015, 09:35:11 AM »
I agree.......0-10 is functionally the same as 10-0......conditional moves or conditional program control has been around for decades.....its not something new......why any software package would not make provisions for it simply implies a lack in development.....I find nothing about this product to imply any type of robust interface.....its simply cheap....not inexpensive.......then instead of spending time working.......you can spend time scratching some part of your body trying to figure out some method to make it work as it should.
bob  :-\

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: return from sub
« Reply #7 on: April 18, 2015, 09:47:39 AM »
Well that is the good thing about fair market no one forces you to use it (;-) . After 10 years of using it I have not found anything that I cannot make that I do with Conditional programming. Most user do NOT hand program.

(;-) TP

rswolff

*
Re: return from sub
« Reply #8 on: April 18, 2015, 09:58:09 AM »
 and again I agree......there is nothing you can't do without conditional programming......it however makes programming much simpler and quicker....which is why any CNC machine with any standard control can utilize it. Why would you then develop software that didn't include it since from an application stand point its not particularly difficult to implement? (think cheap). And I've been using CNC machinery since before 1975 when our posts were on PDP11's....we hand coded a quite a bit back then......
bob  ::)

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: return from sub
« Reply #9 on: April 18, 2015, 10:39:53 AM »
SHOW me another CNC controller that can run native windows using the LPT ports .  There are none (;-) TP

 Sometimes to make the primary purpose (CNC controller) work  you find there are limitations to what you can do. Such is the case of Conditional Gcode in Mach3.

So would you want NO CNC controller or one that has limitations in areas that MOST people  never use ???

DOn't take me wrong as I am an advocate of conditional programming (;-)  BUT you cannot always have your cake and get to eat it too for a $159 6axis CNC controller that runs in windows with the LPT ports

Just a thought, (;-) TP
« Last Edit: April 18, 2015, 10:44:07 AM by BR549 »