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@53 | 29 | /* Model configurations. */ |
paul@53 | 30 | |
paul@53 | 31 | ROM_CARTRIDGE = 1; |
paul@53 | 32 | |
paul@45 | 33 | /* |
paul@45 | 34 | Options for checking. Some useful combinations... |
paul@45 | 35 | |
paul@45 | 36 | Check feature alignment: APART = 0; BACK_SURFACE = 0; FRONT_SURFACE = 0; |
paul@45 | 37 | Check PCB alignment: PCB = 1; BACK_SURFACE = 0; |
paul@45 | 38 | */ |
paul@45 | 39 | |
paul@43 | 40 | BACK = 1; BACK_SURFACE = 1; |
paul@43 | 41 | FRONT = 1; FRONT_SURFACE = 1; |
paul@45 | 42 | |
paul@45 | 43 | /* For printing: APART = 1; PCB = 0; */ |
paul@45 | 44 | |
paul@43 | 45 | APART = 1; |
paul@45 | 46 | PCB = 0; |
paul@43 | 47 | |
paul@48 | 48 | /* To save time (before printing): FILLET = 0; */ |
paul@48 | 49 | |
paul@48 | 50 | FILLET = 1; |
paul@48 | 51 | |
paul@22 | 52 | /* |
paul@22 | 53 | Rounding/fillet radius and additional margin of subtracted |
paul@22 | 54 | material. The additional margin helps avoid geometry problems. |
paul@22 | 55 | */ |
paul@3 | 56 | |
paul@23 | 57 | rr = 2; |
paul@3 | 58 | ro = rr; |
paul@3 | 59 | extra = 0.1; |
paul@3 | 60 | |
paul@47 | 61 | groove_rr = 0.2; |
paul@46 | 62 | groove_ro = groove_rr; |
paul@46 | 63 | |
paul@47 | 64 | pcb_lug_rr = 0.5; |
paul@47 | 65 | pcb_lug_ro = pcb_lug_rr; |
paul@47 | 66 | |
paul@47 | 67 | /* A fillet performs rounding using a quarter segment of a cylinder. */ |
paul@47 | 68 | |
paul@0 | 69 | module fillet(r, h) { |
paul@48 | 70 | if (FILLET) |
paul@48 | 71 | translate([0, 0, -h/2]) |
paul@48 | 72 | difference() { |
paul@48 | 73 | cube([r + extra, r + extra, h + extra]); |
paul@48 | 74 | cylinder(r = r, h = h); |
paul@48 | 75 | } |
paul@48 | 76 | } |
paul@48 | 77 | |
paul@50 | 78 | /* A fillet justified using the axes. */ |
paul@50 | 79 | |
paul@48 | 80 | module fillet_justified(r, h) { |
paul@48 | 81 | if (FILLET) |
paul@0 | 82 | difference() { |
paul@12 | 83 | cube([r + extra, r + extra, h + extra]); |
paul@0 | 84 | cylinder(r = r, h = h); |
paul@0 | 85 | } |
paul@0 | 86 | } |
paul@0 | 87 | |
paul@50 | 88 | /* A justified fillet with the extra material below the y-axis. */ |
paul@50 | 89 | |
paul@50 | 90 | module fillet_partitioned(r, h) { |
paul@50 | 91 | if (FILLET) |
paul@50 | 92 | difference() { |
paul@50 | 93 | translate([0, 0, -extra]) |
paul@50 | 94 | cube([r + extra, r + extra, h + extra]); |
paul@50 | 95 | cylinder(r = r, h = h); |
paul@50 | 96 | } |
paul@50 | 97 | } |
paul@50 | 98 | |
paul@47 | 99 | module fillet_torus(radius, rounding) { |
paul@48 | 100 | if (FILLET) |
paul@48 | 101 | difference() { |
paul@48 | 102 | cube_at((radius + extra) * 2, (radius + extra) * 2, rounding + extra, |
paul@48 | 103 | 0, 0, 1, |
paul@48 | 104 | 0, 0, 0); |
paul@48 | 105 | union() { |
paul@48 | 106 | rotate_extrude(convexity = 10) |
paul@48 | 107 | translate([radius - rounding, 0, 0]) |
paul@48 | 108 | circle(r = rounding); |
paul@48 | 109 | cylinder(r = radius - rounding, h = rounding); |
paul@48 | 110 | } |
paul@47 | 111 | } |
paul@47 | 112 | } |
paul@47 | 113 | |
paul@20 | 114 | /* |
paul@21 | 115 | Justify an object of the given dimensions, according to the given |
paul@21 | 116 | factors (where 1 indicates moving the object to the positive side of an |
paul@21 | 117 | axis, and -1 indicates moving it to the negative side of an axis). |
paul@21 | 118 | |
paul@21 | 119 | NOTE: child should eventually be replaced by children. |
paul@21 | 120 | */ |
paul@21 | 121 | module justify(width, depth, height, wdir, ddir, hdir) { |
paul@21 | 122 | translate([ |
paul@21 | 123 | wdir * width / 2, |
paul@21 | 124 | ddir * depth / 2, |
paul@21 | 125 | hdir * height / 2]) |
paul@21 | 126 | child(); |
paul@21 | 127 | } |
paul@21 | 128 | |
paul@21 | 129 | /* |
paul@20 | 130 | Make a cuboid of the given dimensions, justifying it according to the given |
paul@21 | 131 | factors, and moving it to the specified coordinates. |
paul@21 | 132 | |
paul@21 | 133 | NOTE: Usage of justify within this module will not work due to recursion |
paul@21 | 134 | NOTE: limitations in openscad, potentially removed in more recent |
paul@21 | 135 | NOTE: releases. Thus, the justify transform is merged in here. |
paul@20 | 136 | */ |
paul@20 | 137 | module cube_at(width, depth, height, wdir, ddir, hdir, x, y, z) { |
paul@20 | 138 | translate([ |
paul@20 | 139 | x + wdir * width / 2, |
paul@20 | 140 | y + ddir * depth / 2, |
paul@20 | 141 | z + hdir * height / 2]) |
paul@20 | 142 | cube([width, depth, height], center = true); |
paul@20 | 143 | } |
paul@20 | 144 | |
paul@38 | 145 | /* Internal dimensions. */ |
paul@0 | 146 | |
paul@50 | 147 | int_payload_width = 86.0; /* internal width in the payload section */ |
paul@50 | 148 | int_connector_width = 86.0; /* limited to the Plus 1 socket dimensions */ |
paul@49 | 149 | int_payload_depth = 12.5; /* maximum depth in the payload section */ |
paul@49 | 150 | int_connector_depth = 11.0; /* maximum depth in the connector section */ |
paul@42 | 151 | int_payload_height = 50.8; /* space between the top and the floor */ |
paul@42 | 152 | int_connector_height = 13.5; /* vertical offset of bottom/floor of payload area */ |
paul@0 | 153 | |
paul@24 | 154 | /* Side thicknesses. */ |
paul@24 | 155 | |
paul@24 | 156 | front = 2; |
paul@49 | 157 | payload_back = 2; /* in the payload area the thickness is reduced */ |
paul@49 | 158 | connector_back = 3.5; /* the back cavity requires a thicker back wall */ |
paul@24 | 159 | top = 3; |
paul@42 | 160 | side = 2; /* increased from 1.5 for 3D printing reliability */ |
paul@42 | 161 | bottom = 1; /* thickness of floor of payload area */ |
paul@34 | 162 | |
paul@38 | 163 | /* How much extra depth the back provides for mating with the front. */ |
paul@38 | 164 | |
paul@42 | 165 | groove_width_extra = 1.0; |
paul@42 | 166 | front_back_overlap = 1.0; |
paul@42 | 167 | groove_width_overlap = front_back_overlap + groove_width_extra; |
paul@38 | 168 | |
paul@39 | 169 | /* Division of pieces into front and back, defining the extents. */ |
paul@38 | 170 | |
paul@39 | 171 | int_front_depth = 4.5; |
paul@39 | 172 | front_depth = int_front_depth + front; |
paul@49 | 173 | int_payload_back_depth = int_payload_depth - int_front_depth + front_back_overlap; |
paul@49 | 174 | int_connector_back_depth = int_connector_depth - int_front_depth + front_back_overlap; |
paul@49 | 175 | back_depth = int_payload_back_depth + payload_back; |
paul@38 | 176 | |
paul@38 | 177 | /* Cartridge dimensions. */ |
paul@38 | 178 | |
paul@50 | 179 | payload_width = int_payload_width + side + side; |
paul@50 | 180 | connector_width = int_connector_width + side + side; |
paul@49 | 181 | payload_height = top + int_payload_height; |
paul@49 | 182 | connector_height = bottom + int_connector_height; |
paul@49 | 183 | height = payload_height + bottom + int_connector_height; |
paul@49 | 184 | depth = int_payload_depth + front + payload_back; |
paul@42 | 185 | int_payload_upper_extent = height / 2 - top; |
paul@45 | 186 | int_payload_lower_extent = -height / 2 + int_connector_height + bottom; |
paul@38 | 187 | |
paul@51 | 188 | /* Where the payload is wider than the connector, the payload expands to the left. */ |
paul@51 | 189 | |
paul@51 | 190 | int_payload_right_extent = int_connector_width / 2; |
paul@51 | 191 | int_payload_left_extent = int_payload_right_extent - int_payload_width; |
paul@51 | 192 | payload_left_extent = int_payload_left_extent - side; |
paul@51 | 193 | payload_right_extent = int_payload_right_extent + side; |
paul@51 | 194 | payload_centre = (payload_left_extent + payload_right_extent) / 2; |
paul@51 | 195 | |
paul@38 | 196 | /* Cartridge surfaces. */ |
paul@38 | 197 | |
paul@34 | 198 | front_side = side; |
paul@29 | 199 | front_left = front_side; |
paul@29 | 200 | front_right = front_side; |
paul@34 | 201 | back_side = side; |
paul@29 | 202 | back_left = back_side; |
paul@29 | 203 | back_right = back_side; |
paul@24 | 204 | |
paul@20 | 205 | /* Label details. */ |
paul@1 | 206 | |
paul@50 | 207 | front_label_width = payload_width - side - side - 3.0; |
paul@1 | 208 | front_label_height = 46.0; |
paul@1 | 209 | front_label_depth = 1.0; |
paul@1 | 210 | front_label_offset_from_bottom = 19.5; |
paul@51 | 211 | front_label_centre = payload_centre; |
paul@51 | 212 | front_label_left_extent = front_label_centre - front_label_width / 2; |
paul@3 | 213 | |
paul@1 | 214 | top_label_width = front_label_width; |
paul@20 | 215 | top_label_height = 11.5; /* the height as seen from above */ |
paul@1 | 216 | top_label_depth = front_label_depth; |
paul@1 | 217 | top_label_offset_from_front = 2.5; |
paul@51 | 218 | top_label_centre = payload_centre; |
paul@51 | 219 | top_label_left_extent = top_label_centre - front_label_width / 2; |
paul@3 | 220 | |
paul@41 | 221 | /* |
paul@41 | 222 | The groove around the sides and top. This is extended to allow the |
paul@41 | 223 | pieces to fit together, and this extension is generated regardless of |
paul@41 | 224 | whether the visible groove is enabled or not. |
paul@41 | 225 | */ |
paul@20 | 226 | |
paul@41 | 227 | groove_width_exposed = GROOVE ? 1.5 : 0; |
paul@46 | 228 | groove_width_normal = groove_width_exposed + front_back_overlap; |
paul@8 | 229 | groove_depth = 1.0; /* how deep the groove goes into each side */ |
paul@20 | 230 | |
paul@20 | 231 | /* Additional cutting to mate the back and front. */ |
paul@20 | 232 | |
paul@42 | 233 | top_groove_width = groove_width_overlap; |
paul@8 | 234 | top_groove_depth = 2.0; |
paul@20 | 235 | |
paul@29 | 236 | /* |
paul@29 | 237 | Space for the inner edge of the back inside the front. |
paul@29 | 238 | Offsets are measured from the outside surfaces. |
paul@29 | 239 | */ |
paul@20 | 240 | |
paul@50 | 241 | inner_top_front_cutout_width = int_payload_width; |
paul@30 | 242 | inner_top_front_cutout_depth = top_groove_width; |
paul@30 | 243 | inner_top_front_cutout_height = top - top_groove_depth; |
paul@28 | 244 | |
paul@50 | 245 | inner_payload_front_cutout_height = payload_height - top_groove_depth; |
paul@50 | 246 | inner_payload_front_cutout_width = front_side - groove_depth; |
paul@50 | 247 | inner_payload_front_cutout_depth = groove_width_overlap; |
paul@50 | 248 | |
paul@50 | 249 | inner_connector_front_cutout_height = connector_height; |
paul@50 | 250 | inner_connector_front_cutout_width = front_side - groove_depth; |
paul@50 | 251 | inner_connector_front_cutout_depth = groove_width_overlap; |
paul@1 | 252 | |
paul@35 | 253 | /* |
paul@35 | 254 | The back cavity is the indented part at the bottom of the back of the |
paul@40 | 255 | cartridge. It appears to be mechanically superfluous, just making the |
paul@40 | 256 | shape of the cartridge look a bit fancier. |
paul@35 | 257 | */ |
paul@35 | 258 | |
paul@4 | 259 | back_cavity_width = 68.0; |
paul@4 | 260 | back_cavity_inner_width = 65.0; |
paul@40 | 261 | back_cavity_offset_from_inner_left = 9.0; |
paul@40 | 262 | back_cavity_inner_offset_from_inner_left = 10.5; |
paul@4 | 263 | back_cavity_height = 13.5; |
paul@4 | 264 | back_cavity_inner_height = 12.0; |
paul@4 | 265 | back_cavity_depth = 1.5; |
paul@4 | 266 | |
paul@39 | 267 | /* |
paul@40 | 268 | The effect of the cavity on the inside of the case. The most important |
paul@40 | 269 | measurement is the maximum offset since it defines the width of the |
paul@40 | 270 | internal space that should accommodate the plastic guides of the Plus 1 |
paul@40 | 271 | socket. |
paul@39 | 272 | */ |
paul@35 | 273 | |
paul@6 | 274 | inner_back_slope_depth = 2.5; |
paul@40 | 275 | inner_back_slope_width = inner_back_slope_depth; |
paul@40 | 276 | inner_back_slope_max_offset = 10.5; |
paul@40 | 277 | inner_back_slope_min_offset = inner_back_slope_max_offset - inner_back_slope_width; |
paul@5 | 278 | |
paul@40 | 279 | /* The tapering off of the inner back edge. */ |
paul@40 | 280 | |
paul@5 | 281 | inner_back_edge_width = 69.0; |
paul@5 | 282 | inner_back_edge_height = 3.0; |
paul@5 | 283 | inner_back_edge_depth = 1.5; |
paul@5 | 284 | |
paul@40 | 285 | /* The tapering off of the inner front edge. */ |
paul@40 | 286 | |
paul@50 | 287 | inner_front_edge_width = connector_width - front_side * 2; |
paul@7 | 288 | inner_front_edge_height = 3.0; |
paul@7 | 289 | inner_front_edge_depth = 1.5; |
paul@7 | 290 | |
paul@39 | 291 | /* |
paul@39 | 292 | The cutout in the floor of the back of the cartridge that accommodates |
paul@39 | 293 | the edge connector. |
paul@39 | 294 | */ |
paul@39 | 295 | |
paul@8 | 296 | edge_connector_cutout_back_depth = 3.0; |
paul@23 | 297 | edge_connector_cutout_back_width = 57.5; |
paul@8 | 298 | |
paul@17 | 299 | /* |
paul@49 | 300 | The cutouts in the floor of the front of the cartridge that produce a |
paul@49 | 301 | kind of tab that guides the edge connector into place in the back cutout. |
paul@49 | 302 | */ |
paul@49 | 303 | |
paul@49 | 304 | edge_connector_cutout_front_depth = front_back_overlap; |
paul@50 | 305 | edge_connector_cutout_front_width = (int_connector_width - edge_connector_cutout_back_width) / 2; |
paul@49 | 306 | |
paul@49 | 307 | /* |
paul@17 | 308 | Edge connectors are themselves 0.05" or approximately 1.27mm in |
paul@17 | 309 | thickness according to the Acorn Electron Cartridge Interface Specification |
paul@17 | 310 | (Acorn Support Application Group Note 014). |
paul@17 | 311 | */ |
paul@17 | 312 | |
paul@33 | 313 | /* Extra internal features. Depths include front and back surfaces. */ |
paul@14 | 314 | |
paul@23 | 315 | pcb_back_support_width = 1.2; |
paul@14 | 316 | pcb_back_support_depth = back_depth - |
paul@14 | 317 | edge_connector_cutout_back_depth; |
paul@38 | 318 | pcb_back_support_height = height - int_connector_height - top - bottom; |
paul@14 | 319 | |
paul@23 | 320 | pcb_front_support_width = 1.2; |
paul@44 | 321 | pcb_front_support_depth = int_front_depth; |
paul@15 | 322 | pcb_front_support_height = pcb_back_support_height; |
paul@15 | 323 | |
paul@16 | 324 | /* |
paul@45 | 325 | Features measured from the Stardot Dual ROM Adaptor cartridge board |
paul@37 | 326 | dimensions diagram. Offsets are from inside the bottom "floor". |
paul@16 | 327 | */ |
paul@16 | 328 | |
paul@16 | 329 | pcb_back_support_bump_width = pcb_front_support_width; |
paul@18 | 330 | pcb_back_support_bump_depth = 1.5; |
paul@23 | 331 | pcb_back_support_left_bump_height = 13.2; |
paul@23 | 332 | pcb_back_support_right_bump_height = 10.7; |
paul@23 | 333 | pcb_back_support_left_bump_offset_from_bottom = 15.1; |
paul@23 | 334 | pcb_back_support_right_bump_offset_from_bottom = 17.6; |
paul@27 | 335 | pcb_back_support_top_bump_height = 3.8; |
paul@16 | 336 | |
paul@24 | 337 | /* Move the PCB support towards the centre. */ |
paul@35 | 338 | pcb_support_margin = 1.75; |
paul@37 | 339 | pcb_support_offset_from_centre = edge_connector_cutout_back_width / 2 |
paul@37 | 340 | - pcb_support_margin; |
paul@24 | 341 | |
paul@25 | 342 | pcb_lug_depth = pcb_back_support_depth + |
paul@25 | 343 | pcb_back_support_bump_depth; |
paul@25 | 344 | pcb_lug_inner_radius = 1.0; |
paul@25 | 345 | pcb_lug_outer_radius = 5.5 / 2; |
paul@25 | 346 | pcb_lug_offset_from_bottom = 14.35; |
paul@45 | 347 | pcb_lug_offset_from_inside = 5.55; |
paul@25 | 348 | |
paul@25 | 349 | pcb_lug_cross_width = 6.7; |
paul@33 | 350 | pcb_lug_cross_depth = pcb_back_support_depth; |
paul@25 | 351 | pcb_lug_cross_height = 1.4; |
paul@25 | 352 | |
paul@33 | 353 | pcb_front_lug_depth = pcb_back_support_bump_depth + |
paul@44 | 354 | pcb_front_support_depth; |
paul@33 | 355 | pcb_front_lug_inner_radius = pcb_lug_outer_radius; |
paul@33 | 356 | pcb_front_lug_outer_radius = pow( |
paul@33 | 357 | pow(pcb_lug_cross_width / 2, 2) + |
paul@33 | 358 | pow(pcb_lug_cross_height / 2, 2), |
paul@33 | 359 | 0.5); |
paul@33 | 360 | |
paul@25 | 361 | /* Repeated constructs. */ |
paul@25 | 362 | |
paul@26 | 363 | module pcb_support(xdir, bump_height, bump_offset) { |
paul@35 | 364 | |
paul@35 | 365 | /* |
paul@35 | 366 | Translate the support in the stated direction. |
paul@35 | 367 | Since the support is already justified in the direction, the translation |
paul@35 | 368 | moves the inner edge of the support to alignment with the end of the |
paul@35 | 369 | edge connector cutout and then back by the PCB support margin. |
paul@35 | 370 | */ |
paul@35 | 371 | |
paul@25 | 372 | translate([xdir * |
paul@37 | 373 | pcb_support_offset_from_centre, |
paul@25 | 374 | edge_connector_cutout_back_depth, |
paul@45 | 375 | int_payload_lower_extent]) |
paul@25 | 376 | justify(pcb_back_support_width, |
paul@25 | 377 | pcb_back_support_depth, |
paul@25 | 378 | pcb_back_support_height, |
paul@25 | 379 | xdir, 1, 1) |
paul@25 | 380 | union() { |
paul@27 | 381 | |
paul@27 | 382 | /* Underlying support strut. */ |
paul@27 | 383 | |
paul@25 | 384 | cube([pcb_back_support_width, |
paul@25 | 385 | pcb_back_support_depth, |
paul@25 | 386 | pcb_back_support_height], center = true); |
paul@27 | 387 | |
paul@27 | 388 | /* Middle bump. */ |
paul@27 | 389 | |
paul@25 | 390 | cube_at(pcb_back_support_bump_width, |
paul@25 | 391 | pcb_back_support_bump_depth, |
paul@26 | 392 | bump_height, |
paul@25 | 393 | 0, -1, 1, |
paul@25 | 394 | 0, |
paul@25 | 395 | -pcb_back_support_depth / 2, |
paul@26 | 396 | -pcb_back_support_height / 2 + bump_offset); |
paul@27 | 397 | |
paul@27 | 398 | /* Top bump. */ |
paul@27 | 399 | |
paul@27 | 400 | cube_at(pcb_back_support_bump_width, |
paul@27 | 401 | pcb_back_support_bump_depth, |
paul@27 | 402 | pcb_back_support_top_bump_height, |
paul@27 | 403 | 0, -1, 1, |
paul@27 | 404 | 0, |
paul@27 | 405 | -pcb_back_support_depth / 2, |
paul@27 | 406 | pcb_back_support_height / 2 - |
paul@27 | 407 | pcb_back_support_top_bump_height); |
paul@25 | 408 | } |
paul@25 | 409 | } |
paul@25 | 410 | |
paul@25 | 411 | module pcb_lug(xdir) { |
paul@25 | 412 | translate([xdir * |
paul@50 | 413 | (int_connector_width / 2 - pcb_lug_offset_from_inside), |
paul@25 | 414 | back_depth, |
paul@45 | 415 | int_payload_lower_extent + pcb_lug_offset_from_bottom |
paul@25 | 416 | ]) |
paul@25 | 417 | rotate([90, 0, 0]) |
paul@25 | 418 | difference() { |
paul@25 | 419 | union() { |
paul@25 | 420 | cylinder(h=pcb_lug_depth, r=pcb_lug_outer_radius); |
paul@25 | 421 | cube_at(pcb_lug_cross_width, |
paul@25 | 422 | pcb_lug_cross_height, pcb_lug_cross_depth, |
paul@25 | 423 | 0, 0, 1, |
paul@25 | 424 | 0, 0, 0); |
paul@25 | 425 | cube_at(pcb_lug_cross_height, |
paul@25 | 426 | pcb_lug_cross_width, pcb_lug_cross_depth, |
paul@25 | 427 | 0, 0, 1, |
paul@25 | 428 | 0, 0, 0); |
paul@25 | 429 | } |
paul@25 | 430 | cylinder(h=pcb_lug_depth, r=pcb_lug_inner_radius); |
paul@47 | 431 | translate([0, 0, pcb_lug_depth - pcb_lug_ro]) |
paul@47 | 432 | fillet_torus(pcb_lug_outer_radius, pcb_lug_rr); |
paul@25 | 433 | } |
paul@25 | 434 | } |
paul@25 | 435 | |
paul@33 | 436 | module pcb_front_lug(xdir) { |
paul@33 | 437 | translate([xdir * |
paul@50 | 438 | (int_connector_width / 2 - pcb_lug_offset_from_inside), |
paul@39 | 439 | -int_front_depth + pcb_front_lug_depth, |
paul@45 | 440 | int_payload_lower_extent + pcb_lug_offset_from_bottom |
paul@33 | 441 | ]) |
paul@33 | 442 | rotate([90, 0, 0]) |
paul@33 | 443 | difference() { |
paul@33 | 444 | cylinder(h=pcb_front_lug_depth, |
paul@33 | 445 | r=pcb_front_lug_outer_radius); |
paul@33 | 446 | cylinder(h=pcb_front_lug_depth, |
paul@33 | 447 | r=pcb_front_lug_inner_radius); |
paul@33 | 448 | } |
paul@33 | 449 | } |
paul@33 | 450 | |
paul@25 | 451 | /* The actual shapes. */ |
paul@25 | 452 | |
paul@51 | 453 | front_displacement = APART ? -connector_width * 0.6 : 0; |
paul@43 | 454 | |
paul@43 | 455 | if (FRONT) |
paul@43 | 456 | translate([front_displacement, 0, 0]) |
paul@43 | 457 | difference() { |
paul@1 | 458 | |
paul@43 | 459 | /* The cartridge surfaces. */ |
paul@1 | 460 | |
paul@43 | 461 | union() { |
paul@8 | 462 | |
paul@43 | 463 | /* Front portion. */ |
paul@8 | 464 | |
paul@43 | 465 | if (FRONT_SURFACE) { |
paul@50 | 466 | |
paul@50 | 467 | /* Surfaces surrounding the payload. */ |
paul@50 | 468 | |
paul@50 | 469 | cube_at(payload_width, front, payload_height, |
paul@50 | 470 | 0, -1, 1, |
paul@51 | 471 | payload_centre, -int_front_depth, int_payload_lower_extent); |
paul@50 | 472 | |
paul@50 | 473 | cube_at(front_left, front_depth, payload_height, |
paul@50 | 474 | -1, -1, 1, |
paul@51 | 475 | int_payload_left_extent, 0, int_payload_lower_extent); |
paul@50 | 476 | |
paul@50 | 477 | cube_at(front_right, front_depth, payload_height, |
paul@50 | 478 | 1, -1, 1, |
paul@51 | 479 | int_payload_right_extent, 0, int_payload_lower_extent); |
paul@50 | 480 | |
paul@50 | 481 | /* Surfaces surrounding the connector. */ |
paul@50 | 482 | |
paul@50 | 483 | cube_at(connector_width, front, connector_height, |
paul@50 | 484 | 0, -1, -1, |
paul@50 | 485 | 0, -int_front_depth, int_payload_lower_extent); |
paul@50 | 486 | |
paul@50 | 487 | cube_at(front_left, front_depth, connector_height, |
paul@50 | 488 | -1, -1, -1, |
paul@50 | 489 | -int_connector_width / 2, 0, int_payload_lower_extent); |
paul@50 | 490 | |
paul@50 | 491 | cube_at(front_right, front_depth, connector_height, |
paul@50 | 492 | 1, -1, -1, |
paul@50 | 493 | int_connector_width / 2, 0, int_payload_lower_extent); |
paul@50 | 494 | |
paul@50 | 495 | /* Top surface for the front piece. */ |
paul@50 | 496 | |
paul@50 | 497 | cube_at(payload_width, front_depth, top, |
paul@43 | 498 | 0, -1, 1, |
paul@51 | 499 | payload_centre, 0, int_payload_upper_extent); |
paul@43 | 500 | } |
paul@20 | 501 | |
paul@43 | 502 | difference() { |
paul@43 | 503 | |
paul@43 | 504 | /* Floor of cartridge. */ |
paul@43 | 505 | |
paul@50 | 506 | cube_at(int_connector_width, int_front_depth, bottom, |
paul@43 | 507 | 0, -1, 1, |
paul@43 | 508 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 509 | |
paul@43 | 510 | /* Left cutout. */ |
paul@20 | 511 | |
paul@43 | 512 | cube_at(edge_connector_cutout_front_width, |
paul@43 | 513 | edge_connector_cutout_front_depth, |
paul@43 | 514 | bottom, |
paul@43 | 515 | 1, -1, 1, |
paul@50 | 516 | -int_connector_width / 2, |
paul@43 | 517 | 0, |
paul@43 | 518 | -height / 2 + int_connector_height); |
paul@43 | 519 | |
paul@43 | 520 | /* Right cutout. */ |
paul@20 | 521 | |
paul@43 | 522 | cube_at(edge_connector_cutout_front_width, |
paul@43 | 523 | edge_connector_cutout_front_depth, |
paul@43 | 524 | bottom, |
paul@43 | 525 | -1, -1, 1, |
paul@50 | 526 | int_connector_width / 2, |
paul@43 | 527 | 0, |
paul@43 | 528 | -height / 2 + int_connector_height); |
paul@43 | 529 | } |
paul@43 | 530 | |
paul@52 | 531 | /* Extended floor. */ |
paul@52 | 532 | |
paul@52 | 533 | if (payload_width > connector_width) { |
paul@52 | 534 | |
paul@52 | 535 | cube_at(payload_width - connector_width, front_depth, bottom, |
paul@52 | 536 | 1, -1, 1, |
paul@52 | 537 | payload_left_extent, 0, -height / 2 + int_connector_height); |
paul@52 | 538 | } |
paul@52 | 539 | |
paul@43 | 540 | /* PCB supports. */ |
paul@20 | 541 | |
paul@53 | 542 | if (ROM_CARTRIDGE) { |
paul@53 | 543 | cube_at(pcb_front_support_width, |
paul@53 | 544 | pcb_front_support_depth, |
paul@53 | 545 | pcb_front_support_height, |
paul@53 | 546 | -1, -1, 1, |
paul@53 | 547 | -pcb_support_offset_from_centre, |
paul@53 | 548 | 0, |
paul@53 | 549 | int_payload_lower_extent); |
paul@20 | 550 | |
paul@53 | 551 | cube_at(pcb_front_support_width, |
paul@53 | 552 | pcb_front_support_depth, |
paul@53 | 553 | pcb_front_support_height, |
paul@53 | 554 | 1, -1, 1, |
paul@53 | 555 | pcb_support_offset_from_centre, |
paul@53 | 556 | 0, |
paul@53 | 557 | int_payload_lower_extent); |
paul@20 | 558 | |
paul@53 | 559 | /* Circular "lugs" to hold PCBs in place. */ |
paul@43 | 560 | |
paul@53 | 561 | pcb_front_lug(-1); |
paul@53 | 562 | pcb_front_lug(1); |
paul@53 | 563 | } |
paul@8 | 564 | } |
paul@15 | 565 | |
paul@43 | 566 | /* Label insets. */ |
paul@43 | 567 | |
paul@43 | 568 | union() { |
paul@43 | 569 | |
paul@43 | 570 | /* Front label. */ |
paul@15 | 571 | |
paul@43 | 572 | if (FRONT_LABEL_INSET) |
paul@51 | 573 | translate([front_label_left_extent, -front_depth, |
paul@43 | 574 | front_label_offset_from_bottom - height / 2]) |
paul@43 | 575 | cube([front_label_width, front_label_depth, |
paul@43 | 576 | front_label_height]); |
paul@33 | 577 | |
paul@43 | 578 | /* Top label. See also the back piece. */ |
paul@10 | 579 | |
paul@43 | 580 | if (TOP_LABEL_INSET) |
paul@51 | 581 | translate([top_label_left_extent, |
paul@43 | 582 | -front_depth + top_label_offset_from_front, |
paul@43 | 583 | height / 2 - top_label_depth]) |
paul@43 | 584 | cube([top_label_width, top_label_height, |
paul@43 | 585 | top_label_depth]); |
paul@43 | 586 | } |
paul@10 | 587 | |
paul@43 | 588 | /* Inner front edge cavity. */ |
paul@10 | 589 | |
paul@43 | 590 | translate([inner_front_edge_width / 2, -int_front_depth, -height / 2]) |
paul@43 | 591 | rotate([0, -90, 0]) |
paul@43 | 592 | linear_extrude(height = inner_front_edge_width) |
paul@43 | 593 | polygon([ |
paul@43 | 594 | [-extra, -inner_front_edge_depth], |
paul@43 | 595 | [0, -inner_front_edge_depth], |
paul@43 | 596 | [inner_front_edge_height, 0], |
paul@43 | 597 | [-extra, 0], |
paul@43 | 598 | ]); |
paul@10 | 599 | |
paul@43 | 600 | /* Inner top cutout for the top and sides of the back portion. */ |
paul@10 | 601 | |
paul@43 | 602 | cube_at(inner_top_front_cutout_width, |
paul@43 | 603 | inner_top_front_cutout_depth, |
paul@43 | 604 | inner_top_front_cutout_height, |
paul@51 | 605 | 1, -1, 1, |
paul@51 | 606 | int_payload_left_extent, 0, int_payload_upper_extent); |
paul@11 | 607 | |
paul@50 | 608 | cube_at(inner_payload_front_cutout_width, |
paul@50 | 609 | inner_payload_front_cutout_depth, |
paul@50 | 610 | inner_payload_front_cutout_height, |
paul@50 | 611 | 1, -1, 1, |
paul@51 | 612 | int_payload_right_extent, 0, int_payload_lower_extent); |
paul@50 | 613 | |
paul@50 | 614 | cube_at(inner_payload_front_cutout_width, |
paul@50 | 615 | inner_payload_front_cutout_depth, |
paul@50 | 616 | inner_payload_front_cutout_height, |
paul@50 | 617 | -1, -1, 1, |
paul@51 | 618 | int_payload_left_extent, 0, int_payload_lower_extent); |
paul@11 | 619 | |
paul@50 | 620 | cube_at(inner_connector_front_cutout_width, |
paul@50 | 621 | inner_connector_front_cutout_depth, |
paul@50 | 622 | inner_connector_front_cutout_height, |
paul@50 | 623 | 1, -1, -1, |
paul@50 | 624 | int_connector_width / 2, 0, int_payload_lower_extent); |
paul@50 | 625 | |
paul@50 | 626 | cube_at(inner_connector_front_cutout_width, |
paul@50 | 627 | inner_connector_front_cutout_depth, |
paul@50 | 628 | inner_connector_front_cutout_height, |
paul@50 | 629 | -1, -1, -1, |
paul@50 | 630 | -int_connector_width / 2, 0, int_payload_lower_extent); |
paul@28 | 631 | |
paul@43 | 632 | /* Fillets to round off the edges. */ |
paul@43 | 633 | |
paul@43 | 634 | union() { |
paul@28 | 635 | |
paul@43 | 636 | /* Top left and right rounding. */ |
paul@43 | 637 | |
paul@51 | 638 | translate([payload_left_extent + ro, -front_depth / 2, height / 2 - ro]) |
paul@43 | 639 | rotate([0, 0, 180]) |
paul@43 | 640 | rotate([90, 0, 0]) |
paul@43 | 641 | fillet(rr, front_depth); |
paul@51 | 642 | translate([payload_right_extent - ro, -front_depth / 2, height / 2 - ro]) |
paul@10 | 643 | rotate([90, 0, 0]) |
paul@10 | 644 | fillet(rr, front_depth); |
paul@10 | 645 | |
paul@43 | 646 | /* Top front rounding. */ |
paul@43 | 647 | |
paul@51 | 648 | translate([payload_centre, -front_depth + ro, height / 2 - ro]) |
paul@43 | 649 | rotate([0, 0, 180]) |
paul@43 | 650 | rotate([0, -90, 0]) |
paul@50 | 651 | fillet(rr, payload_width); |
paul@10 | 652 | |
paul@43 | 653 | /* Edge rounding. */ |
paul@43 | 654 | |
paul@52 | 655 | translate([payload_right_extent - ro, -front_depth + ro, int_payload_lower_extent - bottom - extra]) |
paul@52 | 656 | rotate([0, 0, 270]) |
paul@52 | 657 | fillet_justified(rr, payload_height + bottom + extra); |
paul@52 | 658 | |
paul@52 | 659 | translate([payload_left_extent + ro, -front_depth + ro, int_payload_lower_extent - bottom - extra]) |
paul@43 | 660 | rotate([0, 0, 180]) |
paul@52 | 661 | fillet_justified(rr, payload_height + bottom + extra); |
paul@52 | 662 | |
paul@52 | 663 | translate([connector_width / 2 - ro, -front_depth + ro, -height / 2]) |
paul@43 | 664 | rotate([0, 0, 270]) |
paul@52 | 665 | fillet_partitioned(rr, connector_height - bottom); |
paul@52 | 666 | |
paul@52 | 667 | translate([-connector_width / 2 + ro, -front_depth + ro, -height / 2]) |
paul@52 | 668 | rotate([0, 0, 180]) |
paul@52 | 669 | fillet_partitioned(rr, connector_height - bottom); |
paul@43 | 670 | } |
paul@10 | 671 | } |
paul@10 | 672 | |
paul@41 | 673 | /* |
paul@41 | 674 | Place the back piece next to the front, with the internals facing out |
paul@43 | 675 | the same way, if APART is defined. |
paul@41 | 676 | */ |
paul@41 | 677 | |
paul@51 | 678 | back_displacement = APART ? connector_width * 0.6 : 0; |
paul@43 | 679 | back_rotation = APART ? 180 : 0; |
paul@43 | 680 | |
paul@43 | 681 | if (BACK) |
paul@43 | 682 | translate([back_displacement, 0, 0]) |
paul@43 | 683 | rotate([0, 0, back_rotation]) |
paul@43 | 684 | difference() { |
paul@43 | 685 | |
paul@43 | 686 | /* The cartridge surfaces. */ |
paul@43 | 687 | |
paul@43 | 688 | union() { |
paul@43 | 689 | |
paul@43 | 690 | /* Back portion. */ |
paul@10 | 691 | |
paul@43 | 692 | if (BACK_SURFACE) { |
paul@49 | 693 | |
paul@50 | 694 | /* Surfaces surrounding the payload. */ |
paul@50 | 695 | |
paul@49 | 696 | /* Payload section of back surface. */ |
paul@49 | 697 | |
paul@50 | 698 | cube_at(payload_width, payload_back, payload_height, |
paul@49 | 699 | 0, 1, 1, |
paul@51 | 700 | payload_centre, int_payload_back_depth, int_payload_lower_extent); |
paul@49 | 701 | |
paul@50 | 702 | cube_at(back_left, back_depth, payload_height, |
paul@50 | 703 | -1, 1, 1, |
paul@51 | 704 | int_payload_left_extent, 0, int_payload_lower_extent); |
paul@50 | 705 | |
paul@50 | 706 | cube_at(back_right, back_depth, payload_height, |
paul@50 | 707 | 1, 1, 1, |
paul@51 | 708 | int_payload_right_extent, 0, int_payload_lower_extent); |
paul@50 | 709 | |
paul@50 | 710 | /* Surfaces surrounding the connector. */ |
paul@50 | 711 | |
paul@49 | 712 | /* Connector section of back surface overlapping the floor. */ |
paul@49 | 713 | |
paul@50 | 714 | cube_at(connector_width, connector_back, connector_height, |
paul@50 | 715 | 0, 1, -1, |
paul@50 | 716 | 0, int_connector_back_depth, int_payload_lower_extent); |
paul@46 | 717 | |
paul@50 | 718 | cube_at(back_left, back_depth, connector_height, |
paul@50 | 719 | -1, 1, -1, |
paul@50 | 720 | -int_connector_width / 2, 0, int_payload_lower_extent); |
paul@46 | 721 | |
paul@50 | 722 | cube_at(back_right, back_depth, connector_height, |
paul@50 | 723 | 1, 1, -1, |
paul@50 | 724 | int_connector_width / 2, 0, int_payload_lower_extent); |
paul@46 | 725 | |
paul@49 | 726 | /* Top of back piece. */ |
paul@49 | 727 | |
paul@50 | 728 | cube_at(payload_width, back_depth, top, |
paul@43 | 729 | 0, 1, 1, |
paul@51 | 730 | payload_centre, 0, int_payload_upper_extent); |
paul@46 | 731 | |
paul@50 | 732 | /* |
paul@50 | 733 | The extension of the back to connect with the front. Here, the inside |
paul@50 | 734 | edges are rounded. The outside edges are rounded later. |
paul@50 | 735 | |
paul@50 | 736 | An extra overlapping measure is employed so that the filleting is |
paul@50 | 737 | continuous between the payload and connector portions. On the inside |
paul@50 | 738 | edges, the connector filleting is extended upwards. |
paul@50 | 739 | */ |
paul@50 | 740 | |
paul@50 | 741 | /* Left side of payload. */ |
paul@46 | 742 | |
paul@46 | 743 | difference() { |
paul@50 | 744 | cube_at(back_left - groove_depth, groove_width_extra, inner_payload_front_cutout_height, |
paul@46 | 745 | -1, 1, 1, |
paul@51 | 746 | int_payload_left_extent, -groove_width_extra, int_payload_lower_extent); |
paul@51 | 747 | translate([int_payload_left_extent - groove_ro, -groove_width_extra + groove_ro, |
paul@50 | 748 | int_payload_lower_extent]) |
paul@46 | 749 | rotate([0, 0, -90]) |
paul@50 | 750 | fillet_justified(groove_rr, inner_payload_front_cutout_height); |
paul@46 | 751 | } |
paul@46 | 752 | |
paul@50 | 753 | /* Right side of payload. */ |
paul@50 | 754 | |
paul@46 | 755 | difference() { |
paul@50 | 756 | cube_at(back_right - groove_depth, groove_width_extra, inner_payload_front_cutout_height, |
paul@46 | 757 | 1, 1, 1, |
paul@51 | 758 | int_payload_right_extent, -groove_width_extra, int_payload_lower_extent); |
paul@51 | 759 | translate([int_payload_right_extent + groove_ro, -groove_width_extra + groove_ro, |
paul@50 | 760 | int_payload_lower_extent]) |
paul@50 | 761 | rotate([0, 0, 180]) |
paul@50 | 762 | fillet_justified(groove_rr, inner_payload_front_cutout_height); |
paul@50 | 763 | } |
paul@50 | 764 | |
paul@50 | 765 | /* Left side of connector. */ |
paul@50 | 766 | |
paul@50 | 767 | difference() { |
paul@50 | 768 | cube_at(back_left - groove_depth, groove_width_extra, inner_connector_front_cutout_height, |
paul@50 | 769 | -1, 1, -1, |
paul@50 | 770 | -int_connector_width / 2, -groove_width_extra, int_payload_lower_extent); |
paul@50 | 771 | translate([-int_connector_width / 2 - groove_ro, -groove_width_extra + groove_ro, |
paul@50 | 772 | -height / 2]) |
paul@50 | 773 | rotate([0, 0, -90]) |
paul@50 | 774 | fillet_partitioned(groove_rr, inner_connector_front_cutout_height + extra); |
paul@50 | 775 | } |
paul@50 | 776 | |
paul@50 | 777 | /* Right side of connector. */ |
paul@50 | 778 | |
paul@50 | 779 | difference() { |
paul@50 | 780 | cube_at(back_right - groove_depth, groove_width_extra, inner_connector_front_cutout_height, |
paul@50 | 781 | 1, 1, -1, |
paul@50 | 782 | int_connector_width / 2, -groove_width_extra, int_payload_lower_extent); |
paul@50 | 783 | translate([int_connector_width / 2 + groove_ro, -groove_width_extra + groove_ro, |
paul@46 | 784 | -height / 2]) |
paul@46 | 785 | rotate([0, 0, 180]) |
paul@50 | 786 | fillet_partitioned(groove_rr, inner_connector_front_cutout_height + extra); |
paul@46 | 787 | } |
paul@46 | 788 | |
paul@50 | 789 | /* Top side. */ |
paul@50 | 790 | |
paul@46 | 791 | difference() { |
paul@50 | 792 | cube_at(payload_width - groove_depth * 2, groove_width_extra, top - top_groove_depth, |
paul@46 | 793 | 0, 1, 1, |
paul@51 | 794 | payload_centre, -groove_width_extra, int_payload_upper_extent); |
paul@51 | 795 | translate([payload_centre, -groove_width_extra + groove_ro, |
paul@46 | 796 | int_payload_upper_extent + groove_ro]) |
paul@46 | 797 | rotate([0, 0, 180]) |
paul@46 | 798 | rotate([0, 90, 0]) |
paul@50 | 799 | fillet(groove_rr, payload_width - groove_depth * 2); |
paul@46 | 800 | } |
paul@43 | 801 | } |
paul@10 | 802 | |
paul@43 | 803 | difference() { |
paul@8 | 804 | |
paul@43 | 805 | /* Floor of cartridge. */ |
paul@8 | 806 | |
paul@50 | 807 | cube_at(int_connector_width, int_connector_back_depth, bottom, |
paul@43 | 808 | 0, 1, 1, |
paul@43 | 809 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 810 | |
paul@43 | 811 | /* Edge connector cutout. */ |
paul@43 | 812 | |
paul@43 | 813 | cube_at(edge_connector_cutout_back_width, |
paul@43 | 814 | edge_connector_cutout_back_depth, |
paul@43 | 815 | bottom, |
paul@43 | 816 | 0, 1, 1, |
paul@43 | 817 | 0, 0, -height / 2 + int_connector_height); |
paul@43 | 818 | } |
paul@43 | 819 | |
paul@52 | 820 | /* Extended floor. */ |
paul@52 | 821 | |
paul@52 | 822 | if (payload_width > connector_width) { |
paul@52 | 823 | |
paul@52 | 824 | difference() { |
paul@52 | 825 | |
paul@52 | 826 | cube_at(payload_width - connector_width, back_depth, bottom, |
paul@52 | 827 | 1, 1, 1, |
paul@52 | 828 | payload_left_extent, 0, -height / 2 + int_connector_height); |
paul@52 | 829 | |
paul@52 | 830 | cube_at(payload_width - connector_width, edge_connector_cutout_front_depth, bottom, |
paul@52 | 831 | 1, 1, 1, |
paul@52 | 832 | payload_left_extent, 0, -height / 2 + int_connector_height); |
paul@52 | 833 | } |
paul@52 | 834 | } |
paul@52 | 835 | |
paul@43 | 836 | /* PCB supports. */ |
paul@42 | 837 | |
paul@53 | 838 | if (ROM_CARTRIDGE) { |
paul@53 | 839 | pcb_support(-1, pcb_back_support_left_bump_height, |
paul@53 | 840 | pcb_back_support_left_bump_offset_from_bottom); |
paul@53 | 841 | pcb_support(1, pcb_back_support_right_bump_height, |
paul@53 | 842 | pcb_back_support_right_bump_offset_from_bottom); |
paul@20 | 843 | |
paul@53 | 844 | /* Circular "lugs" to hold PCBs in place. */ |
paul@43 | 845 | |
paul@53 | 846 | pcb_lug(-1); |
paul@53 | 847 | pcb_lug(1); |
paul@53 | 848 | } |
paul@43 | 849 | } |
paul@20 | 850 | |
paul@43 | 851 | /* Label insets. */ |
paul@43 | 852 | |
paul@43 | 853 | union() { |
paul@43 | 854 | |
paul@43 | 855 | /* Top label. See also the front piece. */ |
paul@20 | 856 | |
paul@43 | 857 | if (TOP_LABEL_INSET) |
paul@51 | 858 | translate([top_label_left_extent, |
paul@43 | 859 | -front_depth + top_label_offset_from_front, |
paul@43 | 860 | height / 2 - top_label_depth]) |
paul@43 | 861 | cube([top_label_width, top_label_height, |
paul@43 | 862 | top_label_depth]); |
paul@8 | 863 | } |
paul@14 | 864 | |
paul@43 | 865 | /* Top and side grooves, positioned in the back portion. */ |
paul@25 | 866 | |
paul@43 | 867 | union() { |
paul@0 | 868 | |
paul@43 | 869 | /* Left groove. */ |
paul@1 | 870 | |
paul@46 | 871 | cube_at(groove_depth, groove_width_normal, height, |
paul@43 | 872 | 1, 1, 0, |
paul@51 | 873 | payload_left_extent, 0, 0); |
paul@2 | 874 | |
paul@43 | 875 | /* Right groove. */ |
paul@2 | 876 | |
paul@46 | 877 | cube_at(groove_depth, groove_width_normal, height, |
paul@43 | 878 | -1, 1, 0, |
paul@51 | 879 | payload_right_extent, 0, 0); |
paul@8 | 880 | |
paul@43 | 881 | /* Top grooves. */ |
paul@4 | 882 | |
paul@50 | 883 | cube_at(payload_width, groove_width_normal, groove_depth, |
paul@43 | 884 | 0, 1, -1, |
paul@51 | 885 | payload_centre, 0, height / 2); |
paul@4 | 886 | |
paul@50 | 887 | cube_at(payload_width, top_groove_width, top_groove_depth, |
paul@43 | 888 | 0, 1, -1, |
paul@51 | 889 | payload_centre, -groove_width_extra, height / 2); |
paul@41 | 890 | } |
paul@2 | 891 | |
paul@43 | 892 | /* Back cavity. */ |
paul@43 | 893 | |
paul@43 | 894 | if (BACK_CAVITY) |
paul@43 | 895 | intersection() { |
paul@43 | 896 | |
paul@43 | 897 | /* From the bottom upwards. */ |
paul@5 | 898 | |
paul@43 | 899 | translate([0, back_depth, -height / 2]) |
paul@43 | 900 | linear_extrude(height = back_cavity_height) |
paul@50 | 901 | translate([-int_connector_width / 2, 0, 0]) |
paul@43 | 902 | polygon([ |
paul@43 | 903 | [back_cavity_offset_from_inner_left, 0], |
paul@43 | 904 | [back_cavity_inner_offset_from_inner_left, |
paul@43 | 905 | -back_cavity_depth], |
paul@43 | 906 | [back_cavity_inner_offset_from_inner_left + |
paul@43 | 907 | back_cavity_inner_width, |
paul@43 | 908 | -back_cavity_depth], |
paul@43 | 909 | [back_cavity_offset_from_inner_left + |
paul@43 | 910 | back_cavity_width, 0] |
paul@43 | 911 | ]); |
paul@43 | 912 | |
paul@43 | 913 | /* From left to right. */ |
paul@43 | 914 | |
paul@43 | 915 | translate([back_cavity_width / 2, back_depth, -height / 2]) |
paul@43 | 916 | rotate([0, -90, 0]) |
paul@43 | 917 | linear_extrude(height = back_cavity_width) |
paul@43 | 918 | polygon([ |
paul@43 | 919 | [-extra, -back_cavity_depth], |
paul@43 | 920 | [back_cavity_inner_height, |
paul@43 | 921 | -back_cavity_depth], |
paul@43 | 922 | [back_cavity_height, 0], |
paul@43 | 923 | [-extra, 0] |
paul@43 | 924 | ]); |
paul@43 | 925 | } |
paul@43 | 926 | |
paul@43 | 927 | /* Inner back cavities. */ |
paul@5 | 928 | |
paul@49 | 929 | translate([0, int_connector_back_depth, -height / 2]) |
paul@43 | 930 | linear_extrude(height = int_connector_height) |
paul@50 | 931 | translate([-int_connector_width / 2, 0, 0]) |
paul@43 | 932 | polygon([ |
paul@43 | 933 | [0, 0], |
paul@43 | 934 | [inner_back_slope_max_offset, 0], |
paul@43 | 935 | [inner_back_slope_min_offset, |
paul@43 | 936 | inner_back_slope_depth], |
paul@43 | 937 | [0, inner_back_slope_depth] |
paul@43 | 938 | ]); |
paul@5 | 939 | |
paul@49 | 940 | translate([0, int_connector_back_depth, -height / 2]) |
paul@43 | 941 | linear_extrude(height = int_connector_height) |
paul@50 | 942 | translate([int_connector_width / 2, 0, 0]) |
paul@43 | 943 | polygon([ |
paul@43 | 944 | [0, 0], |
paul@43 | 945 | [-inner_back_slope_max_offset, 0], |
paul@43 | 946 | [-inner_back_slope_min_offset, |
paul@43 | 947 | inner_back_slope_depth], |
paul@43 | 948 | [0, inner_back_slope_depth] |
paul@43 | 949 | ]); |
paul@7 | 950 | |
paul@43 | 951 | /* Inner back edge cavity. */ |
paul@5 | 952 | |
paul@43 | 953 | translate([inner_back_edge_width / 2, |
paul@49 | 954 | int_connector_back_depth + inner_back_edge_depth, -height / 2]) |
paul@43 | 955 | rotate([0, -90, 0]) |
paul@43 | 956 | linear_extrude(height = inner_back_edge_width) |
paul@43 | 957 | polygon([ |
paul@43 | 958 | [-extra, -inner_back_edge_depth], |
paul@43 | 959 | [inner_back_edge_height, -inner_back_edge_depth], |
paul@43 | 960 | [0, 0], |
paul@43 | 961 | [-extra, 0] |
paul@43 | 962 | ]); |
paul@0 | 963 | |
paul@43 | 964 | /* Fillets to round off the edges. */ |
paul@43 | 965 | |
paul@43 | 966 | union() { |
paul@43 | 967 | |
paul@43 | 968 | /* Top left and right rounding. */ |
paul@43 | 969 | |
paul@51 | 970 | translate([payload_left_extent + ro, back_depth / 2, height / 2 - ro]) |
paul@43 | 971 | rotate([0, 0, 180]) |
paul@43 | 972 | rotate([90, 0, 0]) |
paul@43 | 973 | fillet(rr, back_depth); |
paul@51 | 974 | translate([payload_right_extent - ro, back_depth / 2, height / 2 - ro]) |
paul@9 | 975 | rotate([90, 0, 0]) |
paul@9 | 976 | fillet(rr, back_depth); |
paul@43 | 977 | |
paul@43 | 978 | /* Top back rounding. */ |
paul@43 | 979 | |
paul@51 | 980 | translate([payload_centre, back_depth - ro, height / 2 - ro]) |
paul@43 | 981 | rotate([0, -90, 0]) |
paul@50 | 982 | fillet(rr, payload_width); |
paul@43 | 983 | |
paul@50 | 984 | /* Outer edge rounding. */ |
paul@43 | 985 | |
paul@52 | 986 | translate([payload_right_extent - ro, back_depth - ro, int_payload_lower_extent - bottom - extra]) |
paul@52 | 987 | fillet_justified(rr, payload_height + bottom + extra); |
paul@50 | 988 | |
paul@52 | 989 | translate([payload_left_extent + ro, back_depth - ro, int_payload_lower_extent - bottom - extra]) |
paul@50 | 990 | rotate([0, 0, 90]) |
paul@52 | 991 | fillet_justified(rr, payload_height + bottom + extra); |
paul@50 | 992 | |
paul@50 | 993 | translate([connector_width / 2 - ro, back_depth - ro, -height / 2]) |
paul@52 | 994 | fillet_partitioned(rr, connector_height - bottom); |
paul@50 | 995 | |
paul@50 | 996 | translate([-connector_width / 2 + ro, back_depth - ro, -height / 2]) |
paul@43 | 997 | rotate([0, 0, 90]) |
paul@52 | 998 | fillet_partitioned(rr, connector_height - bottom); |
paul@50 | 999 | |
paul@50 | 1000 | /* |
paul@50 | 1001 | Outer edge rounding of the back extension. This is done as a |
paul@50 | 1002 | separate removal operation rather than occurring when creating the |
paul@50 | 1003 | extension in order to ensure that the edges are actually rounded. |
paul@50 | 1004 | |
paul@50 | 1005 | An extra overlapping measure is employed so that the filleting is |
paul@50 | 1006 | continuous between the payload and connector portions. On the outside |
paul@50 | 1007 | edges, the payload filleting is extended downwards. |
paul@50 | 1008 | */ |
paul@46 | 1009 | |
paul@51 | 1010 | translate([payload_left_extent + groove_depth + groove_ro, -groove_width_extra + groove_ro, |
paul@50 | 1011 | int_payload_lower_extent - extra]) |
paul@50 | 1012 | rotate([0, 0, 180]) |
paul@50 | 1013 | fillet_justified(groove_rr, inner_payload_front_cutout_height + extra); |
paul@46 | 1014 | |
paul@51 | 1015 | translate([payload_right_extent - groove_depth - groove_ro, -groove_width_extra + groove_ro, |
paul@50 | 1016 | int_payload_lower_extent - extra]) |
paul@50 | 1017 | rotate([0, 0, -90]) |
paul@50 | 1018 | fillet_justified(groove_rr, inner_payload_front_cutout_height + extra); |
paul@50 | 1019 | |
paul@50 | 1020 | /* Sides of connector. */ |
paul@50 | 1021 | |
paul@50 | 1022 | translate([-connector_width / 2 + groove_depth + groove_ro, -groove_width_extra + groove_ro, |
paul@46 | 1023 | -height / 2]) |
paul@46 | 1024 | rotate([0, 0, 180]) |
paul@50 | 1025 | fillet_partitioned(groove_rr, inner_connector_front_cutout_height); |
paul@46 | 1026 | |
paul@50 | 1027 | translate([connector_width / 2 - groove_depth - groove_ro, -groove_width_extra + groove_ro, |
paul@46 | 1028 | -height / 2]) |
paul@46 | 1029 | rotate([0, 0, -90]) |
paul@50 | 1030 | fillet_partitioned(groove_rr, inner_connector_front_cutout_height); |
paul@50 | 1031 | |
paul@50 | 1032 | /* Top of payload. */ |
paul@46 | 1033 | |
paul@51 | 1034 | translate([payload_centre, -groove_width_extra + groove_ro, |
paul@46 | 1035 | int_payload_upper_extent + inner_top_front_cutout_height - groove_ro]) |
paul@46 | 1036 | rotate([0, 0, 180]) |
paul@46 | 1037 | rotate([0, -90, 0]) |
paul@50 | 1038 | fillet(groove_rr, payload_width - groove_depth * 2); |
paul@43 | 1039 | } |
paul@0 | 1040 | } |
paul@45 | 1041 | |
paul@45 | 1042 | /* PCB for checking. */ |
paul@45 | 1043 | |
paul@45 | 1044 | pcb_width = 84.85; pcb_height = 62.5; pcb_depth = 1; |
paul@45 | 1045 | edge_connector_width = 56.5; edge_connector_height = 11.85; |
paul@45 | 1046 | pcb_position_y = int_payload_lower_extent; |
paul@45 | 1047 | |
paul@53 | 1048 | /* |
paul@53 | 1049 | The rectangular part of the narrow left and right holes is smaller |
paul@53 | 1050 | than the "bump" in the case, but the circular parts make the overall |
paul@53 | 1051 | hole larger than the "bump". An extra depth is used for holes to avoid |
paul@53 | 1052 | surface definition problems. |
paul@53 | 1053 | */ |
paul@53 | 1054 | |
paul@53 | 1055 | pcb_hole_margin = 0.55; |
paul@53 | 1056 | pcb_hole_width = 2.2; |
paul@53 | 1057 | pcb_hole_extra_depth = 0.1; |
paul@53 | 1058 | pcb_lug_hole_radius = 3.75; |
paul@53 | 1059 | |
paul@53 | 1060 | pcb_left_hole_offset = pcb_back_support_left_bump_offset_from_bottom + pcb_hole_margin; |
paul@53 | 1061 | pcb_left_hole_height = pcb_back_support_left_bump_height - pcb_hole_margin * 2; |
paul@45 | 1062 | pcb_left_hole_offset_from_centre = pcb_support_offset_from_centre + |
paul@53 | 1063 | pcb_back_support_width / 2 - pcb_hole_width / 2; |
paul@45 | 1064 | |
paul@53 | 1065 | pcb_right_hole_offset = pcb_back_support_right_bump_offset_from_bottom + pcb_hole_margin; |
paul@53 | 1066 | pcb_right_hole_height = pcb_back_support_right_bump_height - pcb_hole_margin * 2; |
paul@45 | 1067 | pcb_right_hole_offset_from_centre = -pcb_left_hole_offset_from_centre; |
paul@45 | 1068 | |
paul@53 | 1069 | pcb_hole_depth = pcb_depth + 2 * pcb_hole_extra_depth; |
paul@53 | 1070 | pcb_hole_start_depth = -pcb_hole_extra_depth; |
paul@45 | 1071 | |
paul@53 | 1072 | if (PCB) if (ROM_CARTRIDGE) { |
paul@45 | 1073 | translate([back_displacement, 0, 0]) |
paul@53 | 1074 | translate([0, 0, pcb_position_y]) |
paul@45 | 1075 | difference() { |
paul@45 | 1076 | |
paul@45 | 1077 | /* Mock PCB. */ |
paul@45 | 1078 | |
paul@45 | 1079 | union() { |
paul@45 | 1080 | cube_at(pcb_width, pcb_depth, |
paul@45 | 1081 | pcb_height - edge_connector_height, |
paul@45 | 1082 | 0, 1, 1, |
paul@45 | 1083 | 0, 0, 0); |
paul@45 | 1084 | cube_at(edge_connector_width, pcb_depth, |
paul@45 | 1085 | edge_connector_height, |
paul@45 | 1086 | 0, 1, -1, |
paul@45 | 1087 | 0, 0, 0); |
paul@45 | 1088 | } |
paul@45 | 1089 | |
paul@45 | 1090 | /* Holes for mounting. */ |
paul@45 | 1091 | |
paul@45 | 1092 | union() { |
paul@53 | 1093 | cube_at(pcb_hole_width, 1, pcb_left_hole_height, |
paul@45 | 1094 | 1, 1, 1, |
paul@45 | 1095 | pcb_left_hole_offset_from_centre, 0, pcb_left_hole_offset); |
paul@45 | 1096 | translate([pcb_left_hole_offset_from_centre + |
paul@53 | 1097 | pcb_hole_width / 2, pcb_hole_start_depth, pcb_left_hole_offset]) |
paul@45 | 1098 | rotate([-90, 0, 0]) |
paul@53 | 1099 | cylinder(h=pcb_hole_depth, r=pcb_hole_width / 2); |
paul@45 | 1100 | translate([pcb_left_hole_offset_from_centre + |
paul@53 | 1101 | pcb_hole_width / 2, pcb_hole_start_depth, |
paul@45 | 1102 | pcb_left_hole_offset + pcb_left_hole_height]) |
paul@45 | 1103 | rotate([-90, 0, 0]) |
paul@53 | 1104 | cylinder(h=pcb_hole_depth, r=pcb_hole_width / 2); |
paul@45 | 1105 | } |
paul@45 | 1106 | |
paul@45 | 1107 | union() { |
paul@53 | 1108 | cube_at(pcb_hole_width, 1, pcb_right_hole_height, |
paul@45 | 1109 | -1, 1, 1, |
paul@45 | 1110 | pcb_right_hole_offset_from_centre, 0, pcb_right_hole_offset); |
paul@45 | 1111 | translate([pcb_right_hole_offset_from_centre - |
paul@53 | 1112 | pcb_hole_width / 2, pcb_hole_start_depth, pcb_right_hole_offset]) |
paul@45 | 1113 | rotate([-90, 0, 0]) |
paul@53 | 1114 | cylinder(h=pcb_hole_depth, r=pcb_hole_width / 2); |
paul@45 | 1115 | translate([pcb_right_hole_offset_from_centre - |
paul@53 | 1116 | pcb_hole_width / 2, pcb_hole_start_depth, |
paul@45 | 1117 | pcb_right_hole_offset + pcb_right_hole_height]) |
paul@45 | 1118 | rotate([-90, 0, 0]) |
paul@53 | 1119 | cylinder(h=pcb_hole_depth, r=pcb_hole_width / 2); |
paul@45 | 1120 | } |
paul@45 | 1121 | |
paul@45 | 1122 | /* Holes for lugs. */ |
paul@45 | 1123 | |
paul@45 | 1124 | translate([ |
paul@50 | 1125 | -int_connector_width / 2 + pcb_lug_offset_from_inside, |
paul@45 | 1126 | pcb_hole_start_depth, pcb_lug_offset_from_bottom]) |
paul@45 | 1127 | rotate([-90, 0, 0]) |
paul@45 | 1128 | cylinder(h=pcb_hole_depth, r=pcb_lug_hole_radius); |
paul@45 | 1129 | |
paul@45 | 1130 | translate([ |
paul@50 | 1131 | int_connector_width / 2 - pcb_lug_offset_from_inside, |
paul@45 | 1132 | pcb_hole_start_depth, pcb_lug_offset_from_bottom]) |
paul@45 | 1133 | rotate([-90, 0, 0]) |
paul@45 | 1134 | cylinder(h=pcb_hole_depth, r=pcb_lug_hole_radius); |
paul@45 | 1135 | } |
paul@53 | 1136 | } |
paul@0 | 1137 | } |
paul@0 | 1138 | |
paul@38 | 1139 | cartridge(); |