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