chiark / gitweb /
digispark-with-cable: midbot_registration 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 //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_y_min = total_y_min + side_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   + side_wall_th*2;
99 midbot_registration_bottom_x = board_w/2 - midbot_registraton_sz_x;
100
101 module BothSides(){
102   for (m=[0,1]) {
103     mirror([m,0,0]) {
104       children();
105     }
106   }
107 }
108
109 module NormalStrapCutouts(y_c, z, rot){
110   BothSides(){
111     translate([ -total_side_wall_x, y_c, z ])
112       rotate([0, rot, 0])
113       cube([ side_wall_th,
114              strap_w,
115              10 ],
116            center=true);
117   }
118 }
119 module BottomStrapCutouts(y_c){
120   NormalStrapCutouts(y_c, bottom_base_z, -45);
121 }
122 // XXXX check strap width
123 // XXXX check cable diameter
124 // XXXX need rear strap
125 // XXXX need bottom-to-middle registration
126 module CoverStrapCutouts(){
127   BothSides(){
128     translate([ -total_side_wall_x, -cover_strap_c_d_y, cover_top_z ])
129       cube([ cover_strap_sz_x*2,
130              strap_w,
131              cover_strap_cutout_z*2 ],
132            center=true);
133   }
134 }
135
136 module FrontWallsPlan(slop) {
137   BothSides(){
138     rectfromto([ -board_w/2 - side_wall_th,    0             ],
139                [ -usb_w/2 - slop,              front_wall_th ]);
140   }
141 }
142 module MiddleSmallWallsPlan() {
143   for (m=[0,1]) {
144     mirror([m,0]) {
145       rectfromto([ -usb_w/2,              -0.01        ],
146                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
147     }
148   }
149   FrontWallsPlan(0);
150   for (w=small_walls) {
151     rectfromto(w[0], w[1]);
152   }
153 }
154 module MiddleCeilPlan() {
155   difference(){
156     BothSides(){
157       rectfromto([ -usb_w/2,              -0.01        ],
158                  [ 0.1,                   usb_tongue_d ]);
159       rectfromto([ -board_w/2 - side_wall_th, 0            ],
160                  [ 0.1,                       ceil_y_min   ]);
161     }
162     rectfromto(chip_cutout[0], chip_cutout[1]);
163   }
164 }
165 module MiddleMainWallsPlan() {
166   BothSides(){
167     rectfromto([ -board_w/2 - side_wall_th, 0          ],
168                [ -board_w/2,                wall_y_min ]);
169   }
170   FrontWallsPlan(usb_tongue_w_slop);
171   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
172              [ +board_w/2 + side_wall_th,            total_y_min ]);
173 }
174
175 module CoverRegistrations(){
176   linextr_y_xz(cover_registration_c_dy - strap_w/2,
177                cover_registration_c_dy + strap_w/2) {
178     difference(){
179       rectfromto([ -total_side_wall_x,
180                           cover_wall_bot_z - cover_registration_sz_z  ],
181                  [ +total_side_wall_x, cover_top_z ]);
182       hull(){
183         MiddleElevationForCutout();
184         translate([0, -20]) MiddleElevationForCutout();
185       }
186     }
187   }
188 }
189
190 module Middle(){ ////toplevel
191   difference(){
192     union(){
193       linextr(0, usb_wall_h)
194         MiddleSmallWallsPlan();
195       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
196         MiddleCeilPlan();
197       linextr(-board_th, usb_wall_h)
198         MiddleMainWallsPlan();
199       BothSides()
200         linextr(cover_wall_bot_z, middle_top_z)
201         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
202                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
203     }
204
205     for (y_c = [strain_0_y_c, strain_1_y_c]) {
206       for (x_c = [-1,+1] * strain_pitch_across/2) {
207         translate([x_c, y_c, 0])
208           linextr(-20, 20)
209           square([ strain_t, strain_w ], center=true);
210       }
211     }
212     linextr_y_xz(total_y_min-1, main_y_min)
213       translate([0, middle_base_z])
214       scale([1, strain_groove_d/strain_groove_w])
215       circle(strain_groove_w/2, $fn = 8);
216   }
217 }
218 module MiddlePrint(){ ////toplevel
219   rotate([180,0,0]) Middle();
220 }
221
222 module MiddleElevationForCutout(){
223     rectfromto([ -(middle_side_wall_x + side_x_gap), middle_base_z ],
224                [ +(middle_side_wall_x + side_x_gap), middle_top_z  ]);
225 }
226 module BottomMainElevation(){
227   difference(){
228     rectfromto([ -total_side_wall_x, bottom_base_z        ],
229                [ +total_side_wall_x, bottom_wall_top_z    ]);
230
231     MiddleElevationForCutout();
232   }
233 }
234 module Bottom(){ ////toplevel
235   difference(){
236     union(){
237       linextr_y_xz(total_y_min, front_y_max)
238         BottomMainElevation();
239     }
240
241     linextr_y_xz(midbot_registration_y_around_max,
242                  front_y_max - side_wall_th)
243       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
244                  [ +board_w/2, 20         ]);
245
246     linextr_y_xz(total_y_min + side_wall_th,
247                  front_y_max - side_wall_th)
248       rectfromto([ -midbot_registration_bottom_x,
249                      bottom_base_z + bottom_floor_th ],
250                  [ +midbot_registration_bottom_x, 20         ]);
251
252     linextr_y_xz(total_y_min - 1,
253                  total_y_min + side_wall_th + 1){
254       translate([ 0, middle_base_z ]){
255         hull(){
256           translate([ 0, -cable_dia/2 ])
257             circle(r = cable_dia/2, $fa = 10, $fs = 1);
258           square([ cable_dia, 0.1 ], center=true);
259         }
260       }
261     }
262     minkowski(){
263       CoverRegistrations();
264       cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
265     }
266     BottomStrapCutouts(-cover_strap_c_d_y);
267   }
268 }
269
270 module CoverMainElevation(){
271   difference(){
272     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
273                [ +total_side_wall_x, cover_top_z    ]);
274
275     MiddleElevationForCutout();
276   }
277 }
278 module Cover(){ ////toplevel
279   difference(){
280     union(){
281       linextr_y_xz(main_y_min, front_y_max)
282         CoverMainElevation();
283       CoverRegistrations();
284     }
285     CoverStrapCutouts();
286   }
287 }
288 module CoverPrint(){ ////toplevel
289   rotate([180,0,0]) Cover();
290 }
291
292 module BottomDemo(){ ////toplevel
293   translate([0, 0, -0.25]) Bottom();
294   %Middle();
295   translate([0, 0, +0.25]) Cover();
296 }