chiark / gitweb /
digispark-with-cable: strap width
[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 = 2.5 + 0.5;
42 strain_t = 1.0 + 0.5;
43 strain_pitch_across = 5;
44 strain_pitch_along = 10;
45 strain_groove_d = 2;
46 strain_groove_w = 4.5;
47
48 cover_strap_c_d_y = 5.5; // from front of board
49 cover_registration_sz_y = 2;
50 cover_registration_sz_z = 3;
51 midbot_registraton_sz_x = 3;
52
53 cable_space_z = 6;
54 cable_dia = 6;
55 bottom_floor_th = 1.5;
56
57 fit_gap_z = 0.5;
58 fit_gap_y = 0.25;
59 side_x_gap = 0.5;
60
61 cover_ceil_th = 0.9;
62
63 cover_strap_sz_x = wall_th * 3.5;
64
65 // calculated
66
67 strap_w = strain_w;
68 cover_strap_cutout_z = wall_th;
69
70 middle_top_z = usb_wall_h;
71 middle_base_z = -board_th;
72 bottom_base_z = middle_base_z - cable_space_z - bottom_floor_th;;
73
74 front_y_max = front_wall_th;
75 main_y_min = -board_l - wall_th;
76
77 strain_0_y_c = main_y_min - strain_w/2;
78 strain_1_y_c = strain_0_y_c - strain_pitch_along;
79 total_y_min = strain_1_y_c - strain_w/2 - wall_th;
80
81 bottom_wall_top_z = (middle_top_z + middle_base_z) * 0.5 - fit_gap_z/2;
82 cover_wall_bot_z  = (middle_top_z + middle_base_z) * 0.5 + fit_gap_z/2;
83 cover_top_z  = middle_top_z + cover_ceil_th;
84
85 middle_side_wall_x = +board_w/2 + wall_th;
86 total_side_wall_x = middle_side_wall_x + wall_th + side_x_gap;
87
88 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
89   - wall_th - cover_registration_sz_y/2;
90
91 midbot_registration_sz_y = cover_registration_sz_y;
92 midbot_registration_sz_z = cover_registration_sz_z;
93 midbot_registration_y_min = total_y_min + wall_th*2;
94 midbot_registration_y_max = midbot_registration_y_min
95   + midbot_registration_sz_y;
96 midbot_registration_y_around_max = midbot_registration_y_max
97   + wall_th*2;
98 midbot_registration_bottom_x = board_w/2 - midbot_registraton_sz_x;
99
100 midbot_strap_c_y = 0.5 * (strain_0_y_c + strain_1_y_c);
101
102 module BothSides(){
103   for (m=[0,1]) {
104     mirror([m,0,0]) {
105       children();
106     }
107   }
108 }
109
110 module NormalStrapCutouts(y_c, z, rot){
111   BothSides(){
112     translate([ -total_side_wall_x, y_c, z ])
113       rotate([0, rot, 0])
114       cube([ wall_th,
115              strap_w,
116              10 ],
117            center=true);
118   }
119 }
120 module BottomStrapCutouts(y_c){
121   NormalStrapCutouts(y_c, bottom_base_z, -45);
122 }
123 // XXXX check strap width
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 Middle(){ ////toplevel
205   difference(){
206     union(){
207       linextr(0, usb_wall_h)
208         MiddleSmallWallsPlan();
209       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
210         MiddleCeilPlan();
211       linextr(-board_th, usb_wall_h)
212         MiddleMainWallsPlan();
213       BothSides()
214         linextr(cover_wall_bot_z, middle_top_z)
215         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
216                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
217       MidBotRegistrations();
218     }
219
220     for (y_c = [strain_0_y_c, strain_1_y_c]) {
221       for (x_c = [-1,+1] * strain_pitch_across/2) {
222         translate([x_c, y_c, 0])
223           linextr(-20, 20)
224           square([ strain_t, strain_w ], center=true);
225       }
226     }
227     linextr_y_xz(total_y_min-1, main_y_min)
228       translate([0, middle_base_z])
229       scale([1, strain_groove_d/strain_groove_w])
230       circle(strain_groove_w/2, $fn = 8);
231     NormalStrapCutouts(midbot_strap_c_y,
232                        middle_top_z, 45);
233   }
234 }
235 module MiddlePrint(){ ////toplevel
236   rotate([180,0,0]) Middle();
237 }
238
239 module MiddleElevationForCutout(){
240     rectfromto([ -(middle_side_wall_x + side_x_gap),
241                     middle_base_z - fit_gap_z ],
242                [ +(middle_side_wall_x + side_x_gap), middle_top_z  ]);
243 }
244 module BottomMainElevation(){
245   difference(){
246     rectfromto([ -total_side_wall_x, bottom_base_z        ],
247                [ +total_side_wall_x, bottom_wall_top_z    ]);
248
249     MiddleElevationForCutout();
250   }
251 }
252 module Bottom(){ ////toplevel
253   difference(){
254     union(){
255       linextr_y_xz(total_y_min, front_y_max)
256         BottomMainElevation();
257     }
258
259     linextr_y_xz(midbot_registration_y_around_max,
260                  front_y_max - wall_th)
261       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
262                  [ +board_w/2, 20         ]);
263
264     linextr_y_xz(total_y_min + wall_th,
265                  front_y_max - wall_th)
266       rectfromto([ -midbot_registration_bottom_x,
267                      bottom_base_z + bottom_floor_th ],
268                  [ +midbot_registration_bottom_x, 20         ]);
269
270     linextr_y_xz(total_y_min - 1,
271                  total_y_min + wall_th + 1){
272       translate([ 0, middle_base_z ]){
273         hull(){
274           translate([ 0, -cable_dia/2 ])
275             circle(r = cable_dia/2, $fa = 10, $fs = 1);
276           square([ cable_dia, 0.1 ], center=true);
277         }
278       }
279     }
280     RegistrationsMinkowski()
281       CoverRegistrations();
282     RegistrationsMinkowski()
283       MidBotRegistrations();
284     BottomStrapCutouts(-cover_strap_c_d_y);
285     BottomStrapCutouts(midbot_strap_c_y);
286   }
287 }
288
289 module CoverMainElevation(){
290   difference(){
291     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
292                [ +total_side_wall_x, cover_top_z    ]);
293
294     MiddleElevationForCutout();
295   }
296 }
297 module Cover(){ ////toplevel
298   difference(){
299     union(){
300       linextr_y_xz(main_y_min, front_y_max)
301         CoverMainElevation();
302       CoverRegistrations();
303     }
304     CoverStrapCutouts();
305   }
306 }
307 module CoverPrint(){ ////toplevel
308   rotate([180,0,0]) Cover();
309 }
310
311 module BottomDemo(){ ////toplevel
312   translate([0, 0, -0.25]) Bottom();
313   %Middle();
314   translate([0, 0, +0.25]) Cover();
315 }