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