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
54 cable_space_z = 6;
55 cable_dia = 5;
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 = side_wall_th * 3.5;
65
66 // calculated
67
68 strap_w = strain_w;
69 cover_strap_cutout_z = side_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 - side_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 - side_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 + side_wall_th;
87 total_side_wall_x = middle_side_wall_x + side_wall_th + side_x_gap;
88
89 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
90   - side_wall_th - cover_registration_sz_y/2;
91
92 midbot_registration_sz_y = cover_registration_sz_y;
93 midbot_registration_y_min = total_y_min + side_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   + side_wall_th*2;
98
99 module BothSides(){
100   for (m=[0,1]) {
101     mirror([m,0,0]) {
102       children();
103     }
104   }
105 }
106
107 module NormalStrapCutouts(y_c, z, rot){
108   BothSides(){
109     translate([ -total_side_wall_x, y_c, z ])
110       rotate([0, rot, 0])
111       cube([ side_wall_th,
112              strap_w,
113              10 ],
114            center=true);
115   }
116 }
117 module BottomStrapCutouts(y_c){
118   NormalStrapCutouts(y_c, bottom_base_z, -45);
119 }
120 // XXXX check strap width
121 // XXXX check cable diameter
122 // XXXX need rear strap
123 // XXXX need bottom-to-middle registration
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 - side_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 - side_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 - side_wall_th, 0          ],
166                [ -board_w/2,                wall_y_min ]);
167   }
168   FrontWallsPlan(usb_tongue_w_slop);
169   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
170              [ +board_w/2 + side_wall_th,            total_y_min ]);
171 }
172
173 module CoverRegistrations(){
174   linextr_y_xz(cover_registration_c_dy - strap_w/2,
175                cover_registration_c_dy + strap_w/2) {
176     difference(){
177       rectfromto([ -total_side_wall_x,
178                           cover_wall_bot_z - cover_registration_sz_z  ],
179                  [ +total_side_wall_x, cover_top_z ]);
180       hull(){
181         MiddleElevationForCutout();
182         translate([0, -20]) MiddleElevationForCutout();
183       }
184     }
185   }
186 }
187
188 module Middle(){ ////toplevel
189   difference(){
190     union(){
191       linextr(0, usb_wall_h)
192         MiddleSmallWallsPlan();
193       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
194         MiddleCeilPlan();
195       linextr(-board_th, usb_wall_h)
196         MiddleMainWallsPlan();
197       BothSides()
198         linextr(cover_wall_bot_z, middle_top_z)
199         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
200                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
201     }
202
203     for (y_c = [strain_0_y_c, strain_1_y_c]) {
204       for (x_c = [-1,+1] * strain_pitch_across/2) {
205         translate([x_c, y_c, 0])
206           linextr(-20, 20)
207           square([ strain_t, strain_w ], center=true);
208       }
209     }
210     linextr_y_xz(total_y_min-1, main_y_min)
211       translate([0, middle_base_z])
212       scale([1, strain_groove_d/strain_groove_w])
213       circle(strain_groove_w/2, $fn = 8);
214   }
215 }
216 module MiddlePrint(){ ////toplevel
217   rotate([180,0,0]) Middle();
218 }
219
220 module MiddleElevationForCutout(){
221     rectfromto([ -(middle_side_wall_x + side_x_gap), middle_base_z ],
222                [ +(middle_side_wall_x + side_x_gap), middle_top_z  ]);
223 }
224 module BottomMainElevation(){
225   difference(){
226     rectfromto([ -total_side_wall_x, bottom_base_z        ],
227                [ +total_side_wall_x, bottom_wall_top_z    ]);
228
229     MiddleElevationForCutout();
230   }
231 }
232 module Bottom(){ ////toplevel
233   difference(){
234     union(){
235       linextr_y_xz(total_y_min, front_y_max)
236         BottomMainElevation();
237     }
238
239     linextr_y_xz(total_y_min + side_wall_th,
240                  front_y_max - side_wall_th)
241       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
242                  [ +board_w/2, 20         ]);
243
244     linextr_y_xz(total_y_min - 1,
245                  total_y_min + side_wall_th + 1){
246       translate([ 0, middle_base_z ]){
247         hull(){
248           translate([ 0, -cable_dia/2 ])
249             circle(r = cable_dia/2, $fa = 10, $fs = 1);
250           square([ cable_dia, 0.1 ], center=true);
251         }
252       }
253     }
254     minkowski(){
255       CoverRegistrations();
256       cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
257     }
258     BottomStrapCutouts(-cover_strap_c_d_y);
259   }
260 }
261
262 module CoverMainElevation(){
263   difference(){
264     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
265                [ +total_side_wall_x, cover_top_z    ]);
266
267     MiddleElevationForCutout();
268   }
269 }
270 module Cover(){ ////toplevel
271   difference(){
272     union(){
273       linextr_y_xz(main_y_min, front_y_max)
274         CoverMainElevation();
275       CoverRegistrations();
276     }
277     CoverStrapCutouts();
278   }
279 }
280 module CoverPrint(){ ////toplevel
281   rotate([180,0,0]) Cover();
282 }
283
284 module BottomDemo(){ ////toplevel
285   translate([0, 0, -0.25]) Bottom();
286   %Middle();
287   translate([0, 0, +0.25]) Cover();
288 }