Machsupport Forum

General CNC Chat => Share Your GCode => Topic started by: Ya-Nvr-No on October 31, 2010, 07:56:03 PM

Title: Multi pass facing program
Post by: Ya-Nvr-No on October 31, 2010, 07:56:03 PM
    I have to clean up lots of top surfaces that need multiple passes to get flat. So I wrote this program to do what I needed. If nothing else it's a good example of doing multiple subroutines using variables. Hope it helps someone, I find it so much easier. I just enter in the width and Length of the face along with the number of passes I need to make to clean it up.
    Wish I could use if/then statements like I use with macro B but this does work well for me in Mach3. I tried to document to help ya. But I hope you will get the idea. Beats the Wizards for me.

Code: [Select]
   (CUTS Top Face of stock)
    (STARTED AT Z0 TOP OF rough PART)

    M03 (start spindle)
    G1G90X0Y0Z0.25F60. (Go to lower left corner of stock)
    Z0 ( Feed to face of rough stock)

    (load variables)
    #1000=[16] (Length in X in this case inches)
    #1001=[13] (Width in Y)
    #1002=[-0.1] (depth each of cut pass)

    #1004=0
    #1005=0.65 (offset cut distance smaller than .75 cutter diameter)
    #1006=[#1005*2] (Compute step over)
    #1007=[#1001/#1006] (Compute passes)

    M98 P5 L8 (call subroutine CUT DOWN IN Z in this case 0.1 * 8 = .8")
    M05 (stop spindle)
    G0G90Z.25 (move back up)
    X0Y0 (go home)
    M30 (All done)

    O5
    M98 P10 L1 (call sub to feed down)
    M98 P20 L1 (call sub to face part)
    G0G90Z0 (Move out of the way)
    X0Y0 (Go Home)
    M99

    O10
    #1004=[#1004+#1002] (Calculate New cut depth)
    G1Z[#1004] (MOVE TO CUT DEPTH)
    M99

    O20
    M98 P30 L[#1007] (call sub to cut reps ACROSS)
    M99

    O30
    (THIS IS THE SUB TO CUT FACE)
    G1 G91Y[#1005] (Increment over in Y)
    G90X[#1000]F80. (Cut across part)
    G91Y[#1005] (again increment over)
    G90X0 (Cut back across part)
    M99
Title: Re: Multi pass facing program
Post by: BR549 on October 31, 2010, 10:33:38 PM
HIYA YA-NO, Looks good, please drop off a copy of this in the MACH TOOLBOX it is a section setup to SAVE things such as this to help others

(;-) TP

Title: Re: Multi pass facing program
Post by: Ya-Nvr-No on October 31, 2010, 11:03:17 PM
Totally forgot about that section, Sorry, Hell to get old!!!
I would have had no problem with anyone moving it for me
Should or... can I, delete this topic?
I did re-post, now I'll probably get in hot water about that, LOL
Title: Re: Multi pass facing program
Post by: BR549 on November 01, 2010, 06:25:52 PM
You are fine(;-) I always encourage people to put a copy of their cool functions in the Mach toolbox. THat way it is easy to find WHEN you need it.

(;-) TP
Title: Re: Multi pass facing program
Post by: Jammerm on November 05, 2010, 07:42:19 PM
Shoot, I didn't even know there was a Mach Toolbox. ??? ::)
Title: Re: Multi pass facing program
Post by: Ya-Nvr-No on March 24, 2012, 12:20:29 PM
Some reason can not find the Mach Toolbox again; Seems like a simple search would helped me locate it, But to no avail.
(Update Found it: Machsupport Forum\ Support\ Downloads section)

Had to sharpen my lawnmower blades for a new season, so mounted a Dumore tool post grinder on my Z axis head, made a blade fixture holder, then wrote a small script to solve the task. Now I don't have to deal with the grief and they are always balanced. Uses a 3" diameter grinding wheel and does one sweet job, no burning and less mess. Though it does take longer than by hand I can get back to more fun safer things. Like napping.
Code: [Select]
O01
#100=-0.05(X Initial Home Start Point)
#101=-0.01(Y Initial Home Start Point)
#102=0.0  (Z Start Point)
#104=5.0  (X End Point)
#105=25   (Depth of Cut 25 *.002" = .05")
#106=15   (Number of Passes 15 * .02" *.02"= .6")
#107=0.002(Depth of Z cut)
#108=0.02 (Step over Y amount)

M3(Grinder Started)
G90
G0 Z0.1
X#100 Y#101(Go to the Initial Start Point)
Z#102
M98 P10 L#105
M5
M30

O10
#100=-0.01(X resets Home Start Point)
#101=0    (Y resets Home Start Point)
#102=0
G0 X#100 Y#101
#102=[#102-#107]
G0 Z#102
M98 P20 L#106
M99

O20
#101=[#101-#108]
G1 Y#101 F90
X#104
#101=[#101-#108]
Y#101
X#100
M99
(Put comment here to make sure I have a carriage return on the last M99)
Title: Re: Multi pass facing program
Post by: jwhalin on April 03, 2012, 01:10:43 PM
Hi, here is the code I use. It calculates how many loops are necessary before a final pass at a finish feed rate.  This is just the cutting part of the code, you can add to it as you like... Enjoy

; Turn OD   4-1-12

; running in DIAMETER mode.

;Set Z to ZERO at face of part

T101 ;facing tool number
;
#10 = .500 ; starting OD
#20 = .375 ; finish OD
#30 = .003 ; Cut depth per pass
#40 = .750 ; LENGTH OF OD CUT FROM ZERO
;
#60 = 3 ; rough feed
#70 = 1 ; finish feed
;
;Calculations
#50 = [#40 * -1] ; length of turning from ZERO (negative towards headstock)
#90 = FIX[[#10 - #20] / [#30]] ; number of FULL loops for P001
;
;
G0 X[#10 + .5]
G0 Z0.050
G0 X [#10]
#100 = [#10]
F[#60]
;
M98 P001 L[#90]
#100 = [#20]
F[#70]
;
M98 P002
G0 X[#10 + .5]
G0 Z2.0
M30
;
O001
G0 X [#100]
G1 Z [#50]
G1 X [#100 + .020] Z [#50 + .010]
G0 Z .050
#100 = [#100 - #30]
M99

O002
G0 X [#100]
G1 Z [#50]
G1 X [#10 + .02]
M99

Title: Re: Multi pass facing program
Post by: Ya-Nvr-No on April 03, 2012, 06:34:30 PM
Thanks, nice to see a lathe routine. one of these days I will get my lathe build done and put your routine to use.
Title: Re: Multi pass facing program
Post by: jwhalin on April 03, 2012, 06:50:54 PM
Thanks, with some simple revision it works great for face milling too. The point was to show how to not have to do any calculations. BTW you can "nest" m98/m99 code to do X-Y and Z.
Title: Re: Multi pass facing program
Post by: Ya-Nvr-No on April 03, 2012, 07:01:10 PM
I know, I been programming since 1984, Started this post for those that were new to sub programs and would like to see some examples of there use and how to apply them to their needs.
Title: Re: Multi pass facing program
Post by: jwhalin on April 03, 2012, 08:43:35 PM
My apologies, I could learn a lot from you.......   I usually just blunder my way through till it works....   
Title: Re: Multi pass facing program
Post by: Ya-Nvr-No on April 03, 2012, 10:42:55 PM
No apologies necessary, when we share, we all learn something new. I just love the many challenges.

There is a lot of talented people sharing on this site.

Thank You and keep blundering. I just wish the Mach3 programming language was even more like Fanuc Macro B because I do like parametric programming. I work with large family of parts and use lookup blocks of code to fill variables. Operator changes one macro variable #500 and when the program starts and reads the #500 variable it jumps to a section that fills all the variables for that part.

Little example of what one of my old turning center main program looks like, including the variable loader program. not all there of course but gives you the idea. Does a several dozen different parts and shapes just uses the same blank shape. The robot side has the same basic program routine but it sets the robot for different blank lengths. So the load, unload and turn around positions can be set with variables, again all by using one input #500 variable by the operator.

Code: [Select]
O0001(LATHE SIDE)
(MAIN PROGRAM)
M98P999(SET/GET VARIABLES)
 
N10(READY TO RUN)
M19(ORIENT CHUCK)
M70(SYNC ROBOT LOAD 1ST PART)
M71(SYNC ROBOT UNLOAD/LOAD)
 
M98P50(CALL 1ST PART 1ST SIDE)
M98P8054(TABLE BLOW LOOP)
M19(ORIENT CHUCK)
M70(SYNC ROBOT LOAD 2ND PART)
M71(SYNC ROBOT UNLOAD/LOAD)
 
M98P50(CALL 2ND PART 1ST SIDE)
M98P8054(TABLE BLOW LOOP)
M19(ORIENT CHUCK)
M70(SYNC ROBOT FLIP STATION)
M71(SYNC ROBOT UNLOAD/LOAD)
 
M98P51(CALL 1ST PART 2ND SIDE)
M60(COUNT PART 1)
M98P8054(TABLE BLOW LOOP)
M19(ORIENT CHUCK)
M70(SYNC ROBOT FLIP STATION)
M71(SYNC ROBOT UNLOAD/LOAD)
 
/M99P20(JUMP FINISH ROUTINE)
M98P51(CALL 2ND PART 2ND SIDE)
M60(COUNT PART 2)
M99P10(LOOP ROUTINE)
 
N20(FINISH ROUTINE)
M98P51(2ND PART 2ND SIDE)
G28U0W0(HOME BOTH X Z AXIS)
M98P8054(TABLE BLOW LOOP)
M19(ORIENT CHUCK)
M70(SYNC ROBOT FLIP STATION)
M71(SYNC ROBOT UNLOAD/LOAD)

M98P8054(TABLE BLOW LOOP)
M19(ORIENT CHUCK)
M70(SYNC ROBOT LOAD 2ND PART)
M72(SYNC ROBOT CODE 2 UNLOAD)
M30

O0050(FIRST SIDE)
G28U0.W0.
G#506

N10
G0T05M347
G97S3200M04
M98P41(DRILL HOLE)
M54(TABLE BLOW ON)
 
N20
G0T03
G97S1079M04
G0X[#502+0.2]M8
Z0.1
G50S3800
G96S1100
M98P42(FACE FRONT)

N30
G0T06
G97S3500M04
M98P43(BORE ID)

N40
G0T07
G97S3800M04
M98P44(BACKBORE FACE)

G0G28W0.T0
G0G28U0.
M99
 
O0051(SECOND SIDE)
G#506
N500
G0T04
G97S1079M04
G0X[#502+0.2]M8
Z[0.1+#504]
G50S3800
G96S1100
M98P#508
G0Z2.
G28W0T0
G0G28W0.M9
G28U0.
M99

O8054(BLOW TABLE LOOP)
M54(TABLE BLOW ON)
G4P1000(DWELL 1 SEC)
M55(TABLE BLOW OFF)
M99

O0999
N2(GET GROUP ID)
IF[#500EQ10]GOTO10(SB 1.35 W/HUB.847)
(several more if statements here)
(stays here till variable 500 is set to part)
GOTO2

N10(SB 1.35 W/HUB.847)
#502=3.45(X DIAMETER)
#501=0(SIDE 1 Z SETBACK)
#503=-0.260(SIDE 2 Z SETBACK)
#504=0(BACKFACE Z OFFSET)
#505=0(X HUB OFFSET)
#506=54(WORKOFFSET NUMBER)
#507=100(SIDE 1 PROGRAM)
#508=101(SIDE 2 PROGRAM)
#509=0(WORKOFFSET Z OFFSET)
M99