Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: SpencerChase on February 16, 2018, 09:56:02 PM

Title: return called with no sub in effect problem continues
Post by: SpencerChase on February 16, 2018, 09:56:02 PM
i thought i had posted this but can not see it in recent posts so i have no idea if others have seen it either

I have read everything i can find on this topic and still have a problem. I have a test machine that is not connected to my router. It is running Version R3.043.066 of Mach3 I can run the code below and it works fine. However when i try to run the code on the real machine i get the return called with no sub in effect error. I have version R3.043.050 on the real machine and pretty much need to keep this because it is the only version i can get to work with an RU Pendant and other things like a Pokeys. I have tried virtually every version of mach3 that i can download and i really seem to be stuck with version ... 050 

i can try version .066 to see if the program will run on the router but i can not use that version for the reason stated above. I added M30 at the end of the program and also added line numbers and a return in each sub to the line called. none of this makes it work on the router but it still works fine on the test machine running v .066

N10 G20 (inch units)
N20 G90 (absolute distance)
N30 G64 (constant velocity mode)
N10 G40 (cancel cutter radius compensation)
N40 G17 (XY plane select)
N50 G52 X0 Y0 Z0 (cancel all offsets)


(M8 coolant on)
(set machine at 0 0 by touching)
(then move to first position X and Y .5" - 1/2 tool diameter)
(do one peck drill then advance 14 times pause tool change drill and reverse )
(can make following a sub, does not need to be incremental but X advance could be)
(space between holes is .325?)

N60 M3 S1000  (spindle on set to 180)
N70 G0 Y -.25
N80 M98 P1000 L5

N90 M6  (stop for part repositioning)
N100 M98 P2000 L5
N110 M30

O1000
G0 Z.1  (retract)
G1 F40 Z .09
G1 F10 Z -.120
G1 F50 Z -.1
G1 F20 Z -.15
G1 F10 Z -.25
G1 F10 Z -.31
G0 Z.1  (retract)
G91
G0 X .32
G90
M99 P80



O2000
G0 Z.1  (retract)
G1 F40 Z .09
G1 F10 Z -.120
(G4 P.5 dwell 500 ms  mach3 seems to be decimal seconds not MS)
G1 F50 Z -.1
G1 F20 Z -.15
G1 F10 Z -.25
(G4 P500 dwell 500 ms)
(M30 rewind program)
G1 F10 Z -.31
G0 Z.1  (retract)
G91
G0 X -.32
G90
M99 P100
Title: Re: return called with no sub in effect problem continues
Post by: joeaverage on February 17, 2018, 12:43:53 AM
Hi,
I have not used subroutines so I can't really help however I have a question....

Quote
M99 P80
You have coded this line in your O1000 sub. Do you need the 'P80' as return address?. My reading of Peter Smid's book suggests not, it does allow for such return
statements but you don't need it.

May I suggest removing the P80 from O1000 and the similar P100 from O2000 and try it.

Craig
Title: Re: return called with no sub in effect problem continues
Post by: rjantz3 on February 17, 2018, 01:13:26 AM
I confirm the problem exists in 050 and not in 066. As a workaround does it work for you to add a blank entry like just add N105 between N100 M98 P2000 L5 and N110 M30 so it looks like this?

N100 M98 P2000 L5
N105
N110 M30

Also it seems to work with or without putting the P parameter at the end of the subroutine.
Title: Re: return called with no sub in effect problem continues
Post by: SpencerChase on February 17, 2018, 02:45:20 AM
i tried the code without the P80 and P100 first and just added them because i thought it might help. either way works in v 066 but not in v 050

i added the blank lines and it works !!!!!!!!  amazing. how do you guys figure this sort of workaround out?
Title: Re: return called with no sub in effect problem continues
Post by: joeaverage on February 17, 2018, 03:16:14 AM
Hi,
the credit is rjantz3's. You may have seen some Gcode files that end:

N110 M30
%

The % symbol is just to ensure that the M30 is recognized, the symbol effectively means that N110 is not the last line but the second to last line.

I have not seen this situation before but rjantz3 had it spot on.

Craig
Title: Re: return called with no sub in effect problem continues
Post by: rcaffin on February 27, 2018, 05:08:50 AM
Yes, you can have all sorts of funny problems if the file does not end properly. This is even mentioned in the Mach3Mill manual somewhere (section 10.5). At the least, it MUST have a <carriage return> at the end of the last line.

As Craig suggested: put a '%' at the end of the code on its own line every time. (I think that too is in the manual - somewhere.)

Cheers
Roger
Title: Re: return called with no sub in effect problem continues
Post by: SpencerChase on February 27, 2018, 12:25:46 PM
i had blank lines at the end of the program, might not have gotten pasted into the post. it seems that blank lines are needed after each M98 as well. do not remember reading anything about that in the manual but it could be there? with a blank line after each M98 it works perfectly and i can start making thousands of little parts, oh joy :)
Title: Re: return called with no sub in effect problem continues
Post by: rcaffin on February 28, 2018, 01:05:33 AM
 it seems that blank lines are needed after each M98
Um ... interesting. I think you mean after every M99 though.

Now I think about it, I do always have a blank line after every M99. Hum ...

Cheers
Roger
Title: Re: return called with no sub in effect problem continues
Post by: SpencerChase on February 28, 2018, 01:46:34 AM
no, i mean after every M98. my main program calls two subs and if i do not have a blank line after each M98 the program will now run and generates and error of something like return with no sub. some clever person on this forum suggested a blank line afer each M(* and this fixed the problem . also verified that it is a problem only with some versions of Mach3  unfortunately i am stuck with a particular version because one thing i am using does not work with a new version and another does not work with an older version. i could just dump everything and start over with new hardware that will have different problems :)
Title: Re: return called with no sub in effect problem continues
Post by: rcaffin on February 28, 2018, 02:19:13 AM
After every M98 ? ? ? ?
You must have an ancient and arguably very defective version of Mach3.

I am curious as to why 'one thing I am using does not work with a new version' - what is that thing?
OK, I am really challenging the claim. It's really not a good idea to be tied like that to a defective version of anything.

I would be seeking to fix that 'thing' problem myself.

Cheers
Roger
Title: Re: return called with no sub in effect problem continues
Post by: SpencerChase on February 28, 2018, 02:45:58 AM
the thing is an RU pendant. it will not work with version over .....50 something. i think the guy who built them had someone else do the plugin and there is no reason or motivation to update it. there is something else i am using or depending on but i forget what it is that requires a minimum of a certain version so i can also not go lower than v ....50 although i would not want to anyway.

i could try dithering around one version up or down but if the only problem i am having right now is that i have to remember to add blank lines to M98s well that is not so bad.
Title: Re: return called with no sub in effect problem continues
Post by: rcaffin on February 28, 2018, 03:34:03 AM
Pendant?
I have a pendant which just plugs straight into the USB port. Does it need a plug-in? I can't remember, but at least one eBay vendor says it does not. Maybe it uses a generic one from MS? Anyhow, the whole thing cost me about US$27, and handles 4 axes.

Cheers
Roger
Title: Re: return called with no sub in effect problem continues
Post by: SpencerChase on February 28, 2018, 11:39:01 AM
if the pendant does not use a plugin it would have to communicate with mach3 via keyboard commands. i built one that works this way and it works OK in certain respects but it not as versatile as one can be that uses a plugin to directly control mach3. the RU is pretty good but not fantastic but it is an older one.