chiark / gitweb /
air-hockey-puck: wip
[reprap-play.git] / digispark-with-cable.scad
1 // -*- C -*-
2 //
3 // Print (fine detail settings):
4 //
5 //   * Bottom
6 //   * MiddlePrint
7 //   * CoverPrint
8
9 include <utils.scad>
10
11 usb_w = 12.01 + 0.19;
12 usb_wall_w = 0.51;
13 usb_tongue_d = 8.97 - 0.2;
14 usb_tongue_w_slop = +0.5;
15 usb_wall_h = 4.54 - 2.04;
16 usb_ceil_th = 0.425;
17
18 wall_th = 1.5; // XXXX rename wall_th
19
20 board_l = 17.56 + 0.2;
21 board_w = 19.14 + 0.2;
22 board_th = 1.92 + 0.1;
23
24 sw_to_edge = board_w/2 + 0.1;
25
26 front_wall_th = 0.75;
27 // egress_w = 8.0;
28
29 wall_y_min = -board_l - wall_th;
30 ceil_y_min = wall_y_min - 5;;
31
32 small_walls = [
33                [ [0, 0], [-sw_to_edge, -1.0] ],
34                [ [sw_to_edge-4.5, -4.5], [sw_to_edge, -5.7] ],
35 //             [ [3.0, -11.72],              [sw_to_edge, -13.38] ],
36                [ [-sw_to_edge+3.85, -14.90], [sw_to_edge, -13.38] ],
37                ];
38 chip_cutout = [[ -sw_to_edge + 4.20,    -3.75 ],
39                [ -sw_to_edge + 11.95,  -11.90 ]];
40
41 strain_w = 3.5 + 0.5;
42 strain_t = 1.5 + 0.5;
43 strain_pitch_across = 5;
44 strain_pitch_along = 10;
45 strain_groove_d = 2;
46 strain_groove_w = 4.5;
47 strain_around = [2.25, 2.00];
48
49 cover_strap_c_d_y = 5.5; // from front of board
50 cover_registration_sz_y = 2;
51 cover_registration_sz_z = 3;
52 midbot_registraton_sz_x = 3;
53
54 cable_space_z = 6;
55 cable_dia = 6;
56 bottom_floor_th = 1.5;
57
58 fit_gap_z = 0.5;
59 fit_gap_y = 0.25;
60 side_x_gap = 0.5;
61
62 cover_ceil_th = 0.9;
63
64 cover_strap_sz_x = wall_th * 3.5;
65
66 // calculated
67
68 strap_w = strain_w;
69 cover_strap_cutout_z = wall_th;
70
71 middle_top_z = usb_wall_h;
72 middle_base_z = -board_th;
73 bottom_base_z = middle_base_z - cable_space_z - bottom_floor_th;;
74
75 front_y_max = front_wall_th;
76 main_y_min = -board_l - wall_th;
77
78 strain_0_y_c = main_y_min - strain_w/2;
79 strain_1_y_c = strain_0_y_c - strain_pitch_along;
80 total_y_min = strain_1_y_c - strain_w/2 - wall_th;
81
82 bottom_wall_top_z = (middle_top_z + middle_base_z) * 0.5 - fit_gap_z/2;
83 cover_wall_bot_z  = (middle_top_z + middle_base_z) * 0.5 + fit_gap_z/2;
84 cover_top_z  = middle_top_z + cover_ceil_th;
85
86 middle_side_wall_x = +board_w/2 + wall_th;
87 total_side_wall_x = middle_side_wall_x + wall_th + side_x_gap;
88
89 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
90   - wall_th - cover_registration_sz_y/2;
91
92 midbot_registration_sz_y = cover_registration_sz_y;
93 midbot_registration_sz_z = cover_registration_sz_z;
94 midbot_registration_y_min = total_y_min + wall_th*2;
95 midbot_registration_y_max = midbot_registration_y_min
96   + midbot_registration_sz_y;
97 midbot_registration_y_around_max = midbot_registration_y_max
98   + wall_th*2;
99 midbot_registration_bottom_x = board_w/2 - midbot_registraton_sz_x;
100
101 midbot_strap_c_y = 0.5 * (strain_0_y_c + strain_1_y_c);
102
103 module BothSides(){
104   for (m=[0,1]) {
105     mirror([m,0,0]) {
106       children();
107     }
108   }
109 }
110
111 module NormalStrapCutouts(y_c, z, rot){
112   BothSides(){
113     translate([ -total_side_wall_x, y_c, z ])
114       rotate([0, rot, 0])
115       cube([ wall_th,
116              strap_w,
117              10 ],
118            center=true);
119   }
120 }
121 module BottomStrapCutouts(y_c){
122   NormalStrapCutouts(y_c, bottom_base_z, -45);
123 }
124 module CoverStrapCutouts(){
125   BothSides(){
126     translate([ -total_side_wall_x, -cover_strap_c_d_y, cover_top_z ])
127       cube([ cover_strap_sz_x*2,
128              strap_w,
129              cover_strap_cutout_z*2 ],
130            center=true);
131   }
132 }
133
134 module FrontWallsPlan(slop) {
135   BothSides(){
136     rectfromto([ -board_w/2 - wall_th,    0             ],
137                [ -usb_w/2 - slop,         front_wall_th ]);
138   }
139 }
140 module MiddleSmallWallsPlan() {
141   for (m=[0,1]) {
142     mirror([m,0]) {
143       rectfromto([ -usb_w/2,              -0.01        ],
144                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
145     }
146   }
147   FrontWallsPlan(0);
148   for (w=small_walls) {
149     rectfromto(w[0], w[1]);
150   }
151 }
152 module MiddleCeilPlan() {
153   difference(){
154     BothSides(){
155       rectfromto([ -usb_w/2,              -0.01        ],
156                  [ 0.1,                   usb_tongue_d ]);
157       rectfromto([ -board_w/2 - wall_th, 0            ],
158                  [ 0.1,                  ceil_y_min   ]);
159     }
160     rectfromto(chip_cutout[0], chip_cutout[1]);
161   }
162 }
163 module MiddleMainWallsPlan() {
164   BothSides(){
165     rectfromto([ -board_w/2 - wall_th, 0          ],
166                [ -board_w/2,           wall_y_min ]);
167   }
168   FrontWallsPlan(usb_tongue_w_slop);
169   rectfromto([ -board_w/2 - wall_th + 0, -      board_l   ],
170              [ +board_w/2 + wall_th,            total_y_min ]);
171 }
172
173 module RegistrationsMinkowski(){
174   minkowski(){
175     cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
176     children();
177   }
178 }
179 module CoverRegistrations(){
180   linextr_y_xz(cover_registration_c_dy - strap_w/2,
181                cover_registration_c_dy + strap_w/2) {
182     difference(){
183       rectfromto([ -total_side_wall_x,
184                           cover_wall_bot_z - cover_registration_sz_z  ],
185                  [ +total_side_wall_x, cover_top_z ]);
186       hull(){
187         MiddleElevationForCutout();
188         translate([0, -20]) MiddleElevationForCutout();
189       }
190     }
191   }
192 }
193 module MidBotRegistrations(){
194   linextr_y_xz(midbot_registration_y_min,
195                midbot_registration_y_max) {
196     BothSides(){
197       rectfromto([ midbot_registration_bottom_x, middle_base_z + 0.1 ],
198                  [ middle_side_wall_x, middle_base_z
199                         - midbot_registration_sz_z ]);
200     }
201   }
202 }
203
204 module MiddleStrainHoles(){
205   BothSides(){
206     for (y_c = [strain_0_y_c, strain_1_y_c]) {
207       translate([strain_pitch_across/2, y_c, 0])
208         square([ strain_t, strain_w ], center=true);
209     }
210   }
211 }
212 module Middle(){ ////toplevel
213   difference(){
214     union(){
215       linextr(0, usb_wall_h)
216         MiddleSmallWallsPlan();
217       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
218         MiddleCeilPlan();
219       linextr(-board_th, usb_wall_h)
220         MiddleMainWallsPlan();
221       BothSides()
222         linextr(cover_wall_bot_z, middle_top_z)
223         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
224                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
225       MidBotRegistrations();
226     }
227
228     linextr(-20, 20)
229       MiddleStrainHoles();
230     linextr_y_xz(total_y_min-1, main_y_min)
231       translate([0, middle_base_z])
232       scale([1, strain_groove_d/strain_groove_w])
233       circle(strain_groove_w/2, $fn = 8);
234     NormalStrapCutouts(midbot_strap_c_y,
235                        middle_top_z, 45);
236   }
237 }
238 module MiddlePrint(){ ////toplevel
239   rotate([180,0,0]) Middle();
240 }
241
242 module MiddleElevationForCutout(){
243     rectfromto([ -(middle_side_wall_x + side_x_gap),
244                     middle_base_z - fit_gap_z ],
245                [ +(middle_side_wall_x + side_x_gap), middle_top_z  ]);
246 }
247 module BottomMainElevation(){
248   difference(){
249     rectfromto([ -total_side_wall_x, bottom_base_z        ],
250                [ +total_side_wall_x, bottom_wall_top_z    ]);
251
252     MiddleElevationForCutout();
253   }
254 }
255 module Bottom(){ ////toplevel
256   difference(){
257     union(){
258       linextr_y_xz(total_y_min, front_y_max)
259         BottomMainElevation();
260     }
261
262     linextr_y_xz(midbot_registration_y_around_max,
263                  front_y_max - wall_th)
264       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
265                  [ +board_w/2, 20         ]);
266
267     linextr_y_xz(total_y_min + wall_th,
268                  front_y_max - wall_th)
269       rectfromto([ -midbot_registration_bottom_x,
270                      bottom_base_z + bottom_floor_th ],
271                  [ +midbot_registration_bottom_x, 20         ]);
272
273     linextr_y_xz(total_y_min - 1,
274                  total_y_min + wall_th + 1){
275       translate([ 0, middle_base_z ]){
276         hull(){
277           translate([ 0, -cable_dia/2 ])
278             circle(r = cable_dia/2, $fa = 10, $fs = 1);
279           square([ cable_dia, 0.1 ], center=true);
280         }
281       }
282     }
283     RegistrationsMinkowski()
284       CoverRegistrations();
285     RegistrationsMinkowski()
286       MidBotRegistrations();
287     BottomStrapCutouts(-cover_strap_c_d_y);
288     BottomStrapCutouts(midbot_strap_c_y);
289   }
290 }
291
292 module CoverMainElevation(){
293   difference(){
294     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
295                [ +total_side_wall_x, cover_top_z    ]);
296
297     MiddleElevationForCutout();
298   }
299 }
300 module Cover(){ ////toplevel
301   difference(){
302     union(){
303       linextr_y_xz(main_y_min, front_y_max)
304         CoverMainElevation();
305       CoverRegistrations();
306     }
307     CoverStrapCutouts();
308     linextr(-20,20) {
309       minkowski(){
310         square(strain_around * 2, center=true);
311         hull() MiddleStrainHoles();
312       }
313     }
314   }
315 }
316 module CoverPrint(){ ////toplevel
317   rotate([180,0,0]) Cover();
318 }
319
320 module BottomDemo(){ ////toplevel
321   translate([0, 0, -0.25]) Bottom();
322   %Middle();
323   translate([0, 0, +0.25]) Cover();
324 }
325 module ImpressionDemo(){ ////toplevel
326   color("black") translate([0, 0, -0.25]) Bottom();
327   %Middle();
328   %translate([0, 0, +0.25]) Cover();
329 }