Skip to content
This repository
Browse code

Added pecking as an option, and PEP08

  • Loading branch information...
commit 2b3e7e75848aa819d7fd958193e6df349d73ff2c 1 parent 158d165
hugomatic authored September 07, 2009

Showing 2 changed files with 48 additions and 40 deletions. Show diff stats Hide diff stats

  1. 84  drillcircle.py
  2. 4  index.xml
84  drillcircle.py
@@ -21,7 +21,7 @@
21 21
 # You can contact me at the following email address:
22 22
 # hugo@hugomatic.ca
23 23
 #
24  
-# g81 g83 contributed by Michael Haberler
  24
+# Thanks to Michael Haberler for his g81 g83 contribution
25 25
 #
26 26
 
27 27
 
@@ -43,39 +43,46 @@ def take_a_break():
43 43
 # remember: 1 inch = 25.4 millimeters
44 44
                    
45 45
 params = hugomatic.toolkit.Parameters('Drill Circular holes', 
46  
-                                      'Perform a uniform drill holes around a point using the drilling code g81. If the hole depth is greater than twice the drill diameter,  g83 (drill pecking) is used instead.', 
  46
+                                      'Perform a uniform drill holes around a point using the drilling code g81 or g83.', 
47 47
                                       picture_file="holecircle.gif",
48 48
                                       debug_callback=take_a_break)
49 49
 
50 50
 
51 51
 
52  
-gcodeUnits = 'mm'  
53  
-params.addArgument( gcodeUnits, 'Program units... 1 inch = 25.4 millimeters', choices=('Inches', 'mm'), group='setup')
54  
-
  52
+units = 'mm'  
  53
+params.addArgument( units, 'Program units... 1 inch = 25.4 millimeters', choices=('Inches', 'mm'), group='setup')
  54
+drill_diameter = 3
  55
+params.addArgument(drill_diameter , 'Drill diameter', group="setup")
55 56
 feed = 100
56 57
 params.addArgument(feed , 'Feed rate in units/min', group="setup")
57  
-dwell = 0.1
58  
-params.addArgument(dwell , 'Dwell time or 0 for no dwell', group="setup")
59  
-zSafe = 5
60  
-params.addArgument(zSafe , 'Safe height above work piece', group="setup")
61  
-drillDiameter = 3
62  
-params.addArgument(drillDiameter , 'Drill diameter', group="setup")
63  
-
64  
-
65  
-zDepth = -2
66  
-params.addArgument(zDepth , 'Final depth (negative)')
67  
-centerX = 0.
68  
-params.addArgument(centerX, 'Circle center X')
69  
-centerY = 0.
70  
-params.addArgument(centerY, 'Circle center Y')
  58
+
  59
+
  60
+z_safe = 5
  61
+params.addArgument(z_safe , 'Safe height above work piece', group="height")
  62
+z_rapid = 1.5
  63
+params.addArgument(z_rapid , 'Rapid plane right above work piece where rapid movement stops', group="height")
  64
+z_depth = -2
  65
+params.addArgument(z_depth , 'Final depth (along Z, negative)', group = 'height')
  66
+
  67
+pecking = True
  68
+params.addArgument(pecking , 'Use pecking (multiple up and down to clean the drill flutes)', group = 'peck')
  69
+peck = 6.0
  70
+params.addArgument(peck , 'Peck height (positive) for each drill cut', group="peck")
  71
+
  72
+center_x = 0.
  73
+params.addArgument(center_x, 'Circle center X')
  74
+center_y = 0.
  75
+params.addArgument(center_y, 'Circle center Y')
71 76
 radius = 1.
72 77
 params.addArgument(radius, 'Circle radius')
73  
-startAngle = 0.
74  
-params.addArgument(startAngle, 'Start Angle')
75  
-IncrementAngle = 15.
76  
-params.addArgument(IncrementAngle, 'Increment Angle (angle between operations)')
77  
-holeCount = 6
78  
-params.addArgument(holeCount, 'Hole count')
  78
+start_angle = 0.
  79
+params.addArgument(start_angle, 'Start Angle')
  80
+increment_angle = 15.
  81
+params.addArgument(increment_angle, 'Increment Angle (angle between operations)')
  82
+hole_count = 6
  83
+params.addArgument(hole_count, 'Hole count')
  84
+dwell = 0.1
  85
+params.addArgument(dwell , 'Dwell (pause) time before xy movement or 0 for no dwell')
79 86
 
80 87
 
81 88
 angle = 0.
@@ -84,30 +91,31 @@ def take_a_break():
84 91
 z = 0.
85 92
 
86 93
 
87  
-# if drill depth > maxvertical, switch to G83 peck cycle
88  
-maxvertical = drillDiameter * 2.0
89  
-# retract to drillDiamater above piece every maxvertical feeds
90  
-retractlevel = drillDiameter
  94
+
  95
+# retract to z_rapid above piece every peck feeds
  96
+
91 97
 #
92 98
 # Generation
93 99
 #
94 100
 if params.loadParams():
95  
-    hugomatic.code.header(gcodeUnits, feed)
  101
+    hugomatic.code.header(units, feed)
96 102
     
97  
-    for i in range(holeCount):
98  
-        print "G0 z%.4f" % zSafe
99  
-        angle = startAngle + i * IncrementAngle
  103
+    for i in range(hole_count):
  104
+        print "G0 z%.4f" % z_safe
  105
+        angle = start_angle + i * increment_angle
100 106
         rads = math.radians(angle)
101 107
         x = radius * math.cos(rads)
102 108
         y = radius * math.sin(rads)
103 109
         print
104 110
         print "(hole number %d)" % (i+1)        
105 111
         # use peck drilling if depth > 2 times drill diameter
106  
-        if math.fabs(zDepth) > maxvertical:
107  
-            print "g83 x%(x).4f y%(y).4f z%(zDepth).4f q%(maxvertical).4f r%(retractlevel).4f" % globals()
  112
+        if pecking:
  113
+            print "g83 x%(x).4f y%(y).4f z%(z_depth).4f q%(peck).4f r%(z_rapid).4f" % globals()
108 114
         else:
109  
-            print "g81 x%(x).4f y%(y).4f z%(zDepth).4f" % globals()
110  
-    
111  
-    print    
  115
+            print "G0 z%.4f" % z_rapid
  116
+            print "g81 x%(x).4f y%(y).4f z%(z_depth).4f" % globals()
  117
+        if dwell > 0:
  118
+            print "G4 p%(dwell).4f (Pause to avoid moving while drill is still in the hole)" % globals()
  119
+    print "G0 z%.4f (Done)" % z_safe
112 120
     print hugomatic.code.footer()
113 121
 
4  index.xml
@@ -14,7 +14,7 @@
14 14
   </Primitives>
15 15
  
16 16
  <Tools>
17  
-  <py name="holecircle.py"/>
  17
+  <py name="drillcircle.py"/>
18 18
   <py name="svgEngraver.py"/>
19 19
   <py name="gear.py"/>
20 20
  </Tools>
@@ -31,4 +31,4 @@
31 31
       <py name="gizmoLed.py"/>
32 32
   </project>
33 33
  </Projects>
34  
-<Catalog/><Selected>Tools/svgEngraver.py</Selected></Hugomatic>
  34
+<Catalog/><Selected>Tools/svgEngraver.py</Selected></Hugomatic>

0 notes on commit 2b3e7e7

Please sign in to comment.
Something went wrong with that request. Please try again.