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