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