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