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