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