Hello Guest it is March 28, 2024, 07:21:37 AM

Author Topic: Subroutine Using M98  (Read 6361 times)

0 Members and 1 Guest are viewing this topic.

Subroutine Using M98
« on: August 18, 2009, 07:52:14 PM »
This is the first program I've ever written in G code, and surprise, surprise it doesn't work! I'm trying to create a subroutine to change my Z position by three thousands of an inch increments. I know there are a lot of threads on here that already discuss this topic, but I haven't been able to find a solution that makes this code work. This is what I have:

G00  G49  G40.1  G17
G80  G50  G90  G98   
G20  (Inch)

G52  Z0.003
M98  P1
G52  Z0.006
M98  P1
G52  Z0.009
M98  P1
G52  Z0
G00  Z-0.01
S1300
G04  P2000
G01  X-6 F10
S0
G04  P1000
G00  Z0.5
G01  x0 F200 
M30
O1
S1300
G04  P2000
G01  X-6 F30
S0
G04  P1000
G00  Z0.5
G01  x0 F200   
G00  Z0
M99
%

I'm sure my code is fundamentally flawed, but if you know what I've missed I would appreciate knowing!

Thanks!

vmax549

*
Re: Subroutine Using M98
« Reply #1 on: August 19, 2009, 05:22:16 PM »
OK the fundimentals work, You have the sub loop working ok and you are applying the G52. 

YOu do need to bone up on the use of the m3 m5 to turn the spindle on or off and not use s0.

ALSO if you need to rapid use a g0 instead of raisng the feed speed, That habit will get you sooner or later(;-)

Are you simulating it and wondering why the dros and the picture looks the same?? Or are you cutting it on a machine?

(;-) TP
Re: Subroutine Using M98
« Reply #2 on: August 20, 2009, 12:34:10 AM »
Hi,

Thanks for the help! I'm cutting it on a machine. I'm not a 100% familiar with the machine, it's my dad's. He has a Rottler F65 that stopped functioning correctly, so he installed a Vital Systems DSPMC control system and uses Mach3. There is a lot of functionality in Mach3 that he can't use with the DSPMC controller, one function is how to run the spindle... so the M3 and M5 are a no go. I was hoping my code was completely messed, now I am thinking it's the controller. It doesn't seem to like G52, and won't run the loop, it will only run the code once with an incorrect increment. I guess I need to try to write something that has a loop, but doesn't require G52. I put this together looking at some of the other posts on here (this forum is extremely helpful!) but I haven't run it yet: I'm not sure if the #3=[#3-0.003] will work. But check out the G00's ;) 

#3=0
M98  P1 L2
M30
O1
G91
G00  Z#3
S1300
G04  P2000
G01  X-6 F30 ( F30 for rough, F10 for finish)
S0
G04  P1000
G00  Z0.5
G00  X0 Z0
#3=[#3-0.003]
M99
%

vmax549

*
Re: Subroutine Using M98
« Reply #3 on: August 20, 2009, 10:22:32 AM »
NOW you have the idea(;-)

BUT  remember when in INC mode it only move the amount not to the position, so a G91 Go Z0 would not move to Z0 it would move z a value of zero.
A good way to test loops is to run the file in SINGLE block mode. THat way each push of cycle start processes ONE line at a time. For testing you can see it drop out to the sub  and then back when done.  That makes it very easy to spot a bad call or line.

YOU file does not have the normal move to start position and plunge in z so I assume you are just testing the theories ???

#3=0
M98  P1 L2
M30


O1
G91            >>>>>>>>> Everything after this will move incrimentally not to position  UNLESS that is what you had it mind(;-)
G00  Z#3
S1300
G04  P2000
G01  X-6 F30 ( F30 for rough, F10 for finish)
S0
G04  P1000
G00  Z0.5
G00  X0 Z0
#3=[#3-0.003]
M99
%


(;-) TP

vmax549

*
Re: Subroutine Using M98
« Reply #4 on: August 20, 2009, 11:58:47 AM »
NOW that said the G52/92 is very handy .  So you have a complet file than you would really just like to multistep the sub DOWN to another level.

You wold use an approach like your first example to rerefernce X0 to a lower level each pass.  Youmay want to play with the g52/92 to see exactly how they work. I think there are some examples n te mach manual.

IF you can't get it figured out get back with us and we will see if we can get you up to speed with it.

I don't know what your controller can or cannot do (;-) I do know what mach can do(;-)

(;-) TP
Re: Subroutine Using M98
« Reply #5 on: August 22, 2009, 01:20:40 PM »
Incremental mode!!!!! Dang it!! Ok, I've got it now. I don't even need the #3 = #3-0.003 if I'm in incremental mode, and just don't return to Z0 until after my subroutine call.... Ok, I think I've got something that works (G52 and my controller just don't get along  :) )

Thanks for the help!