Presentation is loading. Please wait.

Presentation is loading. Please wait.

5 Generating loops Introduction to looping

Similar presentations


Presentation on theme: "5 Generating loops Introduction to looping"— Presentation transcript:

1 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

2 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

3 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

4 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

5 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

6 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

7 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

8 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

9 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

10 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

11 Comparison To Subprogramming
Anything can change each time through a loop! Angular hole position changes Bolt hole circle

12 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position Z position changes

13 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

14 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

15 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position Z position changes

16 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

17 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

18 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position Z position changes

19 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

20 Multiple pass grooving
Comparison To Subprogramming Multiple pass grooving Z position changes

21 Comparison To Subprogramming
Peck drilling Z positions change

22 Comparison To Subprogramming
Peck drilling Z positions change

23 Comparison To Subprogramming
Peck drilling Z positions change

24 Comparison To Subprogramming
Peck drilling Z positions change

25 Comparison To Subprogramming
Peck drilling Z positions change

26 Comparison To Subprogramming
Peck drilling Z positions change

27 Comparison To Subprogramming
Peck drilling Z positions change

28 Comparison To Subprogramming
Peck drilling Z positions change

29 Comparison To Subprogramming
Peck drilling Z positions change

30 Comparison To Subprogramming
Peck drilling Z positions change

31 Comparison To Subprogramming
Peck drilling Z positions change

32 Comparison To Subprogramming
Peck drilling Z position changes

33 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

34 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

35 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

36 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

37 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

38 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

39 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

40 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

41 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

42 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

43 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

44 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

45 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

46 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!

47 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

48 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

49 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

50 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

51 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

52 Two Times Loops Are Required
Most common 1) When the number of executions changes 2) When redundant commands can be reduced

53 How Many Executions? 8 holes
You must determine how many times the loop is executed Sometimes it’s easy: Bolt circle 8 holes

54 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

55 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

56 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?

57 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 per peck

58 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

59 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

60 How Many Executions? Regardless of how difficult it seems…
Always determine the number of passes “up-front”!

61 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

62 What Changes Each Time? X Y

63 What Changes Each Time? X Y

64 What Changes Each Time? X Y

65 What Changes Each Time? X Y

66 What Changes Each Time? X Y

67 What Changes Each Time? X Y

68 What Changes Each Time? X Y

69 What Changes Each Time? But wait, what is the XY position determined by? The hole’s angular position! X Y

70 What Changes Each Time? cos[ang] * radius sin[ang]* radius

71 What Changes Each Time? Current angle: 45 degrees

72 What Changes Each Time? Current angle: 90 degrees

73 What Changes Each Time? Current angle: 135 degrees

74 What Changes Each Time? Current angle: 180 degrees

75 What Changes Each Time? Current angle: 225 degrees

76 What Changes Each Time? Current angle: 270 degrees

77 What Changes Each Time? Current angle: 315 degrees

78 What Changes Each Time? Current angle: 360 degrees

79 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

80 What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0
As initialized: Number of passes: 3 Peck depth: -3.125 Changing variables: Current appr.: 0.1 Current depth: Change:

81 What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0
2nd peck: As initialized: Number of passes: 3 Peck depth: -3.125 Changing variables: Current appr.: Current depth: Change:

82 What Changes Each Time? Arguments: Hole depth: 3.125 Peck depth: 1.0
3rd peck: As initialized: Number of passes: 3 Peck depth: -3.125 Changing variables: Current appr.: Current depth: Change:

83 What Changes Each Time? Z position GW: 0.25 TW: 0.125 3 passes
Current Z pos: -1.0 (0.0625) Move over amount: [ ] / [3-1]

84 What Changes Each Time? Z position GW: 0.25 2nd pass TW: 0.125
3 passes Current Z pos: (0.0625) Move over amount: [ ] / [3-1]

85 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: [ ] / [3-1]

86 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

87 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

88 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

89 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

90 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

91 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

92 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

93 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

94 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 = # (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:

95 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 = # (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:

96 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 = # (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:

97 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 = # (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:

98 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 = # (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:

99 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 = # (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:

100 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 = # (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:

101 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 = # (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:

102 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 = # (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:

103 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 = # (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:

104 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 = # (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:

105 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 = # (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

106 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 = # (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:

107 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 = # (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:

108 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 = # (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:

109 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 = # (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:

110 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 = # (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:

111 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 = # (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:

112 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 = # (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:

113 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 = # (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)

114 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 = # (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:

115 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 = # (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:

116 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 = # (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:

117 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 = # (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:

118 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 = # (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:

119 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 = # (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:

120 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 = # (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

121 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 = # (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:


Download ppt "5 Generating loops Introduction to looping"

Similar presentations


Ads by Google