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