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