chiark / gitweb /
3b012c797a54ddf68b4156bcff4f38e7c6ae422c
[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 //tongue_w = 11.92 + 0.4;
12
13 usb_w = 12.01 + 0.19;
14 usb_wall_w = 0.51;
15 usb_tongue_d = 8.97 - 0.2;
16 usb_tongue_w_slop = +0.5;
17 usb_wall_h = 4.54 - 2.04;
18 usb_ceil_th = 0.425;
19
20 side_wall_th = 1.5; // XXXX rename wall_th
21
22 board_l = 17.56 + 0.2;
23 board_w = 19.14 + 0.2;
24 board_th = 1.92 + 0.1;
25
26 sw_to_edge = board_w/2 + 0.1;
27
28 front_wall_th = 0.75;
29 // egress_w = 8.0;
30
31 wall_y_min = -board_l - side_wall_th; // XXXX remove
32 ceil_y_min = wall_y_min - 5;;
33
34 small_walls = [
35                [ [0, 0], [-sw_to_edge, -1.0] ],
36                [ [sw_to_edge-4.5, -4.5], [sw_to_edge, -5.7] ],
37 //             [ [3.0, -11.72],              [sw_to_edge, -13.38] ],
38                [ [-sw_to_edge+3.85, -14.90], [sw_to_edge, -13.38] ],
39                ];
40 chip_cutout = [[ -sw_to_edge + 4.20,    -3.75 ],
41                [ -sw_to_edge + 11.95,  -11.90 ]];
42
43 strain_w = 2.0 + 0.5;
44 strain_t = 1.0 + 0.5;
45 strain_pitch_across = 5;
46 strain_pitch_along = 10;
47 strain_groove_d = 2;
48 strain_groove_w = 3;
49
50 cover_strap_c_d_y = 5.5; // from front of board
51 cover_registration_sz_y = 2;
52 cover_registration_sz_z = 3;
53 midbot_registraton_sz_x = 3;
54
55 cable_space_z = 6;
56 cable_dia = 5;
57 bottom_floor_th = 1.5;
58
59 fit_gap_z = 0.5;
60 fit_gap_y = 0.25;
61 side_x_gap = 0.5;
62
63 cover_ceil_th = 0.9;
64
65 cover_strap_sz_x = side_wall_th * 3.5;
66
67 // calculated
68
69 strap_w = strain_w;
70 cover_strap_cutout_z = side_wall_th;
71
72 middle_top_z = usb_wall_h;
73 middle_base_z = -board_th;
74 bottom_base_z = middle_base_z - cable_space_z - bottom_floor_th;;
75
76 front_y_max = front_wall_th;
77 main_y_min = -board_l - side_wall_th;
78
79 strain_0_y_c = main_y_min - strain_w/2;
80 strain_1_y_c = strain_0_y_c - strain_pitch_along;
81 total_y_min = strain_1_y_c - strain_w/2 - side_wall_th;
82
83 bottom_wall_top_z = (middle_top_z + middle_base_z) * 0.5 - fit_gap_z/2;
84 cover_wall_bot_z  = (middle_top_z + middle_base_z) * 0.5 + fit_gap_z/2;
85 cover_top_z  = middle_top_z + cover_ceil_th;
86
87 middle_side_wall_x = +board_w/2 + side_wall_th;
88 total_side_wall_x = middle_side_wall_x + side_wall_th + side_x_gap;
89
90 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
91   - side_wall_th - cover_registration_sz_y/2;
92
93 midbot_registration_sz_y = cover_registration_sz_y;
94 midbot_registration_sz_z = cover_registration_sz_z;
95 midbot_registration_y_min = total_y_min + side_wall_th*2;
96 midbot_registration_y_max = midbot_registration_y_min
97   + midbot_registration_sz_y;
98 midbot_registration_y_around_max = midbot_registration_y_max
99   + side_wall_th*2;
100 midbot_registration_bottom_x = board_w/2 - midbot_registraton_sz_x;
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([ side_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 // XXXX check cable diameter
125 // XXXX need rear strap
126 // XXXX need bottom-to-middle registration
127 module CoverStrapCutouts(){
128   BothSides(){
129     translate([ -total_side_wall_x, -cover_strap_c_d_y, cover_top_z ])
130       cube([ cover_strap_sz_x*2,
131              strap_w,
132              cover_strap_cutout_z*2 ],
133            center=true);
134   }
135 }
136
137 module FrontWallsPlan(slop) {
138   BothSides(){
139     rectfromto([ -board_w/2 - side_wall_th,    0             ],
140                [ -usb_w/2 - slop,              front_wall_th ]);
141   }
142 }
143 module MiddleSmallWallsPlan() {
144   for (m=[0,1]) {
145     mirror([m,0]) {
146       rectfromto([ -usb_w/2,              -0.01        ],
147                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
148     }
149   }
150   FrontWallsPlan(0);
151   for (w=small_walls) {
152     rectfromto(w[0], w[1]);
153   }
154 }
155 module MiddleCeilPlan() {
156   difference(){
157     BothSides(){
158       rectfromto([ -usb_w/2,              -0.01        ],
159                  [ 0.1,                   usb_tongue_d ]);
160       rectfromto([ -board_w/2 - side_wall_th, 0            ],
161                  [ 0.1,                       ceil_y_min   ]);
162     }
163     rectfromto(chip_cutout[0], chip_cutout[1]);
164   }
165 }
166 module MiddleMainWallsPlan() {
167   BothSides(){
168     rectfromto([ -board_w/2 - side_wall_th, 0          ],
169                [ -board_w/2,                wall_y_min ]);
170   }
171   FrontWallsPlan(usb_tongue_w_slop);
172   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
173              [ +board_w/2 + side_wall_th,            total_y_min ]);
174 }
175
176 module RegistrationsMinkowski(){
177   minkowski(){
178     cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
179     children();
180   }
181 }
182 module CoverRegistrations(){
183   linextr_y_xz(cover_registration_c_dy - strap_w/2,
184                cover_registration_c_dy + strap_w/2) {
185     difference(){
186       rectfromto([ -total_side_wall_x,
187                           cover_wall_bot_z - cover_registration_sz_z  ],
188                  [ +total_side_wall_x, cover_top_z ]);
189       hull(){
190         MiddleElevationForCutout();
191         translate([0, -20]) MiddleElevationForCutout();
192       }
193     }
194   }
195 }
196 module MidBotRegistrations(){
197   linextr_y_xz(midbot_registration_y_min,
198                midbot_registration_y_max) {
199     BothSides(){
200       rectfromto([ midbot_registration_bottom_x, middle_base_z + 0.1 ],
201                  [ middle_side_wall_x, middle_base_z
202                         - midbot_registration_sz_z ]);
203     }
204   }
205 }
206
207 module Middle(){ ////toplevel
208   difference(){
209     union(){
210       linextr(0, usb_wall_h)
211         MiddleSmallWallsPlan();
212       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
213         MiddleCeilPlan();
214       linextr(-board_th, usb_wall_h)
215         MiddleMainWallsPlan();
216       BothSides()
217         linextr(cover_wall_bot_z, middle_top_z)
218         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
219                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
220       MidBotRegistrations();
221     }
222
223     for (y_c = [strain_0_y_c, strain_1_y_c]) {
224       for (x_c = [-1,+1] * strain_pitch_across/2) {
225         translate([x_c, y_c, 0])
226           linextr(-20, 20)
227           square([ strain_t, strain_w ], center=true);
228       }
229     }
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   }
235 }
236 module MiddlePrint(){ ////toplevel
237   rotate([180,0,0]) Middle();
238 }
239
240 module MiddleElevationForCutout(){
241     rectfromto([ -(middle_side_wall_x + side_x_gap),
242                     middle_base_z - fit_gap_z ],
243                [ +(middle_side_wall_x + side_x_gap), middle_top_z  ]);
244 }
245 module BottomMainElevation(){
246   difference(){
247     rectfromto([ -total_side_wall_x, bottom_base_z        ],
248                [ +total_side_wall_x, bottom_wall_top_z    ]);
249
250     MiddleElevationForCutout();
251   }
252 }
253 module Bottom(){ ////toplevel
254   difference(){
255     union(){
256       linextr_y_xz(total_y_min, front_y_max)
257         BottomMainElevation();
258     }
259
260     linextr_y_xz(midbot_registration_y_around_max,
261                  front_y_max - side_wall_th)
262       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
263                  [ +board_w/2, 20         ]);
264
265     linextr_y_xz(total_y_min + side_wall_th,
266                  front_y_max - side_wall_th)
267       rectfromto([ -midbot_registration_bottom_x,
268                      bottom_base_z + bottom_floor_th ],
269                  [ +midbot_registration_bottom_x, 20         ]);
270
271     linextr_y_xz(total_y_min - 1,
272                  total_y_min + side_wall_th + 1){
273       translate([ 0, middle_base_z ]){
274         hull(){
275           translate([ 0, -cable_dia/2 ])
276             circle(r = cable_dia/2, $fa = 10, $fs = 1);
277           square([ cable_dia, 0.1 ], center=true);
278         }
279       }
280     }
281     RegistrationsMinkowski()
282       CoverRegistrations();
283     RegistrationsMinkowski()
284       MidBotRegistrations();
285     BottomStrapCutouts(-cover_strap_c_d_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 }