Hello Guest it is December 12, 2019, 02:07:30 PM

Author Topic: Stumped on how to code iterations  (Read 2429 times)

0 Members and 1 Guest are viewing this topic.

Stumped on how to code iterations
« on: November 18, 2015, 02:11:41 PM »
I am trying to run simple program to cut a slot making deeper passes with each iteration of the code.  I need to code to make 80 cuts, .015 inches deep.  I have tried a G92 command to reset Z0 after each cycle, but for some reason I can't get the syntax right.  I haven't tried a G10 because, as I understand it, that just resets the G55, G56, etc., for fixtures.  Can someone help me out with how to use G92, or a better alternative.

Thanks from the dummy trying to learn G Code on his own.

Dan
Re: Stumped on how to code iterations
« Reply #1 on: November 18, 2015, 06:37:03 PM »
Does your sig imply a Jersey guy?

Programming by hand is what we used to do. Get CamBam and use it free for 40 sessions.  Even if you don't buy it you'll learn a whole lot and my bet is you will buy it for $150.  The user forum there is great too, everyone will help.  Your slot task gets programmed in about the same time that it took me to write this! Once you start looking at code that works you'll learn G-code real fast.

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Stumped on how to code iterations
« Reply #2 on: November 18, 2015, 06:45:20 PM »
THAT is a job for sub programing (;-) List the code for your slot.

(;-) TP
Re: Stumped on how to code iterations
« Reply #3 on: November 18, 2015, 09:15:52 PM »
Garylucas, thanks for the tip.  No, I am not from Jersey.  It's worse than that.  California!  Where everyone is either fruits or nuts.

BR549

My routine looks like this:

(I am using a 3/8 end mill on 7075 T6 aluminum)

G54
X0 Y0 Z0
G1 Z-.015
G1 X 1.65
G0 Z.2
G0 X0
G0 Y-.157
G1 Z-.015
G1 X1.65
G0 Z.2
G0 X0
G0 Y-.315
G1 Z-.015
G1 X1.65
G92 Z0 (this would be where my code fails)
G0 Z.2
G0 X0Y0
M30

Rinse and repeat to a depth of 1.24 inches.  I thought about a subroutine, but not sure that I would gain anything with such a simple routine.  I just want to reset Z to current position, then rewind and run again, looping 80 times.

I could use some help understanding how to reset work home and restarting the routine.

Thx
« Last Edit: November 18, 2015, 09:20:46 PM by fortdick »

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Stumped on how to code iterations
« Reply #4 on: November 18, 2015, 10:43:02 PM »
G54
#1 = -.015
#2 = [#1+.085]
#3 = -.015
X0 Y0 Z0
M98 P1 L80
G0 X0Y0
M30
%
o1
G1 Z#1
G1 X 1.65
G0 Z#2
G0 X0
G0 Y-.157
G1 Z#1
G1 X1.65
G0 Z#2
G0 X0
G0 Y-.315
G1 Z#1
G1 X1.65
G0 Z#2
G0 X0 Y0
#1 = [#1+#3]
M99
%
Re: Stumped on how to code iterations
« Reply #5 on: November 19, 2015, 01:25:51 AM »
Thank you for that BR!  I will cut and paste that and give it a go, but more importantly, I am going to study that very hard to understand what it is doing.  I don't see which line resets the Z axis, but I do see the parameters you put in in place of a G92.  I just have to figure out which line sets the cut #1 deeper for each pass.

Thanks
Dan
Re: Stumped on how to code iterations
« Reply #6 on: November 19, 2015, 01:52:57 AM »
Alright, looking at the sub routine, I see where you set some parameters.  #1 is my depth of cut and #2 is .085, so would that make safe Z .70.  Can I use .115 in place of .085 to get to safe Z .1?

The M98 calls sub o1 with the P switch, and the L switch loops it 80 times.  But the M30 command rewinds and resets everything.   I presume that some how or others Mach remembers the L count and M30 doesn't reset that count.  Wouldn't Z, however, return to the original home coordinates with the G54 call?

I see at the end of the sub #1 is doubled with the #3 parameter, which would be perfect if there was a command resetting Z = #3.  This is what I am missing.  When you end the sub and return, and call G54 you have reset Z = 0 again, and wouldn't # 1 revert from #1 + #3?  Could a G92 Z = #3 capable of working here?

I am a noob at this, so if my questions seem obtuse, forgive me.

Thx
Dan
« Last Edit: November 19, 2015, 01:57:16 AM by fortdick »
Re: Stumped on how to code iterations
« Reply #7 on: November 19, 2015, 02:02:27 PM »
I guess simpler way of asking the above is, are variables #1, #2, and #3 modal (persistent)?

I guess they are because the code works perfectly, I am just asking so I understand what is happening.

thx
« Last Edit: November 19, 2015, 02:16:20 PM by fortdick »

Offline BR549

*
  •  6,916 6,916
    • View Profile
Re: Stumped on how to code iterations
« Reply #8 on: November 19, 2015, 08:44:12 PM »
#1 is teh starting point for Z
#2 = Rapid Height for Z
#3 = Depth per pass

The L# = number of loops

On each loop it ADDs teh depth of cut value to  Z depth

The # vars in Mach3 are modal and Global  But most are not persistant. If you need persistant # vars  use 500-600 that range is saved on shutdown.

Mach3 #vars are NOT fanuc compatible if that is what you want to know they are unique to mach3.

(;-) TP
« Last Edit: November 19, 2015, 08:47:04 PM by BR549 »