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