forked from jcrocholl/25000
-
Notifications
You must be signed in to change notification settings - Fork 5
/
clover.py
executable file
·167 lines (137 loc) · 4.13 KB
/
clover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python
from math import *
import sys
def rotate(x, y, degrees):
c = cos(pi * degrees / 180.0)
s = sin(pi * degrees / 180.0)
return x * c + y * s, y * c - x * s
def move(verb, **kwargs):
keys = kwargs.keys()
keys.sort()
words = [verb.upper()]
for key in keys:
words.append('%s%g' % (key.upper(), kwargs[key]))
print ' '.join(words)
def travel(**kwargs): move('G0', **kwargs)
def linear(**kwargs): move('G1', **kwargs)
def clockwise(**kwargs): move('G2', **kwargs)
def up(): travel(z=8)
def down(): linear(z=-2)
def jump(**kwargs):
up()
travel(**kwargs)
down()
frame_width = 200
frame_height = 75
drill = 1.6 # 1/16 inch radius.
extrusion = 15
motor_screw_grid = 31
motor_cutout_diameter = 22
motor_width = 42.2
motor_offset = 35 # Motor face to extrusion.
motor_side, motor_bend = rotate(0, motor_offset + extrusion, 30)
motor_side += extrusion/2
motor_side += extrusion/cos(pi/6)
mc = motor_cutout_diameter/2 + drill
#nema23 = 47.14 # Mounting screws center-to-center
clover = 6
thickness = 0.0478 * 25.4 # 18 gauge steel.
enable_perimeter = False
print >> sys.stderr, 'thickness', thickness
print >> sys.stderr, 'motor_bend', motor_bend
print >> sys.stderr, 'motor_side', motor_side
print >> sys.stderr, 'mc', mc
print >> sys.stderr, 'extrusion-to-extrusion', frame_width
print >> sys.stderr, 'edge-to-edge', frame_width + 2*extrusion
xa = motor_side - drill # Outside wings start
xb = motor_side + motor_bend + drill
xs1 = xa + extrusion/2 # Extrusion screws
xs2 = xb - extrusion/2
# xe = frame_width/2 # Extrusion corner
xt = motor_width/2
xms = motor_screw_grid/sqrt(2)
xgs = 19
ya = frame_height/2 + drill # Top without flange
yb = frame_height/2 + drill - extrusion
ys = frame_height/2 - extrusion/2 # Extrusion screws
yt = motor_width/2
yt2 = yt + 4
yms = xms
ygs = xgs
s2 = sqrt(2)
print 'G17 ; Select XY plane for arcs'
print 'G90 ; Absolute coordinates'
move('G92', x=0, y=0, z=0)
linear(x=0, y=0, z=0)
print '; Gasket screw holes'
for x in (-xgs, xgs):
for y in (-x, x):
jump(x=x, y=y)
# clockwise(i=1)
if enable_perimeter:
print '; Horizontal extrusion screw holes'
for x in (xs1, xs2):
jump(x=x, y=ys)
for x in (xs2, xs1, -xs1, -xs2):
jump(x=x, y=-ys)
for x in (-xs2, -xs1):
jump(x=x, y=ys)
#print '; 22mm dia cutout for reference'
#jump(x=0, y=11)
#clockwise(j=-11)
#print '; NEMA17 square for reference'
#jump(x=0, y=yt*s2)
#linear(x=xt*s2, y=0)
#linear(x=0, y=-yt*s2)
#linear(x=-xt*s2, y=0)
#linear(x=0, y=yt*s2)
def clovercut(z):
up()
travel(x=-clover+1, y=yms-clover-1)
linear(z=z)
print '; Motor cutout clover leaf'
linear(x=-clover, y=yms-clover)
clockwise(x=clover, i=clover, j=clover)
#clockwise(x=xms-clover, y=clover, r=mc)
linear(x=xms-clover, y=clover, r=mc)
clockwise(y=-clover, i=clover, j=-clover)
#clockwise(x=clover, y=-yms+clover, r=mc)
linear(x=clover, y=-yms+clover, r=mc)
clockwise(x=-clover, i=-clover, j=-clover)
#clockwise(x=-xms+clover, y=-clover, r=mc)
linear(x=-xms+clover, y=-clover, r=mc)
clockwise(y=clover, i=-clover, j=clover)
#clockwise(x=-clover, y=yms-clover, r=mc)
linear(x=-clover, y=yms-clover, r=mc)
linear(x=-clover+1, y=yms-clover+1)
for z in (-1, -2.5):
clovercut(z)
def perimeter(z):
up()
travel(x=xa, y=yb)
linear(z=z)
print '; Right wing (outside horizontal extrusions)'
clockwise(x=xa+extrusion, y=ya, i=extrusion)
linear(x=xb)
linear(y=-ya)
linear(x=xa+extrusion)
clockwise(x=xa, y=-yb, j=extrusion)
print '; Extrusion pass-through and motor mounting plate'
linear(x=xa-20)
clockwise(x=-xa+20, i=-xa+20, j=yb)
linear(x=-xa, y=-yb)
print '; Left wing (outside horizontal extrusions)'
clockwise(x=-xa-extrusion, y=-ya, i=-extrusion)
linear(x=-xb)
linear(y=ya)
linear(x=-xa-extrusion)
clockwise(x=-xa, y=yb, j=-extrusion)
print '; Extrusion pass-through and motor mounting plate'
linear(x=-xa+20)
clockwise(x=xa-20, i=xa-20, j=-yb)
linear(x=xa, y=yb)
if enable_perimeter:
for z in (-1, -2.5):
perimeter(z)
print '; All done'
up()