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 cover_strap_sz_x = side_wall_th * 3.5;
59
60 // calculated
61
62 strap_w = strain_w;
63 cover_strap_cutout_z = side_wall_th;
64
65 top_top_z = usb_wall_h;
66 top_base_z = -board_th;
67 bottom_base_z = top_base_z - cable_space_z - bottom_floor_th;;
68
69 front_y_max = front_wall_th;
70 main_y_min = -board_l - side_wall_th;
71
72 strain_0_y_c = main_y_min - strain_w/2;
73 strain_1_y_c = strain_0_y_c - strain_pitch_along;
74 total_y_min = strain_1_y_c - strain_w/2 - side_wall_th;
75
76 bottom_wall_top_z = (top_top_z + top_base_z) * 0.5 - fit_gap_z/2;
77 cover_wall_bot_z  = (top_top_z + top_base_z) * 0.5 + fit_gap_z/2;
78 cover_top_z  = top_top_z + cover_ceil_th;
79
80 top_side_wall_x = +board_w/2 + side_wall_th;
81 total_side_wall_x = top_side_wall_x + side_wall_th + side_x_gap;
82
83 cover_registration_c_dy = -cover_strap_c_d_y - strap_w/2
84   - side_wall_th - cover_registration_sz_y/2;
85
86 module BothSides(){
87   for (m=[0,1]) {
88     mirror([m,0,0]) {
89       children();
90     }
91   }
92 }
93 module StrapCutouts(y_c, z_top, top_sz_x){
94   for (z = [ bottom_base_z, z_top ]) {
95     BothSides(){
96       translate([ -total_side_wall_x, y_c, z_top ])
97         cube([ top_sz_x*2,
98                strap_w,
99                cover_strap_cutout_z*2 ],
100              center=true);
101       translate([ -total_side_wall_x, y_c, bottom_base_z ])
102         rotate([0, -45, 0])
103         cube([ side_wall_th,
104                strap_w,
105                10 ],
106              center=true);
107     }
108   }
109 }
110
111 module CoverStrapCutouts(){
112   StrapCutouts( -cover_strap_c_d_y, cover_top_z, cover_strap_sz_x );
113 }
114
115 module FrontWallsPlan(slop) {
116   BothSides(){
117     rectfromto([ -board_w/2 - side_wall_th,    0             ],
118                [ -usb_w/2 - slop,              front_wall_th ]);
119   }
120 }
121 module TopSmallWallsPlan() {
122   for (m=[0,1]) {
123     mirror([m,0]) {
124       rectfromto([ -usb_w/2,              -0.01        ],
125                  [ -usb_w/2 + usb_wall_w, usb_tongue_d ]);
126     }
127   }
128   FrontWallsPlan(0);
129   for (w=small_walls) {
130     rectfromto(w[0], w[1]);
131   }
132 }
133 module TopCeilPlan() {
134   difference(){
135     BothSides(){
136       rectfromto([ -usb_w/2,              -0.01        ],
137                  [ 0.1,                   usb_tongue_d ]);
138       rectfromto([ -board_w/2 - side_wall_th, 0            ],
139                  [ 0.1,                       ceil_y_min   ]);
140     }
141     rectfromto(chip_cutout[0], chip_cutout[1]);
142   }
143 }
144 module TopMainWallsPlan() {
145   BothSides(){
146     rectfromto([ -board_w/2 - side_wall_th, 0          ],
147                [ -board_w/2,                wall_y_min ]);
148   }
149   FrontWallsPlan(usb_tongue_w_slop);
150   rectfromto([ -board_w/2 - side_wall_th + 0, -      board_l   ],
151              [ +board_w/2 + side_wall_th,            total_y_min ]);
152 }
153
154 module CoverRegistrations(){
155   linextr_y_xz(cover_registration_c_dy - strap_w/2,
156                cover_registration_c_dy + strap_w/2) {
157     difference(){
158       rectfromto([ -total_side_wall_x,
159                           cover_wall_bot_z - cover_registration_sz_z  ],
160                  [ +total_side_wall_x, cover_top_z ]);
161       hull(){
162         TopElevationForCutout();
163         translate([0, -20]) TopElevationForCutout();
164       }
165     }
166   }
167 }
168
169 module Top(){ ////toplevel
170   difference(){
171     union(){
172       linextr(0, usb_wall_h)
173         TopSmallWallsPlan();
174       linextr(usb_wall_h - usb_ceil_th, usb_wall_h)
175         TopCeilPlan();
176       linextr(-board_th, usb_wall_h)
177         TopMainWallsPlan();
178       BothSides()
179         linextr(cover_wall_bot_z, top_top_z)
180         rectfromto([ -(board_w/2 + 0.1),  total_y_min             ],
181                    [ -total_side_wall_x,  main_y_min - fit_gap_y  ]);
182     }
183
184     for (y_c = [strain_0_y_c, strain_1_y_c]) {
185       for (x_c = [-1,+1] * strain_pitch_across/2) {
186         translate([x_c, y_c, 0])
187           linextr(-20, 20)
188           square([ strain_t, strain_w ], center=true);
189       }
190     }
191     linextr_y_xz(total_y_min-1, main_y_min)
192       translate([0, top_base_z])
193       scale([1, strain_groove_d/strain_groove_w])
194       circle(strain_groove_w/2, $fn = 8);
195   }
196 }
197
198 module TopElevationForCutout(){
199     rectfromto([ -(top_side_wall_x + side_x_gap), top_base_z ],
200                [ +(top_side_wall_x + side_x_gap), top_top_z  ]);
201 }
202 module BottomMainElevation(){
203   difference(){
204     rectfromto([ -total_side_wall_x, bottom_base_z        ],
205                [ +total_side_wall_x, bottom_wall_top_z    ]);
206
207     TopElevationForCutout();
208   }
209 }
210 module Bottom(){ ////toplevel
211   difference(){
212     union(){
213       linextr_y_xz(total_y_min, front_y_max)
214         BottomMainElevation();
215     }
216
217     linextr_y_xz(total_y_min + side_wall_th,
218                  front_y_max - side_wall_th)
219       rectfromto([ -board_w/2, bottom_base_z + bottom_floor_th ],
220                  [ +board_w/2, 20         ]);
221
222     linextr_y_xz(total_y_min - 1,
223                  total_y_min + side_wall_th + 1){
224       translate([ 0, top_base_z ]){
225         hull(){
226           translate([ 0, -cable_dia/2 ])
227             circle(r = cable_dia/2, $fa = 10, $fs = 1);
228           square([ cable_dia, 0.1 ], center=true);
229         }
230       }
231     }
232     minkowski(){
233       CoverRegistrations();
234       cube([ 1, fit_gap_y*2, fit_gap_z*2 ], center=true);
235     }
236     CoverStrapCutouts();
237   }
238 }
239
240 module CoverMainElevation(){
241   difference(){
242     rectfromto([ -total_side_wall_x, cover_wall_bot_z        ],
243                [ +total_side_wall_x, cover_top_z    ]);
244
245     TopElevationForCutout();
246   }
247 }
248 module Cover(){ ////toplevel
249   difference(){
250     union(){
251       linextr_y_xz(main_y_min, front_y_max)
252         CoverMainElevation();
253       CoverRegistrations();
254     }
255     CoverStrapCutouts();
256   }
257 }
258
259 module BottomDemo(){ ////toplevel
260   translate([0, 0, -0.25]) Bottom();
261   %Top();
262   translate([0, 0, +0.25]) Cover();
263 }