5 Generating loops Introduction to looping Presentation links page for lesson five 5 Generating loops Introduction to looping Comparison to sub-programming A loop that counts to ten Steps to looping How many executions are required? What changes each time through? Peck drilling example application
We can compare looping to subprogramming Looping Defined Looping is the act of causing the control to execute a series of commands a specified number of times Definition: We can compare looping to subprogramming
Comparison To Subprogramming As you know, subprograms can be repeated Repeat subprogram 5 times M98 P1000 L5 But nothing can change from one execution to the next
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Comparison To Subprogramming Anything can change each time through a loop! Angular hole position changes Bolt hole circle
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Multiple pass grooving Comparison To Subprogramming Multiple pass grooving Z position changes
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z positions change
Comparison To Subprogramming Peck drilling Z position changes
A Loop That Counts To Ten O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Program number O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Initialize counter O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Test if finished with loop O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99 Now false
A Loop That Counts To Ten Calculations would go here O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Motions would go here O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Step the counter by one (now 2) O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Go back to the test O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Test if finished O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99 Still false
A Loop That Counts To Ten Calculations would go here O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Motions would go here O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Step counter by one (now 3) O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
A Loop That Counts To Ten Go back to test O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
After ten executions, this will be true! A Loop That Counts To Ten Counter will eventually be 11 O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99 After ten executions, this will be true!
A Loop That Counts To Ten GOTO sends control to end of loop O2000 (Custom macro B) #101 = 1 N1 IF[#101GT10] GOTO 99 (Calculate if necessary) (Motions for this execution) #101 = #101+1 GOTO 1 N99 M99
Steps To Looping Warning! 1) Initialize Counter Number of executions Initialize counter, number of executions, and anything that changes each time through the loop Warning! 1) Initialize Counter Number of executions Anything that changes Change-by amounts Constant variable values Constant position values Always determine the number of executions up-front – You’ll often be tempted to test against axis position to see if your finished
Steps To Looping 1) Initialize 2) Test to see if finished Counter Test if counter is greater than number of executions 1) Initialize Counter Number of executions Anything that changes Change-by amounts Constant variable values Constant position values 2) Test to see if finished If counter is greater-than executions
Steps To Looping 3) Make calculations 4) Perform the loop’s intention Not all loops require this step Make the control do one execution of the loop 3) Make calculations for this loop execution if necessary 4) Perform the loop’s intention Machine workpiece workpiece drill one hole make one milling pass make one peck Make positioning movement Test an offset
Steps To Looping 5) Step anything that changes 6) Go back to the test What changes each time through the loop? The test will eventually be true 5) Step anything that changes Counter Anything else that changes 6) Go back to the test GOTO statement label before test
Two Times Loops Are Required Most common 1) When the number of executions changes 2) When redundant commands can be reduced
How Many Executions? 8 holes You must determine how many times the loop is executed Sometimes it’s easy: Bolt circle 8 holes
The number of holes is the number of executions How Many Executions? You must determine how many times the loop is executed Sometimes it’s easy: 16 holes The number of holes is the number of executions
Divide hole depth by peck depth to determine number of executions How Many Executions? Sometimes it’s harder: Hole depth: 3.0 Peck depth: 1.0 Divide hole depth by peck depth to determine number of executions # of passes = Hole depth Peck depth 3.0 1.0 3 pecks
How Many Executions? Hole depth: 3.125 Peck depth: 1.0 4 pecks? Sometimes it’s harder: But wait… Hole depth: 3.125 Peck depth: 1.0 The hole depth is not evenly divisible by the peck depth! But remember, you must determine the number of executions up front! 3.125 1.0 4 pecks?
We’ve recalculated the peck depth to generate an even number of pecks! How Many Executions? Sometimes it’s harder: Hole depth: 3.125 Peck depth: 1.0 We’ve recalculated the peck depth to generate an even number of pecks! # of pecks = ROUND[HD/PD] 3.125 1.0 Peck depth = HD / # of pecks 3 Pecks 1.0416 per peck
The passes must overlap! How Many Executions? Sometimes it’s much harder: Minimum overlap Passes = FUP[GW / [TW-.02]] 0.125 The passes must overlap! 2 passes? 0.25
How Many Executions? 3 passes Passes = FUP[GW / [TW-.02]] 0.125 0.25 Sometimes it’s much harder: Passes = FUP[GW / [TW-.02]] 0.125 3 passes 0.25
How Many Executions? Regardless of how difficult it seems… Always determine the number of passes “up-front”!
The XY position changes each time through the loop What Changes Each Time? 3. 1. 45 8 holes The XY position changes each time through the loop
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? X Y
What Changes Each Time? But wait, what is the XY position determined by? The hole’s angular position! X Y
What Changes Each Time? cos[ang] * radius sin[ang]* radius
What Changes Each Time? Current angle: 45 degrees
What Changes Each Time? Current angle: 90 degrees
What Changes Each Time? Current angle: 135 degrees
What Changes Each Time? Current angle: 180 degrees
What Changes Each Time? Current angle: 225 degrees
What Changes Each Time? Current angle: 270 degrees
What Changes Each Time? Current angle: 315 degrees
What Changes Each Time? Current angle: 360 degrees
What is the incremental angular distance between the holes? What Changes Each Time? What is the incremental angular distance between the holes? Distance between = 360 / number of holes
What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0 As initialized: Number of passes: 3 Peck depth: 1.0416 -3.125 Changing variables: Current appr.: 0.1 Current depth: -1.0416 Change: -1.0416
What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0 2nd peck: As initialized: Number of passes: 3 Peck depth: 1.0416 -3.125 Changing variables: Current appr.: -0.9416 Current depth: -2.0832 Change: -1.0416
What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0 3rd peck: As initialized: Number of passes: 3 Peck depth: 1.0416 -3.125 Changing variables: Current appr.: -1.9832 Current depth: -3.1248 Change: -1.0416
What Changes Each Time? Z position GW: 0.25 TW: 0.125 3 passes Current Z pos: -1.0 (0.0625) Move over amount: [.25 - .125] / [3-1]
What Changes Each Time? Z position GW: 0.25 2nd pass TW: 0.125 3 passes Current Z pos: -.9375 (0.0625) Move over amount: [.25 - .125] / [3-1]
You must determine what changes each time through the loop! GW: 0.25 TW: 0.125 3rd pass Z position 3 passes Current Z pos: -.875 You must determine what changes each time through the loop! (0.0625) Move over amount: [.25 - .125] / [3-1]
There may be other values needed within the loop Any Other Initialized Values? All changing values must be initialized (set to a starting value) at the beginning of the loop Changing values must be stepped (by the step amount) at the end of the loop There may be other values needed within the loop
Any Other Initialized Values? Bolt hole pattern: Rapid plane Hole bottom position These values are not being stepped. But they are initialized to save calculations each time through the loop. Peck drilling: Initial approach position Grooving: X axis approach Groove bottom position
Prior Positioning Movement? Many loop applications require a prior positioning movement before the loop Bolt hole pattern: To center of the pattern Peck drilling: To Z approach position Grooving: To approach position
What Must Happen Each Time? You must determine what happens each time through the loop Bolt hole pattern: Machine one hole Peck drilling: Make one peck & retract Be careful! Beginners tend to do too much! Grooving: Make one plunge & retract
Peck Drilling Example Main program: O0001 (1/2 drill) N005 T01 M06 N010 G54 G90 S200 M03 T02 N015 G00 X2. Y2. N020 G43 H01 Z0.1 N025 G65 P1001 X2. Y2. R.1 Z-4.0 Q1.5 F5. N030 G65 P1001 X3. Y2. R.1 Z-4.0 Q1.5 F5. N035 G91 G28 Z0 M19 N040 M01
Peck Drilling Example Main program: O0001 (1/2 drill) N005 T01 M06 N010 G54 G90 S200 M03 T02 N015 G00 X2. Y2. N020 G43 H01 Z0.1 N025 G65 P1001 X2. Y2. R.1 Z-4.0 Q1.5 F5. N030 G65 P1001 X3. Y2. R.1 Z-4.0 Q1.5 F5. N035 G91 G28 Z0 M19 N040 M01
Peck Drilling Example Main program: O0001 (1/2 drill) N005 T01 M06 N010 G54 G90 S200 M03 T02 N015 G00 X2. Y2. N020 G43 H01 Z0.1 N025 G65 P1001 X2. Y2. R.1 Z-4.0 Q1.5 F5. N030 G65 P1001 X3. Y2. R.1 Z-4.0 Q1.5 F5. N035 G91 G28 Z0 M19 N040 M01
Peck Drilling Example Main program: O0001 (1/2 drill) N005 T01 M06 N010 G54 G90 S200 M03 T02 N015 G00 X2. Y2. N020 G43 H01 Z0.1 N025 G65 P1001 X2. Y2. R.1 Z-4.0 Q1.5 F5. N030 G65 P1001 X3. Y2. R.1 Z-4.0 Q1.5 F5. N035 G91 G28 Z0 M19 N040 M01 #24 #17 #7 #18 #25 #9
Peck Drilling Example In custom macro B: O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Program number O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize counter O1001 #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize amount of Z motion #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize number of passes #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize recalculated peck depth O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize current approach position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Initialize current bottom position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Rapid to hole center in XY #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Rapid to R plane O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Test if loop is finished #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Rapid to current Z approach position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B: This positioning movement is not required the first time through the loop
Peck Drilling Example In custom macro B: Feed to current peck depth #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Retract out of hole O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step counter O1001 #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step current Z approach position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step current peck bottom position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Go back to test O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Are we done now? (no) O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Rapid to current Z approach position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B: For each successive peck, this movement is necessary (the tool is at the initial approach position)
Peck Drilling Example In custom macro B: Drill to current peck depth #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Retract out of hole O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step counter O1001 #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step current approach position O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Step current peck bottom #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
Peck Drilling Example In custom macro B: Go back to test O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B:
After the last peck, this IF statement will be true Peck Drilling Example Are we done yet? O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B: After the last peck, this IF statement will be true
Peck Drilling Example In custom macro B: End of loop (and custom macro in this case) O1001 #101 = 1 (Counter) #102 = #18 - #26 (Total Z movement) #103 = ROUND[#102 / #17] (# of passes) #104 = #102 / #103 (New peck depth) #105 = #18 (Current peck approach) #106 = -[#104] (Current peck bottom) G00 X#24 Y#25 (Rapid to hole XY position) Z#18 (Rapid to initial Z approach position) N1 IF [#101 GT #103] GOTO 99 (IF finished, exit) G00 Z#105 (Rapid to current peck approach) G01 Z#106 F#9 (Machine to current peck bottom) G00 Z#18 Retract to initial rapid plane) #101 = #101 + 1 (Step counter) #105 = #105 - #104 (Step current peck approach) #106 = #106 - #104 (Step current peck bottom) GOTO 1 (Go back to test) N99 M99 (End of custom macro) In custom macro B: