paul@22 | 1 | /* |
paul@22 | 2 | Copyright (C) 2014 Paul Boddie |
paul@22 | 3 | |
paul@22 | 4 | This program is free software; you can redistribute it and/or modify it under |
paul@22 | 5 | the terms of the GNU General Public License as published by the Free Software |
paul@22 | 6 | Foundation; either version 3 of the License, or (at your option) any later |
paul@22 | 7 | version. |
paul@22 | 8 | |
paul@22 | 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@22 | 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
paul@22 | 11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
paul@22 | 12 | more details. |
paul@22 | 13 | |
paul@22 | 14 | You should have received a copy of the GNU General Public License along with |
paul@22 | 15 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@22 | 16 | */ |
paul@22 | 17 | |
paul@0 | 18 | module cartridge() |
paul@0 | 19 | { |
paul@0 | 20 | $fn = 50; |
paul@0 | 21 | |
paul@41 | 22 | /* Configure the generated shapes. */ |
paul@41 | 23 | |
paul@41 | 24 | BACK_CAVITY = 1; |
paul@41 | 25 | FRONT_LABEL_INSET = 1; |
paul@41 | 26 | TOP_LABEL_INSET = 1; |
paul@41 | 27 | GROOVE = 1; |
paul@41 | 28 | |
paul@45 | 29 | /* |
paul@45 | 30 | Options for checking. Some useful combinations... |
paul@45 | 31 | |
paul@45 | 32 | Check feature alignment: APART = 0; BACK_SURFACE = 0; FRONT_SURFACE = 0; |
paul@45 | 33 | Check PCB alignment: PCB = 1; BACK_SURFACE = 0; |
paul@45 | 34 | */ |
paul@45 | 35 | |
paul@43 | 36 | BACK = 1; BACK_SURFACE = 1; |
paul@43 | 37 | FRONT = 1; FRONT_SURFACE = 1; |
paul@45 | 38 | |
paul@45 | 39 | /* For printing: APART = 1; PCB = 0; */ |
paul@45 | 40 | |
paul@43 | 41 | APART = 1; |
paul@45 | 42 | PCB = 0; |
paul@43 | 43 | |
paul@22 | 44 | /* |
paul@22 | 45 | Rounding/fillet radius and additional margin of subtracted |
paul@22 | 46 | material. The additional margin helps avoid geometry problems. |
paul@22 | 47 | */ |
paul@3 | 48 | |
paul@23 | 49 | rr = 2; |
paul@3 | 50 | ro = rr; |
paul@3 | 51 | extra = 0.1; |
paul@3 | 52 | |
paul@0 | 53 | module fillet(r, h) { |
paul@0 | 54 | translate([0, 0, -h/2]) |
paul@0 | 55 | difference() { |
paul@12 | 56 | cube([r + extra, r + extra, h + extra]); |
paul@0 | 57 | cylinder(r = r, h = h); |
paul@0 | 58 | } |
paul@0 | 59 | } |
paul@0 | 60 | |
paul@20 | 61 | /* |
paul@21 | 62 | Justify an object of the given dimensions, according to the given |
paul@21 | 63 | factors (where 1 indicates moving the object to the positive side of an |
paul@21 | 64 | axis, and -1 indicates moving it to the negative side of an axis). |
paul@21 | 65 | |
paul@21 | 66 | NOTE: child should eventually be replaced by children. |
paul@21 | 67 | */ |
paul@21 | 68 | module justify(width, depth, height, wdir, ddir, hdir) { |
paul@21 | 69 | translate([ |
paul@21 | 70 | wdir * width / 2, |
paul@21 | 71 | ddir * depth / 2, |
paul@21 | 72 | hdir * height / 2]) |
paul@21 | 73 | child(); |
paul@21 | 74 | } |
paul@21 | 75 | |
paul@21 | 76 | /* |
paul@20 | 77 | Make a cuboid of the given dimensions, justifying it according to the given |
paul@21 | 78 | factors, and moving it to the specified coordinates. |
paul@21 | 79 | |
paul@21 | 80 | NOTE: Usage of justify within this module will not work due to recursion |
paul@21 | 81 | NOTE: limitations in openscad, potentially removed in more recent |
paul@21 | 82 | NOTE: releases. Thus, the justify transform is merged in here. |
paul@20 | 83 | */ |
paul@20 | 84 | module cube_at(width, depth, height, wdir, ddir, hdir, x, y, z) { |
paul@20 | 85 | translate([ |
paul@20 | 86 | x + wdir * width / 2, |
paul@20 | 87 | y + ddir * depth / 2, |
paul@20 | 88 | z + hdir * height / 2]) |
paul@20 | 89 | cube([width, depth, height], center = true); |
paul@20 | 90 | } |
paul@20 | 91 | |
paul@38 | 92 | /* Internal dimensions. */ |
paul@0 | 93 | |
paul@38 | 94 | int_width = 86.0; |
paul@38 | 95 | int_depth = 11.0; |
paul@42 | 96 | int_payload_height = 50.8; /* space between the top and the floor */ |
paul@42 | 97 | int_connector_height = 13.5; /* vertical offset of bottom/floor of payload area */ |
paul@0 | 98 | |
paul@24 | 99 | /* Side thicknesses. */ |
paul@24 | 100 | |
paul@24 | 101 | front = 2; |
paul@24 | 102 | back = 3.5; |
paul@24 | 103 | top = 3; |
paul@42 | 104 | side = 2; /* increased from 1.5 for 3D printing reliability */ |
paul@42 | 105 | bottom = 1; /* thickness of floor of payload area */ |
paul@34 | 106 | |
paul@38 | 107 | /* How much extra depth the back provides for mating with the front. */ |
paul@38 | 108 | |
paul@42 | 109 | groove_width_extra = 1.0; |
paul@42 | 110 | front_back_overlap = 1.0; |
paul@42 | 111 | groove_width_overlap = front_back_overlap + groove_width_extra; |
paul@38 | 112 | |
paul@39 | 113 | /* Division of pieces into front and back, defining the extents. */ |
paul@38 | 114 | |
paul@39 | 115 | int_front_depth = 4.5; |
paul@39 | 116 | front_depth = int_front_depth + front; |
paul@42 | 117 | int_back_depth = int_depth - int_front_depth + front_back_overlap; |
paul@39 | 118 | back_depth = int_back_depth + back; |
paul@38 | 119 | |
paul@38 | 120 | /* Cartridge dimensions. */ |
paul@38 | 121 | |
paul@38 | 122 | width = int_width + side + side; |
paul@42 | 123 | height = top + int_payload_height + bottom + int_connector_height; |
paul@38 | 124 | depth = int_depth + front + back; |
paul@42 | 125 | int_payload_upper_extent = height / 2 - top; |
paul@45 | 126 | int_payload_lower_extent = -height / 2 + int_connector_height + bottom; |
paul@38 | 127 | |
paul@38 | 128 | /* Cartridge surfaces. */ |
paul@38 | 129 | |
paul@34 | 130 | front_side = side; |
paul@29 | 131 | front_left = front_side; |
paul@29 | 132 | front_right = front_side; |
paul@34 | 133 | back_side = side; |
paul@29 | 134 | back_left = back_side; |
paul@29 | 135 | back_right = back_side; |
paul@24 | 136 | |
paul@20 | 137 | /* Label details. */ |
paul@1 | 138 | |
paul@1 | 139 | front_label_width = 83.0; |
paul@1 | 140 | front_label_height = 46.0; |
paul@1 | 141 | front_label_depth = 1.0; |
paul@1 | 142 | front_label_offset_from_bottom = 19.5; |
paul@3 | 143 | |
paul@1 | 144 | top_label_width = front_label_width; |
paul@20 | 145 | top_label_height = 11.5; /* the height as seen from above */ |
paul@1 | 146 | top_label_depth = front_label_depth; |
paul@1 | 147 | top_label_offset_from_front = 2.5; |
paul@3 | 148 | |
paul@41 | 149 | /* |
paul@41 | 150 | The groove around the sides and top. This is extended to allow the |
paul@41 | 151 | pieces to fit together, and this extension is generated regardless of |
paul@41 | 152 | whether the visible groove is enabled or not. |
paul@41 | 153 | */ |
paul@20 | 154 | |
paul@41 | 155 | groove_width_exposed = GROOVE ? 1.5 : 0; |
paul@42 | 156 | groove_width = groove_width_exposed + groove_width_overlap; |
paul@8 | 157 | groove_depth = 1.0; /* how deep the groove goes into each side */ |
paul@20 | 158 | |
paul@20 | 159 | /* Additional cutting to mate the back and front. */ |
paul@20 | 160 | |
paul@42 | 161 | top_groove_width = groove_width_overlap; |
paul@8 | 162 | top_groove_depth = 2.0; |
paul@20 | 163 | |
paul@29 | 164 | /* |
paul@29 | 165 | Space for the inner edge of the back inside the front. |
paul@29 | 166 | Offsets are measured from the outside surfaces. |
paul@29 | 167 | */ |
paul@20 | 168 | |
paul@42 | 169 | inner_top_front_cutout_width = int_width; |
paul@30 | 170 | inner_top_front_cutout_depth = top_groove_width; |
paul@30 | 171 | inner_top_front_cutout_height = top - top_groove_depth; |
paul@28 | 172 | |
paul@42 | 173 | inner_side_front_cutout_height = height - top_groove_depth; |
paul@30 | 174 | inner_side_front_cutout_width = front_side - groove_depth; |
paul@42 | 175 | inner_side_front_cutout_depth = groove_width_overlap; |
paul@1 | 176 | |
paul@35 | 177 | /* |
paul@35 | 178 | The back cavity is the indented part at the bottom of the back of the |
paul@40 | 179 | cartridge. It appears to be mechanically superfluous, just making the |
paul@40 | 180 | shape of the cartridge look a bit fancier. |
paul@35 | 181 | */ |
paul@35 | 182 | |
paul@4 | 183 | back_cavity_width = 68.0; |
paul@4 | 184 | back_cavity_inner_width = 65.0; |
paul@40 | 185 | back_cavity_offset_from_inner_left = 9.0; |
paul@40 | 186 | back_cavity_inner_offset_from_inner_left = 10.5; |
paul@4 | 187 | back_cavity_height = 13.5; |
paul@4 | 188 | back_cavity_inner_height = 12.0; |
paul@4 | 189 | back_cavity_depth = 1.5; |
paul@4 | 190 | |
paul@39 | 191 | /* |
paul@40 | 192 | The effect of the cavity on the inside of the case. The most important |
paul@40 | 193 | measurement is the maximum offset since it defines the width of the |
paul@40 | 194 | internal space that should accommodate the plastic guides of the Plus 1 |
paul@40 | 195 | socket. |
paul@39 | 196 | */ |
paul@35 | 197 | |
paul@6 | 198 | inner_back_slope_depth = 2.5; |
paul@40 | 199 | inner_back_slope_width = inner_back_slope_depth; |
paul@40 | 200 | inner_back_slope_max_offset = 10.5; |
paul@40 | 201 | inner_back_slope_min_offset = inner_back_slope_max_offset - inner_back_slope_width; |
paul@5 | 202 | |
paul@40 | 203 | /* The tapering off of the inner back edge. */ |
paul@40 | 204 | |
paul@5 | 205 | inner_back_edge_width = 69.0; |
paul@5 | 206 | inner_back_edge_height = 3.0; |
paul@5 | 207 | inner_back_edge_depth = 1.5; |
paul@5 | 208 | |
paul@40 | 209 | /* The tapering off of the inner front edge. */ |
paul@40 | 210 | |
paul@34 | 211 | inner_front_edge_width = width - front_side * 2; |
paul@7 | 212 | inner_front_edge_height = 3.0; |
paul@7 | 213 | inner_front_edge_depth = 1.5; |
paul@7 | 214 | |
paul@39 | 215 | /* |
paul@39 | 216 | The cutouts in the floor of the front of the cartridge that produce a |
paul@39 | 217 | kind of tab that guides the edge connector into place in the back cutout. |
paul@39 | 218 | */ |
paul@39 | 219 | |
paul@8 | 220 | edge_connector_cutout_front_offset = 1.0; |
paul@42 | 221 | edge_connector_cutout_front_depth = front_back_overlap; |
paul@8 | 222 | edge_connector_cutout_front_width = 15.0; |
paul@39 | 223 | |
paul@39 | 224 | /* |
paul@39 | 225 | The cutout in the floor of the back of the cartridge that accommodates |
paul@39 | 226 | the edge connector. |
paul@39 | 227 | */ |
paul@39 | 228 | |
paul@8 | 229 | edge_connector_cutout_back_depth = 3.0; |
paul@23 | 230 | edge_connector_cutout_back_width = 57.5; |
paul@8 | 231 | |
paul@17 | 232 | /* |
paul@17 | 233 | Edge connectors are themselves 0.05" or approximately 1.27mm in |
paul@17 | 234 | thickness according to the Acorn Electron Cartridge Interface Specification |
paul@17 | 235 | (Acorn Support Application Group Note 014). |
paul@17 | 236 | */ |
paul@17 | 237 | |
paul@33 | 238 | /* Extra internal features. Depths include front and back surfaces. */ |
paul@14 | 239 | |
paul@23 | 240 | pcb_back_support_width = 1.2; |
paul@14 | 241 | pcb_back_support_depth = back_depth - |
paul@14 | 242 | edge_connector_cutout_back_depth; |
paul@38 | 243 | pcb_back_support_height = height - int_connector_height - top - bottom; |
paul@14 | 244 | |
paul@23 | 245 | pcb_front_support_width = 1.2; |
paul@44 | 246 | pcb_front_support_depth = int_front_depth; |
paul@15 | 247 | pcb_front_support_height = pcb_back_support_height; |
paul@15 | 248 | |
paul@16 | 249 | /* |
paul@45 | 250 | Features measured from the Stardot Dual ROM Adaptor cartridge board |
paul@37 | 251 | dimensions diagram. Offsets are from inside the bottom "floor". |
paul@16 | 252 | */ |
paul@16 | 253 | |
paul@16 | 254 | pcb_back_support_bump_width = pcb_front_support_width; |
paul@18 | 255 | pcb_back_support_bump_depth = 1.5; |
paul@23 | 256 | pcb_back_support_left_bump_height = 13.2; |
paul@23 | 257 | pcb_back_support_right_bump_height = 10.7; |
paul@23 | 258 | pcb_back_support_left_bump_offset_from_bottom = 15.1; |
paul@23 | 259 | pcb_back_support_right_bump_offset_from_bottom = 17.6; |
paul@27 | 260 | pcb_back_support_top_bump_height = 3.8; |
paul@16 | 261 | |
paul@24 | 262 | /* Move the PCB support towards the centre. */ |
paul@35 | 263 | pcb_support_margin = 1.75; |
paul@37 | 264 | pcb_support_offset_from_centre = edge_connector_cutout_back_width / 2 |
paul@37 | 265 | - pcb_support_margin; |
paul@24 | 266 | |
paul@25 | 267 | pcb_lug_depth = pcb_back_support_depth + |
paul@25 | 268 | pcb_back_support_bump_depth; |
paul@25 | 269 | pcb_lug_inner_radius = 1.0; |
paul@25 | 270 | pcb_lug_outer_radius = 5.5 / 2; |
paul@25 | 271 | pcb_lug_offset_from_bottom = 14.35; |
paul@45 | 272 | pcb_lug_offset_from_inside = 5.55; |
paul@25 | 273 | |
paul@25 | 274 | pcb_lug_cross_width = 6.7; |
paul@33 | 275 | pcb_lug_cross_depth = pcb_back_support_depth; |
paul@25 | 276 | pcb_lug_cross_height = 1.4; |
paul@25 | 277 | |
paul@33 | 278 | pcb_front_lug_depth = pcb_back_support_bump_depth + |
paul@44 | 279 | pcb_front_support_depth; |
paul@33 | 280 | pcb_front_lug_inner_radius = pcb_lug_outer_radius; |
paul@33 | 281 | pcb_front_lug_outer_radius = pow( |
paul@33 | 282 | pow(pcb_lug_cross_width / 2, 2) + |
paul@33 | 283 | pow(pcb_lug_cross_height / 2, 2), |
paul@33 | 284 | 0.5); |
paul@33 | 285 | |
paul@25 | 286 | /* Repeated constructs. */ |
paul@25 | 287 | |
paul@26 | 288 | module pcb_support(xdir, bump_height, bump_offset) { |
paul@35 | 289 | |
paul@35 | 290 | /* |
paul@35 | 291 | Translate the support in the stated direction. |
paul@35 | 292 | Since the support is already justified in the direction, the translation |
paul@35 | 293 | moves the inner edge of the support to alignment with the end of the |
paul@35 | 294 | edge connector cutout and then back by the PCB support margin. |
paul@35 | 295 | */ |
paul@35 | 296 | |
paul@25 | 297 | translate([xdir * |
paul@37 | 298 | pcb_support_offset_from_centre, |
paul@25 | 299 | edge_connector_cutout_back_depth, |
paul@45 | 300 | int_payload_lower_extent]) |
paul@25 | 301 | justify(pcb_back_support_width, |
paul@25 | 302 | pcb_back_support_depth, |
paul@25 | 303 | pcb_back_support_height, |
paul@25 | 304 | xdir, 1, 1) |
paul@25 | 305 | union() { |
paul@27 | 306 | |
paul@27 | 307 | /* Underlying support strut. */ |
paul@27 | 308 | |
paul@25 | 309 | cube([pcb_back_support_width, |
paul@25 | 310 | pcb_back_support_depth, |
paul@25 | 311 | pcb_back_support_height], center = true); |
paul@27 | 312 | |
paul@27 | 313 | /* Middle bump. */ |
paul@27 | 314 | |
paul@25 | 315 | cube_at(pcb_back_support_bump_width, |
paul@25 | 316 | pcb_back_support_bump_depth, |
paul@26 | 317 | bump_height, |
paul@25 | 318 | 0, -1, 1, |
paul@25 | 319 | 0, |
paul@25 | 320 | -pcb_back_support_depth / 2, |
paul@26 | 321 | -pcb_back_support_height / 2 + bump_offset); |
paul@27 | 322 | |
paul@27 | 323 | /* Top bump. */ |
paul@27 | 324 | |
paul@27 | 325 | cube_at(pcb_back_support_bump_width, |
paul@27 | 326 | pcb_back_support_bump_depth, |
paul@27 | 327 | pcb_back_support_top_bump_height, |
paul@27 | 328 | 0, -1, 1, |
paul@27 | 329 | 0, |
paul@27 | 330 | -pcb_back_support_depth / 2, |
paul@27 | 331 | pcb_back_support_height / 2 - |
paul@27 | 332 | pcb_back_support_top_bump_height); |
paul@25 | 333 | } |
paul@25 | 334 | } |
paul@25 | 335 | |
paul@25 | 336 | module pcb_lug(xdir) { |
paul@25 | 337 | translate([xdir * |
paul@45 | 338 | (int_width / 2 - pcb_lug_offset_from_inside), |
paul@25 | 339 | back_depth, |
paul@45 | 340 | int_payload_lower_extent + pcb_lug_offset_from_bottom |
paul@25 | 341 | ]) |
paul@25 | 342 | rotate([90, 0, 0]) |
paul@25 | 343 | difference() { |
paul@25 | 344 | union() { |
paul@25 | 345 | cylinder(h=pcb_lug_depth, r=pcb_lug_outer_radius); |
paul@25 | 346 | cube_at(pcb_lug_cross_width, |
paul@25 | 347 | pcb_lug_cross_height, pcb_lug_cross_depth, |
paul@25 | 348 | 0, 0, 1, |
paul@25 | 349 | 0, 0, 0); |
paul@25 | 350 | cube_at(pcb_lug_cross_height, |
paul@25 | 351 | pcb_lug_cross_width, pcb_lug_cross_depth, |
paul@25 | 352 | 0, 0, 1, |
paul@25 | 353 | 0, 0, 0); |
paul@25 | 354 | } |
paul@25 | 355 | cylinder(h=pcb_lug_depth, r=pcb_lug_inner_radius); |
paul@25 | 356 | } |
paul@25 | 357 | } |
paul@25 | 358 | |
paul@33 | 359 | module pcb_front_lug(xdir) { |
paul@33 | 360 | translate([xdir * |
paul@45 | 361 | (int_width / 2 - pcb_lug_offset_from_inside), |
paul@39 | 362 | -int_front_depth + pcb_front_lug_depth, |
paul@45 | 363 | int_payload_lower_extent + pcb_lug_offset_from_bottom |
paul@33 | 364 | ]) |
paul@33 | 365 | rotate([90, 0, 0]) |
paul@33 | 366 | difference() { |
paul@33 | 367 | cylinder(h=pcb_front_lug_depth, |
paul@33 | 368 | r=pcb_front_lug_outer_radius); |
paul@33 | 369 | cylinder(h=pcb_front_lug_depth, |
paul@33 | 370 | r=pcb_front_lug_inner_radius); |
paul@33 | 371 | } |
paul@33 | 372 | } |
paul@33 | 373 | |
paul@25 | 374 | /* The actual shapes. */ |
paul@25 | 375 | |
paul@43 | 376 | front_displacement = APART ? -width * 0.6 : 0; |
paul@43 | 377 | |
paul@43 | 378 | if (FRONT) |
paul@43 | 379 | translate([front_displacement, 0, 0]) |
paul@43 | 380 | difference() { |
paul@1 | 381 | |
paul@43 | 382 | /* The cartridge surfaces. */ |
paul@1 | 383 | |
paul@43 | 384 | union() { |
paul@8 | 385 | |
paul@43 | 386 | /* Front portion. */ |
paul@8 | 387 | |
paul@43 | 388 | if (FRONT_SURFACE) { |
paul@43 | 389 | cube_at(width, front, height, |
paul@43 | 390 | 0, -1, 0, |
paul@43 | 391 | 0, -int_front_depth, 0); |
paul@43 | 392 | cube_at(front_left, front_depth, height, |
paul@43 | 393 | -1, -1, 0, |
paul@43 | 394 | -int_width / 2, 0, 0); |
paul@43 | 395 | cube_at(front_right, front_depth, height, |
paul@43 | 396 | 1, -1, 0, |
paul@43 | 397 | int_width / 2, 0, 0); |
paul@43 | 398 | cube_at(width, front_depth, top, |
paul@43 | 399 | 0, -1, 1, |
paul@43 | 400 | 0, 0, int_payload_upper_extent); |
paul@43 | 401 | } |
paul@20 | 402 | |
paul@43 | 403 | difference() { |
paul@43 | 404 | |
paul@43 | 405 | /* Floor of cartridge. */ |
paul@43 | 406 | |
paul@45 | 407 | cube_at(int_width, int_front_depth, bottom, |
paul@43 | 408 | 0, -1, 1, |
paul@43 | 409 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 410 | |
paul@43 | 411 | /* Left cutout. */ |
paul@20 | 412 | |
paul@43 | 413 | cube_at(edge_connector_cutout_front_width, |
paul@43 | 414 | edge_connector_cutout_front_depth, |
paul@43 | 415 | bottom, |
paul@43 | 416 | 1, -1, 1, |
paul@43 | 417 | -width / 2 + edge_connector_cutout_front_offset, |
paul@43 | 418 | 0, |
paul@43 | 419 | -height / 2 + int_connector_height); |
paul@43 | 420 | |
paul@43 | 421 | /* Right cutout. */ |
paul@20 | 422 | |
paul@43 | 423 | cube_at(edge_connector_cutout_front_width, |
paul@43 | 424 | edge_connector_cutout_front_depth, |
paul@43 | 425 | bottom, |
paul@43 | 426 | -1, -1, 1, |
paul@43 | 427 | width / 2 - edge_connector_cutout_front_offset, |
paul@43 | 428 | 0, |
paul@43 | 429 | -height / 2 + int_connector_height); |
paul@43 | 430 | } |
paul@43 | 431 | |
paul@43 | 432 | /* PCB supports. */ |
paul@20 | 433 | |
paul@43 | 434 | cube_at(pcb_front_support_width, |
paul@43 | 435 | pcb_front_support_depth, |
paul@43 | 436 | pcb_front_support_height, |
paul@44 | 437 | -1, -1, 1, |
paul@44 | 438 | -pcb_support_offset_from_centre, |
paul@43 | 439 | 0, |
paul@45 | 440 | int_payload_lower_extent); |
paul@20 | 441 | |
paul@43 | 442 | cube_at(pcb_front_support_width, |
paul@43 | 443 | pcb_front_support_depth, |
paul@43 | 444 | pcb_front_support_height, |
paul@44 | 445 | 1, -1, 1, |
paul@44 | 446 | pcb_support_offset_from_centre, |
paul@43 | 447 | 0, |
paul@45 | 448 | int_payload_lower_extent); |
paul@20 | 449 | |
paul@43 | 450 | /* Circular "lugs" to hold PCBs in place. */ |
paul@43 | 451 | |
paul@43 | 452 | pcb_front_lug(-1); |
paul@43 | 453 | pcb_front_lug(1); |
paul@8 | 454 | } |
paul@15 | 455 | |
paul@43 | 456 | /* Label insets. */ |
paul@43 | 457 | |
paul@43 | 458 | union() { |
paul@43 | 459 | |
paul@43 | 460 | /* Front label. */ |
paul@15 | 461 | |
paul@43 | 462 | if (FRONT_LABEL_INSET) |
paul@43 | 463 | translate([-front_label_width / 2, -front_depth, |
paul@43 | 464 | front_label_offset_from_bottom - height / 2]) |
paul@43 | 465 | cube([front_label_width, front_label_depth, |
paul@43 | 466 | front_label_height]); |
paul@33 | 467 | |
paul@43 | 468 | /* Top label. See also the back piece. */ |
paul@10 | 469 | |
paul@43 | 470 | if (TOP_LABEL_INSET) |
paul@43 | 471 | translate([-top_label_width / 2, |
paul@43 | 472 | -front_depth + top_label_offset_from_front, |
paul@43 | 473 | height / 2 - top_label_depth]) |
paul@43 | 474 | cube([top_label_width, top_label_height, |
paul@43 | 475 | top_label_depth]); |
paul@43 | 476 | } |
paul@10 | 477 | |
paul@43 | 478 | /* Inner front edge cavity. */ |
paul@10 | 479 | |
paul@43 | 480 | translate([inner_front_edge_width / 2, -int_front_depth, -height / 2]) |
paul@43 | 481 | rotate([0, -90, 0]) |
paul@43 | 482 | linear_extrude(height = inner_front_edge_width) |
paul@43 | 483 | polygon([ |
paul@43 | 484 | [-extra, -inner_front_edge_depth], |
paul@43 | 485 | [0, -inner_front_edge_depth], |
paul@43 | 486 | [inner_front_edge_height, 0], |
paul@43 | 487 | [-extra, 0], |
paul@43 | 488 | ]); |
paul@10 | 489 | |
paul@43 | 490 | /* Inner top cutout for the top and sides of the back portion. */ |
paul@10 | 491 | |
paul@43 | 492 | cube_at(inner_top_front_cutout_width, |
paul@43 | 493 | inner_top_front_cutout_depth, |
paul@43 | 494 | inner_top_front_cutout_height, |
paul@43 | 495 | 0, -1, 1, |
paul@43 | 496 | 0, 0, int_payload_upper_extent); |
paul@11 | 497 | |
paul@43 | 498 | cube_at(inner_side_front_cutout_width, |
paul@43 | 499 | inner_side_front_cutout_depth, |
paul@43 | 500 | inner_side_front_cutout_height, |
paul@43 | 501 | 1, -1, 0, |
paul@43 | 502 | int_width / 2, 0, -inner_top_front_cutout_height); |
paul@11 | 503 | |
paul@43 | 504 | cube_at(inner_side_front_cutout_width, |
paul@43 | 505 | inner_side_front_cutout_depth, |
paul@43 | 506 | inner_side_front_cutout_height, |
paul@43 | 507 | -1, -1, 0, |
paul@43 | 508 | -int_width / 2, 0, -inner_top_front_cutout_height); |
paul@28 | 509 | |
paul@43 | 510 | /* Fillets to round off the edges. */ |
paul@43 | 511 | |
paul@43 | 512 | union() { |
paul@28 | 513 | |
paul@43 | 514 | /* Top left and right rounding. */ |
paul@43 | 515 | |
paul@43 | 516 | translate([-width / 2 + ro, -front_depth / 2, height / 2 - ro]) |
paul@43 | 517 | rotate([0, 0, 180]) |
paul@43 | 518 | rotate([90, 0, 0]) |
paul@43 | 519 | fillet(rr, front_depth); |
paul@43 | 520 | translate([width / 2 - ro, -front_depth / 2, height / 2 - ro]) |
paul@10 | 521 | rotate([90, 0, 0]) |
paul@10 | 522 | fillet(rr, front_depth); |
paul@10 | 523 | |
paul@43 | 524 | /* Top front rounding. */ |
paul@43 | 525 | |
paul@43 | 526 | translate([0, -front_depth + ro, height / 2 - ro]) |
paul@43 | 527 | rotate([0, 0, 180]) |
paul@43 | 528 | rotate([0, -90, 0]) |
paul@43 | 529 | fillet(rr, width); |
paul@10 | 530 | |
paul@43 | 531 | /* Edge rounding. */ |
paul@43 | 532 | |
paul@43 | 533 | translate([-width / 2 + ro, -front_depth + ro, 0]) |
paul@43 | 534 | rotate([0, 0, 180]) |
paul@43 | 535 | fillet(rr, height); |
paul@43 | 536 | translate([width / 2 - ro, -front_depth + ro, 0]) |
paul@43 | 537 | rotate([0, 0, 270]) |
paul@43 | 538 | fillet(rr, height); |
paul@43 | 539 | } |
paul@10 | 540 | } |
paul@10 | 541 | |
paul@41 | 542 | /* |
paul@41 | 543 | Place the back piece next to the front, with the internals facing out |
paul@43 | 544 | the same way, if APART is defined. |
paul@41 | 545 | */ |
paul@41 | 546 | |
paul@43 | 547 | back_displacement = APART ? width * 0.6 : 0; |
paul@43 | 548 | back_rotation = APART ? 180 : 0; |
paul@43 | 549 | |
paul@43 | 550 | if (BACK) |
paul@43 | 551 | translate([back_displacement, 0, 0]) |
paul@43 | 552 | rotate([0, 0, back_rotation]) |
paul@43 | 553 | difference() { |
paul@43 | 554 | |
paul@43 | 555 | /* The cartridge surfaces. */ |
paul@43 | 556 | |
paul@43 | 557 | union() { |
paul@43 | 558 | |
paul@43 | 559 | /* Back portion. */ |
paul@10 | 560 | |
paul@43 | 561 | if (BACK_SURFACE) { |
paul@43 | 562 | cube_at(width, back, height, |
paul@43 | 563 | 0, 1, 0, |
paul@43 | 564 | 0, int_back_depth, 0); |
paul@43 | 565 | cube_at(back_left, back_depth + groove_width_extra, height, |
paul@43 | 566 | -1, 1, 0, |
paul@43 | 567 | -int_width / 2, -groove_width_extra, 0); |
paul@43 | 568 | cube_at(back_right, back_depth + groove_width_extra, height, |
paul@43 | 569 | 1, 1, 0, |
paul@43 | 570 | int_width / 2, -groove_width_extra, 0); |
paul@43 | 571 | cube_at(width, back_depth + groove_width_extra, top, |
paul@43 | 572 | 0, 1, 1, |
paul@43 | 573 | 0, -groove_width_extra, int_payload_upper_extent); |
paul@43 | 574 | } |
paul@10 | 575 | |
paul@43 | 576 | difference() { |
paul@8 | 577 | |
paul@43 | 578 | /* Floor of cartridge. */ |
paul@8 | 579 | |
paul@45 | 580 | cube_at(int_width, int_back_depth, bottom, |
paul@43 | 581 | 0, 1, 1, |
paul@43 | 582 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 583 | |
paul@43 | 584 | /* Edge connector cutout. */ |
paul@43 | 585 | |
paul@43 | 586 | cube_at(edge_connector_cutout_back_width, |
paul@43 | 587 | edge_connector_cutout_back_depth, |
paul@43 | 588 | bottom, |
paul@43 | 589 | 0, 1, 1, |
paul@43 | 590 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 591 | } |
paul@43 | 592 | |
paul@43 | 593 | /* PCB supports. */ |
paul@42 | 594 | |
paul@43 | 595 | pcb_support(-1, pcb_back_support_left_bump_height, |
paul@43 | 596 | pcb_back_support_left_bump_offset_from_bottom); |
paul@43 | 597 | pcb_support(1, pcb_back_support_right_bump_height, |
paul@43 | 598 | pcb_back_support_right_bump_offset_from_bottom); |
paul@20 | 599 | |
paul@43 | 600 | /* Circular "lugs" to hold PCBs in place. */ |
paul@43 | 601 | |
paul@43 | 602 | pcb_lug(-1); |
paul@43 | 603 | pcb_lug(1); |
paul@43 | 604 | } |
paul@20 | 605 | |
paul@43 | 606 | /* Label insets. */ |
paul@43 | 607 | |
paul@43 | 608 | union() { |
paul@43 | 609 | |
paul@43 | 610 | /* Top label. See also the front piece. */ |
paul@20 | 611 | |
paul@43 | 612 | if (TOP_LABEL_INSET) |
paul@43 | 613 | translate([-top_label_width / 2, |
paul@43 | 614 | -front_depth + top_label_offset_from_front, |
paul@43 | 615 | height / 2 - top_label_depth]) |
paul@43 | 616 | cube([top_label_width, top_label_height, |
paul@43 | 617 | top_label_depth]); |
paul@8 | 618 | } |
paul@14 | 619 | |
paul@43 | 620 | /* Top and side grooves, positioned in the back portion. */ |
paul@25 | 621 | |
paul@43 | 622 | union() { |
paul@0 | 623 | |
paul@43 | 624 | /* Left groove. */ |
paul@1 | 625 | |
paul@43 | 626 | cube_at(groove_depth, groove_width, height, |
paul@43 | 627 | 1, 1, 0, |
paul@43 | 628 | -width / 2, -groove_width_extra, 0); |
paul@2 | 629 | |
paul@43 | 630 | /* Right groove. */ |
paul@2 | 631 | |
paul@43 | 632 | cube_at(groove_depth, groove_width, height, |
paul@43 | 633 | -1, 1, 0, |
paul@43 | 634 | width / 2, -groove_width_extra, 0); |
paul@8 | 635 | |
paul@43 | 636 | /* Top grooves. */ |
paul@4 | 637 | |
paul@43 | 638 | cube_at(width, groove_width, groove_depth, |
paul@43 | 639 | 0, 1, -1, |
paul@43 | 640 | 0, -groove_width_extra, height / 2); |
paul@4 | 641 | |
paul@43 | 642 | cube_at(width, top_groove_width, top_groove_depth, |
paul@43 | 643 | 0, 1, -1, |
paul@43 | 644 | 0, -groove_width_extra, height / 2); |
paul@41 | 645 | } |
paul@2 | 646 | |
paul@43 | 647 | /* Back cavity. */ |
paul@43 | 648 | |
paul@43 | 649 | if (BACK_CAVITY) |
paul@43 | 650 | intersection() { |
paul@43 | 651 | |
paul@43 | 652 | /* From the bottom upwards. */ |
paul@5 | 653 | |
paul@43 | 654 | translate([0, back_depth, -height / 2]) |
paul@43 | 655 | linear_extrude(height = back_cavity_height) |
paul@43 | 656 | translate([-int_width / 2, 0, 0]) |
paul@43 | 657 | polygon([ |
paul@43 | 658 | [back_cavity_offset_from_inner_left, 0], |
paul@43 | 659 | [back_cavity_inner_offset_from_inner_left, |
paul@43 | 660 | -back_cavity_depth], |
paul@43 | 661 | [back_cavity_inner_offset_from_inner_left + |
paul@43 | 662 | back_cavity_inner_width, |
paul@43 | 663 | -back_cavity_depth], |
paul@43 | 664 | [back_cavity_offset_from_inner_left + |
paul@43 | 665 | back_cavity_width, 0] |
paul@43 | 666 | ]); |
paul@43 | 667 | |
paul@43 | 668 | /* From left to right. */ |
paul@43 | 669 | |
paul@43 | 670 | translate([back_cavity_width / 2, back_depth, -height / 2]) |
paul@43 | 671 | rotate([0, -90, 0]) |
paul@43 | 672 | linear_extrude(height = back_cavity_width) |
paul@43 | 673 | polygon([ |
paul@43 | 674 | [-extra, -back_cavity_depth], |
paul@43 | 675 | [back_cavity_inner_height, |
paul@43 | 676 | -back_cavity_depth], |
paul@43 | 677 | [back_cavity_height, 0], |
paul@43 | 678 | [-extra, 0] |
paul@43 | 679 | ]); |
paul@43 | 680 | } |
paul@43 | 681 | |
paul@43 | 682 | /* Inner back cavities. */ |
paul@5 | 683 | |
paul@43 | 684 | translate([0, int_back_depth, -height / 2]) |
paul@43 | 685 | linear_extrude(height = int_connector_height) |
paul@43 | 686 | translate([-int_width / 2, 0, 0]) |
paul@43 | 687 | polygon([ |
paul@43 | 688 | [0, 0], |
paul@43 | 689 | [inner_back_slope_max_offset, 0], |
paul@43 | 690 | [inner_back_slope_min_offset, |
paul@43 | 691 | inner_back_slope_depth], |
paul@43 | 692 | [0, inner_back_slope_depth] |
paul@43 | 693 | ]); |
paul@5 | 694 | |
paul@43 | 695 | translate([0, int_back_depth, -height / 2]) |
paul@43 | 696 | linear_extrude(height = int_connector_height) |
paul@43 | 697 | translate([int_width / 2, 0, 0]) |
paul@43 | 698 | polygon([ |
paul@43 | 699 | [0, 0], |
paul@43 | 700 | [-inner_back_slope_max_offset, 0], |
paul@43 | 701 | [-inner_back_slope_min_offset, |
paul@43 | 702 | inner_back_slope_depth], |
paul@43 | 703 | [0, inner_back_slope_depth] |
paul@43 | 704 | ]); |
paul@7 | 705 | |
paul@43 | 706 | /* Inner back edge cavity. */ |
paul@5 | 707 | |
paul@43 | 708 | translate([inner_back_edge_width / 2, |
paul@43 | 709 | int_back_depth + inner_back_edge_depth, -height / 2]) |
paul@43 | 710 | rotate([0, -90, 0]) |
paul@43 | 711 | linear_extrude(height = inner_back_edge_width) |
paul@43 | 712 | polygon([ |
paul@43 | 713 | [-extra, -inner_back_edge_depth], |
paul@43 | 714 | [inner_back_edge_height, -inner_back_edge_depth], |
paul@43 | 715 | [0, 0], |
paul@43 | 716 | [-extra, 0] |
paul@43 | 717 | ]); |
paul@0 | 718 | |
paul@43 | 719 | /* Fillets to round off the edges. */ |
paul@43 | 720 | |
paul@43 | 721 | union() { |
paul@43 | 722 | |
paul@43 | 723 | /* Top left and right rounding. */ |
paul@43 | 724 | |
paul@43 | 725 | translate([-width / 2 + ro, back_depth / 2, height / 2 - ro]) |
paul@43 | 726 | rotate([0, 0, 180]) |
paul@43 | 727 | rotate([90, 0, 0]) |
paul@43 | 728 | fillet(rr, back_depth); |
paul@43 | 729 | translate([width / 2 - ro, back_depth / 2, height / 2 - ro]) |
paul@9 | 730 | rotate([90, 0, 0]) |
paul@9 | 731 | fillet(rr, back_depth); |
paul@43 | 732 | |
paul@43 | 733 | /* Top back rounding. */ |
paul@43 | 734 | |
paul@43 | 735 | translate([0, back_depth - ro, height / 2 - ro]) |
paul@43 | 736 | rotate([0, -90, 0]) |
paul@43 | 737 | fillet(rr, width); |
paul@43 | 738 | |
paul@43 | 739 | /* Edge rounding. */ |
paul@43 | 740 | |
paul@43 | 741 | translate([width / 2 - ro, back_depth - ro, 0]) |
paul@3 | 742 | fillet(rr, height); |
paul@43 | 743 | translate([-width / 2 + ro, back_depth - ro, 0]) |
paul@43 | 744 | rotate([0, 0, 90]) |
paul@43 | 745 | fillet(rr, height); |
paul@43 | 746 | } |
paul@0 | 747 | } |
paul@45 | 748 | |
paul@45 | 749 | /* PCB for checking. */ |
paul@45 | 750 | |
paul@45 | 751 | pcb_width = 84.85; pcb_height = 62.5; pcb_depth = 1; |
paul@45 | 752 | edge_connector_width = 56.5; edge_connector_height = 11.85; |
paul@45 | 753 | pcb_position_y = int_payload_lower_extent; |
paul@45 | 754 | |
paul@45 | 755 | pcb_left_hole_offset = pcb_back_support_left_bump_offset_from_bottom |
paul@45 | 756 | + 0.55; |
paul@45 | 757 | pcb_left_hole_width = 2.2; |
paul@45 | 758 | pcb_left_hole_height = pcb_back_support_left_bump_height - 0.55 * 2; |
paul@45 | 759 | pcb_left_hole_offset_from_centre = pcb_support_offset_from_centre + |
paul@45 | 760 | pcb_back_support_width / 2 - pcb_left_hole_width / 2; |
paul@45 | 761 | |
paul@45 | 762 | pcb_right_hole_offset = pcb_back_support_right_bump_offset_from_bottom |
paul@45 | 763 | + 0.55; |
paul@45 | 764 | pcb_right_hole_width = pcb_left_hole_width; |
paul@45 | 765 | pcb_right_hole_height = pcb_back_support_right_bump_height - 0.55 * 2; |
paul@45 | 766 | pcb_right_hole_offset_from_centre = -pcb_left_hole_offset_from_centre; |
paul@45 | 767 | |
paul@45 | 768 | pcb_hole_depth = pcb_depth + 0.2; |
paul@45 | 769 | pcb_hole_start_depth = -0.1; |
paul@45 | 770 | pcb_lug_hole_radius = 3.75; |
paul@45 | 771 | |
paul@45 | 772 | if (PCB) |
paul@45 | 773 | translate([back_displacement, 0, 0]) |
paul@45 | 774 | translate([0, 0, pcb_position_y]) |
paul@45 | 775 | difference() { |
paul@45 | 776 | |
paul@45 | 777 | /* Mock PCB. */ |
paul@45 | 778 | |
paul@45 | 779 | union() { |
paul@45 | 780 | cube_at(pcb_width, pcb_depth, |
paul@45 | 781 | pcb_height - edge_connector_height, |
paul@45 | 782 | 0, 1, 1, |
paul@45 | 783 | 0, 0, 0); |
paul@45 | 784 | cube_at(edge_connector_width, pcb_depth, |
paul@45 | 785 | edge_connector_height, |
paul@45 | 786 | 0, 1, -1, |
paul@45 | 787 | 0, 0, 0); |
paul@45 | 788 | } |
paul@45 | 789 | |
paul@45 | 790 | /* Holes for mounting. */ |
paul@45 | 791 | |
paul@45 | 792 | union() { |
paul@45 | 793 | cube_at(pcb_left_hole_width, 1, pcb_left_hole_height, |
paul@45 | 794 | 1, 1, 1, |
paul@45 | 795 | pcb_left_hole_offset_from_centre, 0, pcb_left_hole_offset); |
paul@45 | 796 | translate([pcb_left_hole_offset_from_centre + |
paul@45 | 797 | pcb_left_hole_width / 2, pcb_hole_start_depth, pcb_left_hole_offset]) |
paul@45 | 798 | rotate([-90, 0, 0]) |
paul@45 | 799 | cylinder(h=pcb_hole_depth, r=pcb_left_hole_width / 2); |
paul@45 | 800 | translate([pcb_left_hole_offset_from_centre + |
paul@45 | 801 | pcb_left_hole_width / 2, pcb_hole_start_depth, |
paul@45 | 802 | pcb_left_hole_offset + pcb_left_hole_height]) |
paul@45 | 803 | rotate([-90, 0, 0]) |
paul@45 | 804 | cylinder(h=pcb_hole_depth, r=pcb_left_hole_width / 2); |
paul@45 | 805 | } |
paul@45 | 806 | |
paul@45 | 807 | union() { |
paul@45 | 808 | cube_at(pcb_right_hole_width, 1, pcb_right_hole_height, |
paul@45 | 809 | -1, 1, 1, |
paul@45 | 810 | pcb_right_hole_offset_from_centre, 0, pcb_right_hole_offset); |
paul@45 | 811 | translate([pcb_right_hole_offset_from_centre - |
paul@45 | 812 | pcb_right_hole_width / 2, pcb_hole_start_depth, pcb_right_hole_offset]) |
paul@45 | 813 | rotate([-90, 0, 0]) |
paul@45 | 814 | cylinder(h=pcb_hole_depth, r=pcb_right_hole_width / 2); |
paul@45 | 815 | translate([pcb_right_hole_offset_from_centre - |
paul@45 | 816 | pcb_right_hole_width / 2, pcb_hole_start_depth, |
paul@45 | 817 | pcb_right_hole_offset + pcb_right_hole_height]) |
paul@45 | 818 | rotate([-90, 0, 0]) |
paul@45 | 819 | cylinder(h=pcb_hole_depth, r=pcb_right_hole_width / 2); |
paul@45 | 820 | } |
paul@45 | 821 | |
paul@45 | 822 | /* Holes for lugs. */ |
paul@45 | 823 | |
paul@45 | 824 | translate([ |
paul@45 | 825 | -int_width / 2 + pcb_lug_offset_from_inside, |
paul@45 | 826 | pcb_hole_start_depth, pcb_lug_offset_from_bottom]) |
paul@45 | 827 | rotate([-90, 0, 0]) |
paul@45 | 828 | cylinder(h=pcb_hole_depth, r=pcb_lug_hole_radius); |
paul@45 | 829 | |
paul@45 | 830 | translate([ |
paul@45 | 831 | int_width / 2 - pcb_lug_offset_from_inside, |
paul@45 | 832 | pcb_hole_start_depth, pcb_lug_offset_from_bottom]) |
paul@45 | 833 | rotate([-90, 0, 0]) |
paul@45 | 834 | cylinder(h=pcb_hole_depth, r=pcb_lug_hole_radius); |
paul@45 | 835 | } |
paul@0 | 836 | } |
paul@0 | 837 | |
paul@38 | 838 | cartridge(); |