chiark / gitweb /
digispark-with-cable: wip progress
[reprap-play.git] / digispark-with-cable.scad
1 // -*- C -*-
2
3 include <utils.scad>
4
5 //tongue_w = 11.92 + 0.4;
6
7 usb_w = 12.01 + 0.19;
8 usb_wall_w = 0.51;
9 usb_tongue_d = 8.97 - 0.2;
10 usb_tongue_w_slop = +0.5;
11 usb_wall_h = 4.54 - 2.04;
12 usb_ceil_th = 0.425;
13
14 side_wall_th = 1.5; // XXXX rename wall_th
15
16 board_l = 17.56 + 0.2;
17 board_w = 19.14 + 0.2;
18 board_th = 1.92 + 0.1;
19
20 sw_to_edge = board_w/2 + 0.1;
21
22 front_wall_th = 0.75;
23 // egress_w = 8.0;
24
25 wall_y_min = -board_l - side_wall_th; // XXXX remove
26 ceil_y_min = wall_y_min - 5;;
27
28 small_walls = [
29                [ [0, 0], [-sw_to_edge, -1.0] ],
30                [ [sw_to_edge-4.5, -4.5], [sw_to_edge, -5.7] ],
31 //             [ [3.0, -11.72],              [sw_to_edge, -13.38] ],
32                [ [-sw_to_edge+3.85, -14.90], [sw_to_edge, -13.38] ],
33                ];
34 chip_cutout = [[ -sw_to_edge + 4.20,    -3.75 ],
35                [ -sw_to_edge + 11.95,  -11.90 ]];
36
37 strain_w = 2.0 + 0.5;
38 strain_t = 1.0 + 0.5;
39 strain_pitch_across = 5;
40 strain_pitch_along = 10;
41 strain_groove_d = 2;
42 strain_groove_w = 3;
43
44 cover_strap_c_d_y = 5.5; // from front of board
45 cover_registration_sz_y = 2;
46 cover_registration_sz_z = 3;
47
48 cable_space_z = 6;
49 cable_dia = 5;
50 bottom_floor_th = 1.5;
51
52 fit_gap_z = 0.5;
53 fit_gap_y = 0.25;
54 side_x_gap = 0.5;
55
56 cover_ceil_th = 0.9;
57
58 // calculated
59
60 strap_w = strain_w;
61 strap_cutout_x = side_wall_th * 2;
62 strap_cutout_z = side_wall_th;
63
64 top_top_z = usb_wall_h;
65 top_base_z = -board_th;
66 bottom_base_z = top_base_z - cable_space_z - bottom_floor_th;;
67
68 front_y_max = front_wall_th;
69 main_y_min = -board_l - side_wall_th;
70
71 strain_0_y_c = main_y_min - strain_w/2;
72 strain_1_y_c = strain_0_y_c - strain_pitch_along;
73 total_y_min = strain_1_y_c - strain_w/2 - side_wall_th;
74
75 bottom_wall_top_z = (top_top_z + top_base_z) * 0.5 - fit_gap_z/2;
76 cover_wall_bot_z  = (top_top_z + top_base_z) * 0.5 + fit_gap_z/2;
77 cover_top_z  = top_top_z + cover_ceil_th;
78
79 top_side_wall_x = +board_w/2 + side_wall_th;
80 total_side_wall_x = top_side_wall_x + side_wall_th + side_x_gap;
81
82 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
83   - side_wall_th - cover_registration_sz_y/2;
84
85 module BothSides(){
86   for (m=[0,1]) {
87     mirror([m,0,0]) {
88       children();
89     }
90   }
91 }
92 module StrapCutouts(y_c, z_top){
93   for (z = [ bottom_base_z, z_top ]) {
94     BothSides(){
95       translate([ -total_side_wall_x, y_c, z_top ]) {
96         cube([ strap_cutout_x*2,
97                strap_w,
98                strap_cutout_z*2 ],
99              center=true);
100       }
101     }
102   }
103 }
104
105 module CoverStrapCutouts(){
106   StrapCutouts( -cover_strap_c_d_y, cover_top_z );
107 }
108
109 module FrontWallsPlan(slop) {
110   BothSides(){
111     rectfromto([ -board_w/2 - side_wall_th,    0             ],
112                [ -usb_w/2 - slop,              front_wall_th ]);
113   }
114 }
115 module TopSmallWallsPlan() {
116   for (m=[0,1]) {
117     mirror([m,0]) {
118       rectfromto([ -usb_w/2,              -0.01        ],
119                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
120     }
121   }
122   FrontWallsPlan(0);
123   for (w=small_walls) {
124     rectfromto(w[0], w[1]);
125   }
126 }
127 module TopCeilPlan() {
128   difference(){
129     BothSides(){
130       rectfromto([ -usb_w/2,              -0.01        ],
131                  [ 0.1,                   usb_tongue_d ]);
132       rectfromto([ -board_w/2 - side_wall_th, 0            ],
133                  [ 0.1,                       ceil_y_min   ]);
134     }
135     rectfromto(chip_cutout[0], chip_cutout[1]);
136   }
137 }
138 module TopMainWallsPlan() {
139   BothSides(){
140     rectfromto([ -board_w/2 - side_wall_th, 0          ],
141                [ -board_w/2,                wall_y_min ]);
142   }
143   FrontWallsPlan(usb_tongue_w_slop);
144   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
145              [ +board_w/2 + side_wall_th,            total_y_min ]);
146 }
147
148 module CoverRegistrations(){
149   linextr_y_xz(cover_registration_c_dy - strap_w/2,
150                cover_registration_c_dy + strap_w/2) {
151     difference(){
152       rectfromto([ -total_side_wall_x,
153                           cover_wall_bot_z - cover_registration_sz_z  ],
154                  [ +total_side_wall_x, cover_top_z ]);
155       hull(){
156         TopElevationForCutout();
157         translate([0, -20]) TopElevationForCutout();
158       }
159     }
160   }
161 }
162
163 module Top(){ ////toplevel
164   difference(){
165     union(){
166       linextr(0, usb_wall_h)
167         TopSmallWallsPlan();
168       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
169         TopCeilPlan();
170       linextr(-board_th, usb_wall_h)
171         TopMainWallsPlan();
172       BothSides()
173         linextr(cover_wall_bot_z, top_top_z)
174         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
175                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
176     }
177
178     for (y_c = [strain_0_y_c, strain_1_y_c]) {
179       for (x_c = [-1,+1] * strain_pitch_across/2) {
180         translate([x_c, y_c, 0])
181           linextr(-20, 20)
182           square([ strain_t, strain_w ], center=true);
183       }
184     }
185     linextr_y_xz(total_y_min-1, main_y_min)
186       translate([0, top_base_z])
187       scale([1, strain_groove_d/strain_groove_w])
188       circle(strain_groove_w/2, $fn = 8);
189   }
190 }
191
192 module TopElevationForCutout(){
193     rectfromto([ -(top_side_wall_x + side_x_gap), top_base_z ],
194                [ +(top_side_wall_x + side_x_gap), top_top_z  ]);
195 }
196 module BottomMainElevation(){
197   difference(){
198     rectfromto([ -total_side_wall_x, bottom_base_z        ],
199                [ +total_side_wall_x, bottom_wall_top_z    ]);
200
201     TopElevationForCutout();
202   }
203 }
204 module Bottom(){ ////toplevel
205   difference(){
206     union(){
207       linextr_y_xz(total_y_min, front_y_max)
208         BottomMainElevation();
209     }
210
211     linextr_y_xz(total_y_min + side_wall_th,
212                  front_y_max - side_wall_th)
213       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
214                  [ +board_w/2, 20         ]);
215
216     linextr_y_xz(total_y_min - 1,
217                  total_y_min + side_wall_th + 1){
218       translate([ 0, top_base_z ]){
219         hull(){
220           translate([ 0, -cable_dia/2 ])
221             circle(r = cable_dia/2, $fa = 10, $fs = 1);
222           square([ cable_dia, 0.1 ], center=true);
223         }
224       }
225     }
226     minkowski(){
227       CoverRegistrations();
228       cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
229     }
230   }
231 }
232
233 module CoverMainElevation(){
234   difference(){
235     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
236                [ +total_side_wall_x, cover_top_z    ]);
237
238     TopElevationForCutout();
239   }
240 }
241 module Cover(){ ////toplevel
242   difference(){
243     union(){
244       linextr_y_xz(main_y_min, front_y_max)
245         CoverMainElevation();
246       CoverRegistrations();
247     }
248     CoverStrapCutouts();
249   }
250 }
251
252 module BottomDemo(){ ////toplevel
253   translate([0, 0, -0.25]) Bottom();
254   %Top();
255   translate([0, 0, +0.25]) Cover();
256 }