-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
niz.ml
343 lines (325 loc) · 8.06 KB
/
niz.ml
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
open OCADml
open OSCADml
module Bottom = struct
let w = 17.5
let h = 17.5
let thickness = 4.
let bulge_thickness = 0.6
let bulge_length = 6.5
let bulge_height = 3.2
let ellipse_offset = -0.25
let ellipse_x = (w /. 2.) +. ellipse_offset
let ellipse_inset_x_rad = 1.6
let ellipse_inset_y_scale = 1.2
let corner_cut_rad = 3.
let corner_cut_off = 1.
let ellipse =
Scad.scale (v2 1. ellipse_inset_y_scale) (Scad.circle ~fn:32 ellipse_inset_x_rad)
let bulge = Scad.square ~center:true (v2 bulge_length (bulge_thickness +. 0.1))
let cutter = Scad.circle ~fn:64 corner_cut_rad
let corner x_sign y_sign =
let x = (w /. 2.) +. corner_cut_off
and y = (h /. 2.) +. corner_cut_off in
Scad.translate (v2 (x *. x_sign) (y *. y_sign)) cutter
let shadow =
Scad.union
[ Scad.difference
(Scad.square ~center:true (v2 w h))
[ Scad.translate (v2 ellipse_x 0.) ellipse
; Scad.translate (v2 (ellipse_x *. -1.) 0.) ellipse
; corner 1. 1.
; corner 1. (-1.)
; corner (-1.) 1.
; corner (-1.) (-1.)
]
; Scad.ytrans ((h /. 2.) +. (bulge_thickness /. 2.)) bulge
; Scad.ytrans ((h /. -2.) -. (bulge_thickness /. 2.) +. 0.001) bulge
; Scad.ytrans ((h /. 2.) +. (bulge_thickness /. 2.)) bulge
; Scad.ytrans ((h /. -2.) -. (bulge_thickness /. 2.) +. 0.001) bulge
]
let scad =
let bulges =
let b = Scad.extrude ~height:bulge_height bulge in
[ Scad.translate (v3 0. ((h /. 2.) -. 0.1) 0.) b
; Scad.translate (v3 0. ((h /. -2.) +. 0.1) 0.) b
]
in
Scad.difference
(Scad.square ~center:true (v2 w h))
[ Scad.xtrans ellipse_x ellipse
; Scad.xtrans (ellipse_x *. -1.) ellipse
; corner 1. 1.
; corner 1. (-1.)
; corner (-1.) 1.
; corner (-1.) (-1.)
]
|> Scad.extrude ~height:(thickness +. 0.001)
|> fun b -> Scad.union (b :: bulges)
end
module Config = struct
type t =
{ outer_w : float
; outer_h : float
; inner_w : float
; inner_h : float
; thickness : float
; cap_height : float
; cap_cutout_height : float option
; clearance : float
; corner : Path3.Round.corner option
; fn : int option
; dome_w : float
; dome_waist_clip : float
; dome_thickness : float
; base_thickness : float
; sensor_depth : float
; sensor_cutter : Sensor.cutter
}
let make
?(outer_w = 20.5)
?(outer_h = 20.5)
?(inner_w = 14.)
?(inner_h = 14.)
?(thickness = 5.6)
?(cap_height = 6.5)
?(cap_cutout_height = Some 1.5)
?(clearance = 4.)
?corner
?fn
?(dome_w = 19.5)
?(dome_waist_clip = 1.)
?(dome_thickness = 1.6)
?(base_thickness = 3.)
?(sensor_depth = 1.4)
?(sensor_cutter = Sensor.ThroughHole.tape_cutout ())
()
=
{ outer_w
; outer_h
; inner_w
; inner_h
; thickness
; cap_height
; cap_cutout_height
; clearance
; corner
; fn
; dome_w
; dome_waist_clip
; dome_thickness
; base_thickness
; sensor_depth
; sensor_cutter
}
let default = make ()
end
(* Dome thickness
- BKE ~= 0.85mm
- DES ~= 0.70mm
The actual value for [dome_thickness] though must account for FDM overhang
tolerance, thus it should be a good amount higher to ensure reliable fit.
Both BKE and DES domes are roughly ~19x19mm. *)
(* Magnet size, with a sensor depth of 1.4mm (slightly below the thickness of a
standard through-hole sensor package):
- 3x1mm magnets actuate the AH3574 sensor at ~1.16mm travel and are able to
deactivate by the top of the return with Niz rings
- 2x1 magnets actuate the AH3572 sensor at ~2.4mm travel, deactivation
occurs by the top of the return with Niz rings.
- recommended: 2x1 magnet with sensor_depth = 1.4. Easier to attach magnet
size, and should be no worries about hysteresis within FDM and gluing
tolerances with the stock Niz silencing rings. Thinner rings (or no rings)
will increase the travel, so keep that in mind. *)
(* TODO: better magnet / sensor break down notes *)
let hole_of_config
?render
?cap
Config.
{ outer_w
; outer_h
; inner_w
; inner_h
; thickness
; cap_height
; cap_cutout_height
; clearance
; corner
; fn
; dome_w
; dome_waist_clip
; dome_thickness
; base_thickness
; sensor_depth
; sensor_cutter
}
=
let thickness = Float.max thickness (Bottom.thickness +. dome_thickness) in
let clearance = Float.max clearance (base_thickness +. 0.5)
and bottom_z = (thickness /. 2.) -. Bottom.thickness
and bottom_cut = Scad.extrude ~height:(Bottom.thickness *. 2.) Bottom.shadow in
let dome_z = bottom_z -. dome_thickness in
let dome_cut =
let waist_clip sign =
Scad.difference
Bottom.ellipse
[ Scad.square
~center:true
(v2
(dome_waist_clip *. 2.)
(Bottom.ellipse_inset_x_rad *. Bottom.ellipse_inset_y_scale *. 2.) )
|> Scad.translate (v2 (Bottom.ellipse_inset_x_rad *. -.sign) 0.)
]
|> Scad.translate (v2 (Bottom.ellipse_x *. sign) 0.)
in
Scad.difference
(Scad.square ~center:true (v2 dome_w dome_w))
[ waist_clip 1.; waist_clip (-1.) ]
|> Scad.extrude ~height:(dome_thickness +. 0.001)
|> Scad.translate (v3 0. 0. dome_z)
and base =
let slab =
Scad.cube (v3 outer_w outer_h (base_thickness +. 0.001))
|> Scad.translate (v3 (outer_w /. -2.) (outer_h /. -2.) (dome_z -. base_thickness))
in
Scad.difference slab [ sensor_cutter ~z:(dome_z +. 0.01) (sensor_depth +. 0.01) ]
and pillars =
let cyl = Scad.extrude ~height:dome_thickness Bottom.ellipse in
Scad.(
union
[ translate (v3 Bottom.ellipse_x 0. 0.) cyl
; translate (v3 (Bottom.ellipse_x *. -1.) 0. 0.) cyl
]
|> translate (v3 0. 0. (bottom_z -. dome_thickness)))
in
let cutout =
let internals =
Scad.union [ Scad.translate (v3 0. 0. bottom_z) bottom_cut; dome_cut ]
in
match cap_cutout_height with
| Some h ->
Scad.union
[ Scad.ztrans
(2.5 +. h +. (thickness /. 2.))
(Scad.cube ~center:true (v3 20. 20. 7.))
; internals
]
| None -> internals
and clip hole = Scad.union [ base; hole; pillars ] in
Key.(
make
?render
?cap
~cutout
{ outer_w
; outer_h
; inner_w
; inner_h
; thickness
; clip
; cap_height
; clearance
; corner
; fn
})
let make_hole
?render
?cap
?outer_w
?outer_h
?inner_w
?inner_h
?thickness
?cap_height
?cap_cutout_height
?clearance
?corner
?fn
?dome_w
?dome_waist_clip
?dome_thickness
?base_thickness
?sensor_depth
?sensor_cutter
()
=
hole_of_config
?render
?cap
(Config.make
?outer_w
?outer_h
?inner_w
?inner_h
?thickness
?cap_height
?cap_cutout_height
?clearance
?corner
?fn
?dome_w
?dome_waist_clip
?dome_thickness
?base_thickness
?sensor_depth
?sensor_cutter
() )
let empty_hole_of_config
?render
?cap
Config.
{ outer_w
; outer_h
; inner_w
; inner_h
; thickness
; cap_height
; cap_cutout_height
; clearance
; corner
; fn
; _
}
=
Mx.make_hole
?render
?cap
~outer_w
~outer_h
~inner_w
~inner_h
~thickness
~cap_height
~cap_cutout_height
~clearance
?corner
?fn
()
let make_empty_hole
?render
?cap
?outer_w
?outer_h
?inner_w
?inner_h
?thickness
?cap_height
?cap_cutout_height
?clearance
?corner
?fn
()
=
empty_hole_of_config
?render
?cap
(Config.make
?outer_w
?outer_h
?inner_w
?inner_h
?thickness
?cap_height
?cap_cutout_height
?clearance
?corner
?fn
() )